Midterm Review Flashcards
Arrays
Linear lists which use contiguous memory and are usually homogenous.
Operations are limited to its structure.
Can be used to implement different types of lists.
List Operations
Insert, Delete, Update, Read
Search, Reorder, Resize, Rules
Stacks
Structures that use the LIFO approach. Elements can only be pushed onto or popped from the top of the stack.
Peek operation may give access to top without modifying the stack.
Overflow
When a stack is full and does not contain enough space to accept new values.
Stack Operations
Push() - add to top
Pop() - remove from top
Peek() - look at top
isFull() - check for overflow
Singly Linked List
Can be traversed in one direction (head to tail).
Each node contains a pointer to the next node (null if none).
Linked List Operations
addNode() - add new after current
deleteNode() - delete current (none if null)
Queue
A list that grows by adding to its tail and shrinks by removing from its head and is a FIFO structure which operates similar to stacks.
Queue Operations
Clear - clear queue Enqueue - add to tail Dequeue - remove from head Peek - return first element without removing isEmpty - check if anything in queue
Insertion Sort
Consider first 2 and swap if needed.
For every following element, place in proper position.
Bubble Sort
Swap adjacent elements (if wrong order) and reduce inspected elements by 1 for each pass.
Selection Sort
Find lowest and place in front. Find next and place next to front, etc.
Merge Sort
- Divide: if input small enough use straightforward method, otherwise divide into subsets
- Recur: recursively solve subproblems in subsets
- Conquer: take solutions and merge into full solution
Quick Sort
- Divide: select a specific element to be pivot and store in 3 sequences - less than, equal to, and greater than (LEG)
- Recur: recursively sort L and G
- Conquer: order by inserting L then E then G
Specialization
A specific version of a templated function AKA generated function