Data Structures 3 Flashcards
Array: access, search, insert, delete
Access: O(1)Search: O(n)Insert: O(n)Delete: O(n)
Array: memory
Memory: O(n)
Array: advantage, disadvantage
Advantage: quick insert, quick access if index is knownDisadvantage: slow search, slow delete, fixed size
Doubly Linked List: access, search, insert, delete
Access: O(n)Search: O(n)Insert: O(1)Delete: O(1)
Doubly Linked List: memory
Memory: O(3n) (LL: O 2n)
Doubly Linked List: advantage, disadvantage
Advantage: quick insert, quick deleteDisadvantage: slow search
Binary Tree: advantage, disadvantage
Advantage: quick search, delete, insertDisadvantage: complex deletion
of elements in a binary tree
2^(# of rows)
Heap: advantage, disadvantage
Advantage: quick insert, quick delete, access to largest itemDisadvantage: slow access to all other items
Heap Binary Tree: access, search, insert, delete,
Access: O(1)Search: O(n)Insert: O (lg n) Best case: sorted arrayDelete: O (lg n)
Heap Binary Tree: max-heapify, build-max-heap, heap-sort
Max-heapify: O(n)Build-max-heap: O(n)Heap-sort: O(n lgn)
Heap Binary Tree: memory
Memory: O(n)
Heap Binary Tree: definition
A binary tree with two additional constraints:Shape - complete treeHeap property - max/min heap
Heap Binary Tree: advantage, disadvantage
Advantage: fast access, quick insert and deleteDisadvantage: slow search, efficient memory if full
Heap-sort: definition
Array size doesn’t change, but heap size doesTake off bottom, reshuffle, repeatLess efficient than max-heapify because it sorts from the top instead of the bottom
Binary Search Tree: search, insert, delete
Search: O(h) / balanced, O(lg n)Insert: O(h) / balanced, O(lg n)Delete: O(h) / balanced, O(lg n)
Binary Search Tree: max, min, successor, predecessor
Max: O(h)Min: O(h)Successor: O(h)Predecessor: O(h)
Binary Search Tree: property
value[left[x]] <= value[x]value[right[x] >= value[x]
Binary Search Tree: memory
Memory: O(n)
Binary Search Tree: advantage, disadvantage
Advantage: quick search, quick insert and deleteDisadvantage: slower than hash table
Height of binary tree
number of edges on the longest downward path between the root and a leaflog(n) - complete binary tree
Node height
number of edges on the longest downward path between node and a leaf
Node depth
number of edges on the longest downward path between node and the root
Tries: advantage, disadvantage, memory
Advantage: faster search than a hash table, no collisions, no hash function needed, quick insert and deleteDisadvantage: can take up more space than a hash tableMemory: A LOT - need empty memory for every possibility
Tries: definition
Key-value storage; a kind of treeKey -not- stored in node, value stored in nodeNode variables : Boolean isNode, String value, array Edges
Heap Priority Queue: insert, max, extract max, increase value
Heap-insert: O(lg n)Heap-maximum: O(1)Heap-extract-max: O(lg n)Heap-increase-value: O(lg n)