Computer science · 05 / 06

Data and networks: useful abstractions

Final-year concepts · Worked example and 4 exercises with solutions, at your pace.

The principle, simply

Data structures organise values and operations: stacks are last-in first-out; queues are first-in first-out. Networks connect devices exchanging information through protocols. An address, domain name and content differ. Layers separate application, transport and routing concerns.

THE PICTURE TO REMEMBERData and networks: useful abstractions
  1. 01Values
  2. 02Organisation
  3. 03Allowed operations
  4. 04Behaviour and limits

WORKED EXAMPLE

From principle to reasoning

If A then B enter a queue, A is processed first. A call stack completes the latest operation before returning to the previous one.

Solve a problem in this subject

  1. Specify the contract

    Define inputs, types, outputs and forbidden cases. State whether a search algorithm requires sorted data.

  2. Trace a small example

    Tabulate variables, tested conditions and actions using a small hand-checkable example.

  3. Test boundaries

    Consider empty inputs, one item, duplicates, missing values and numeric limits where relevant. Define the output or explain rejection.

  4. Justify

    Explain termination and correctness. Distinguish operation counts, measured time and memory use.

YOUR TURN

01 · Try before checking

A stack receives A then B. Which is removed first?

One hint

Think of stacked plates.

Reveal and understand the solution

B: last-in first-out. A queue would remove A first.

Compare method, conditions and answer; identify the exact part to revisit.

IMPROVE THROUGH PRACTICE

Three additional challenges with solutions

Start with the first challenge. Write your method before opening a hint; use the solution to find the first step that needs work.

Reflect after practising
02 · Recognise and understandLink to this exercise

Push A then B onto a stack. Which exits first?

A hint to get started

A stack is last-in, first-out.

Step-by-step solution
  1. B was added last.
  2. B exits first: LIFO.
  3. An ordinary queue would release A first: FIFO.

Which step did you miss? Retry without help, then explain why the method works.

03 · Apply the methodLink to this exercise

Distinguish URL, domain name and IP address.

A hint to get started

One describes a resource access location.

Step-by-step solution
  1. A URL identifies a resource and protocol.
  2. A domain is a name resolved notably through DNS.
  3. An IP address identifies a network interface in context, not a web page.

Which step did you miss? Retry without help, then explain why the method works.

04 · Go furtherLink to this exercise

Why can a message be divided into packets?

A hint to get started

Networks transport smaller units.

Step-by-step solution
  1. Data is segmented for transmission.
  2. Protocol mechanisms can manage ordering and retransmission.
  3. Details depend on protocol; not all communication guarantees the same properties.

Which step did you miss? Retry without help, then explain why the method works.

The trap to avoid

An analogy is not a complete implementation; domain names are not immutable addresses.

Without notes, can you…

  • Explain the principle in your own words?
  • Rebuild the diagram and its connections?
  • Solve the exercise and justify the method?

Choosing a state saves it in this browser. This is your assessment, not a grade.