what order does the 3 tree traversal types traverse in
pre-order: root-left-right
in-order: left-root-right
post-order: left-right-root
queue
circular vs linear queue
circular: tail of queue joins to the head of queue when queue is full
linear: no such wraparound
circular: fixed size (won’t exceed memory capacity)
linear: grows/shrinks in size as items are enqueued/dequeued
circular: faster than linear queue of same size
stack
whats a balanced tree?
tree with minimum possible height (eg using median of data as the root node)
advantage of BST? (may be outdated)
(may be outdated)
- enables use of binary search on data structure that is guaranteed to remain sorted
- adding elements into BST has a time complexity of O(log n), vs append-and-sort operations for an array which hv time complexity of O(n log n) using merge sort
- mostly-sorted arrays are worst-case scenario for quick sort, resulting in O(n2) time complexity
disadvantages of BST
can i implement BST using hash table?
no.
BST iterates over vals (in sorted order) bc nodes fllw a strict sorting rule/arranged acc to specific rules
AND hash table cnnt bc it doesnt rec keys in order
purpose of traversing through linked list (with numbers & mathematical operations as node data)
to traverse through linked list, concatenating each node’s value to the next
linked list
static array > linked list (assume dynamic)
linked list > static array
how can queue & stack be implemented?
implemented using:
- array which wld use static allocation of memory
- linked list which wld use dynamic allocation of memory
how is deletion of root node done?
how is insertion of new_node into ordered linked list done?
^^more/less depends on how linked list is ordered –> ascending/descending