Send a link to your students to track their progress
33 Terms
1
New cards
Bag
Collection that allows duplicates and has no order, unlike a set
2
New cards
Bag vs set
A set rejects duplicates, a bag allows them
3
New cards
Bag vs list
A list has order and index positions, a bag does not
4
New cards
Heap left child index
2 times i plus 1, where i is the parent index
5
New cards
Heap right child index
2 times i plus 2
6
New cards
Heap parent index
i minus 1, divided by 2 using integer division
7
New cards
Heap insertion process
Add the new element at the end of the array, then repeatedly swap it with its parent until the heap property is restored, called bubble up or sift up
8
New cards
Heap deletion process
Remove the root, move the last element into the root position, then repeatedly swap it with the smaller or larger child until the heap property is restored, called bubble down or sift down
9
New cards
Why the last heap element replaces the root
Keeps the heap a complete binary tree with no gaps
10
New cards
BST property
Every node's left subtree contains smaller values, right subtree contains larger values
11
New cards
BST search
Go left if the target is smaller, right if larger, repeat until found or a null is reached
12
New cards
BST insertion
Search for where the value would be, then insert it there as a new leaf
13
New cards
BST deletion with two children
Replace the node's value with its in order successor, the smallest value in the right subtree, then delete that successor
14
New cards
In order traversal
Left, node, right, visits nodes in sorted order
15
New cards
Pre order traversal
Node, left, right, useful for copying a tree
16
New cards
Post order traversal
Left, right, node, useful for deleting a tree
17
New cards
BST Big O balanced
O(log N) for search, insert, and delete
18
New cards
BST Big O worst case
O(N), happens when the tree is degenerate like a linked list
19
New cards
Stack push
Adds an item to the top of the stack
20
New cards
Stack pop
Removes and returns the item from the top of the stack
21
New cards
Queue enqueue
Adds an item to the back of the queue
22
New cards
Queue dequeue
Removes and returns the item from the front of the queue
23
New cards
Singly linked list node
Stores data and a reference to the next node only
24
New cards
Doubly linked list node
Stores data plus references to both the next and previous nodes
25
New cards
Linked list access Big O
O(N), no random access like an array
26
New cards
Linked list insertion at a known node
O(1), just pointer updates
27
New cards
Array vs linked list tradeoff
Arrays give fast random access but slow insertion and deletion, linked lists give fast insertion and deletion at a known point but slow access
28
New cards
Set union
All elements from both sets, no duplicates
29
New cards
Set intersection
Only elements that exist in both sets
30
New cards
Set difference
Elements in this set but not in the other set
31
New cards
Set filter
New set containing only elements that satisfy a condition
32
New cards
Set map
New set formed by applying a function to every element