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.
- 01Values
- 02Organisation
- 03Allowed operations
- 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
- Specify the contract
Define inputs, types, outputs and forbidden cases. State whether a search algorithm requires sorted data.
- Trace a small example
Tabulate variables, tested conditions and actions using a small hand-checkable example.
- Test boundaries
Consider empty inputs, one item, duplicates, missing values and numeric limits where relevant. Define the output or explain rejection.
- 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.
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
- B was added last.
- B exits first: LIFO.
- An ordinary queue would release A first: FIFO.
Which step did you miss? Retry without help, then explain why the method works.
Distinguish URL, domain name and IP address.
A hint to get started
One describes a resource access location.
Step-by-step solution
- A URL identifies a resource and protocol.
- A domain is a name resolved notably through DNS.
- 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.
Why can a message be divided into packets?
A hint to get started
Networks transport smaller units.
Step-by-step solution
- Data is segmented for transmission.
- Protocol mechanisms can manage ordering and retransmission.
- 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.