If a queue and a stack are both just a list inside, what actually makes them two different types?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
cells holds a list built the second way the video described — memory allocated here and there, wherever there was room. Each key is a memory address, and the value stored there is a two-item list: the element's value, and the address of the next element. The last cell's next address is None, and start holds the address of the first element.
Follow the chain from start and collect the values in list order into values, an ordinary Python list. The order the addresses happen to be written in cells is not the list's order.
(Hint: while, is not None, and the list method .append() are all useful here.)
Two possible internal layouts of the list class
Describe the contiguous block of memory layout and the scattered cells each holding a value plus the location of the next, and list the list operations usable under either.
Elevator and employee representations
Write the elevator as length, width, height, maximum capacity and current floor with behaviors such as changing floor and adding people, and the employee as first name, last name, birth date and salary.
Queue and stack sharing one representation
Record that both are a list of names, then trace first in first out by adding at the end and removing from the front, against first in last out removing from the end.
Bundling data together with behavior
State that a class packages the representation and the operations into one type, and record the guarantee that every object built from it carries the same structure and usage rules.