C949 Flashcards
Array
An ordered list where each item is directly by a positional index. A data structure that stores subitems. Primary search method, Binary.
Linked list
Stores ordered list of items in nodes. Each node stores data and has a pointer to the next node. Faster than an array.
Hash Table
Stores unordered items by mapping(or hashing) each item to a location in an array(or vector)
Chaining
Handles hash table collision by using a list for each bucket. Each list may store multiple items that map to the same bucket.
Bucket
Each element in a hash table
Hash Key
Value used to map an index
Modulo hash function
(num_keys/num_buckets)
Hash table searching
Supports fast search, insert and remove. O(1) linear search requires(N).
Max-Heap
A binary tree that maintains the property that a node’s key is greater than or equal to the node’s children key. The root is always the max key.
Heap Storage
Heaps are stores using Arrays. If represented by a tree the root node is always entry 0. Works with Tree based data structures.
Max-Heap Insert
An insert into a max-heap starts by inserting the node in the tree’s last level. Then swapping the node with it’s parent until no violation occurs.
Max-heap remove
Always removes the root. Each node is swapped until no violation occurs.
Percolating
The upward movement of a node in a heap.
Min-Heap
Like a max-heap, but a node’s key is less than or equal to it’s children’s keys.
Heap parent and child indices
Because heaps do not have a node structure nodes are referred to by index. Parent index for a node at index 12: ((12-1) // 2) = 5, child index for a node at index 6: 2* 6 + 2 = 14 **Double # and add 1, double # and add 2.
Priority Queues with Heaps
Both functions return the value in the root, but the Pop() function removes the value and the Peek function does not. Pop and Push worst case is 0(logN) and Peek, IsEmpty and GetLength is worst case O(1)
Array Based List
A list ADT implemented using an array. Allows for operations such as append, prepend, insert after, remove and search.
Linked List vs Array
If a program requires fast insertion a linked list is a better choice.
Abstract Data Type(ADT)
A data type described by a predefined user operation. Such as “insert data at rear” without indicating how each operation is implemented.
Array in Java
Generic class that supports different data types.
Tuple
A container with ordered elements.
Stack
An ADT with “Last in first out” rule. Pop and Peek cannot be used in empty list.
Stack and Queue in Python
Can be implemented using a class with a single linked list.
Queue
An ADT in which items are inserted at the end and removed from the front.(Linked List, Array, Vector)
Linked List
A linear data structure that consists of nodes that link to the next node.
Double Linked List
A data structure that can also include a reference to the head node. If no variable is assigned returns None or Null.