Data Structures and Data Manipulation Flashcards
Data Structure
Is a group of related data items.
Static Data Structure
Are those where the size is fixed when the structure is created (the size cannot change during processing).
Dynamic Data Structure
Are those where the size of the data structure changes as data is added and removed.
Static vs Dynamic
Static - amount of storage required known so easier to program. Dynamic - amount of storage not known more complex code.
Stack
LIFO. A stack is a list in which insertion and deletion take place at the same end (TOP). One pointer – top.
Stack - uses
Storing return addresses (during subroutine calls), Passing parameters, Storing contents of registers while processing interrupt
Reversing the order of a set of data.
Stack overflow/underflow
Overflow error when try to push an item onto a full stack and Underflow when try to pop item off empty stack.
Stack – insert algorithm
Push item onto stack
If Stack is full Then Error and stop Else Increment StackPointer. Add data item at position StackPointer End if.
Stack – retrieve/delete alg
Pop item off stack
If Stack is empty Then Error and stop Else Return the data item at position StackPointer. Decrement StackPointer End if.
Queue
FIFO. A queue is a list. Insertion is done at one end, while deletion is performed at the other end. Front and back pointers.
Q overflow/underflow
Overflow error when try to enqueue an item onto a full queue and Underflow when try to dequeue item off empty queue.
Queue - uses
Jobs waiting for a printer in a spool queue, Job queue batch processing system, Keyboard buffer.
Shuffle queue
Front index always fixed (items shuffle up to front when an item is dequeued.
Circular queue
When enqueuing next index moves forward. When dequeuing the front index moves forward. Circular as next pointer wraps to beginning once last index is reached.
Queue – insert algorithm / add item to circular queue
(Enqueue). If Queue is full Then Error and stop Else Add data item at position NextPointer. Increment NextPointer. If NextPointer > MaxIndex Then Assign the value of 1 to NextPointer End if.