csnotes/370/past-midterms/m1.md
Medium Fries ea2aa8d2a6 yote
2019-03-15 01:26:26 -07:00

58 lines
1.9 KiB
Markdown

# Practice things
_just going through the practice midterm problems_
1. Identifying sorting algorithms based on progression(_conceptual_)
_bubble sort_: the bigger the value = the bigger the bubble
* compare two values from the start always, bubble up the bigger value
keep compmaring two adjacent values till you get to the end of the list
* kinda like gladiator m&m's
_insertion sort_: we have the left sublist which maintains a ordered state always
* we walk along the unsorted list and try to drop our current value into the currently sorted left-hand sublist.
* Key points:
left hand ordered sublist
_quick sort_: here we push things up to the top immediately where they are then sorted against the left hand sub-list
_heap sort_: make a giant heap(list) and just take the largest/smallest value and prepend/append to the """heap"""
__reponse__: insertion sort
Left side of progression is always sorted while the right isn't
Left side also get progressively larger
2. How you know if a graph is undirected given a matrix(_code_)
_empirically_: check the upper right half of the matrix and check if each coord pair is reflected across the main axis
1. Take a coords pair value(_say True_)
2. Flip the (x,y) so we have /x,y/
3. If the /x,y/ value is the same as (x,y) then those two nodes are bidrectional(i.e. undirected)
The _trick_ here is making sure we don't bother check the divisor axis or below by accident.
3. Binary tree lookup(_code_)
Recursion is the smollest way of doing this so just go with that.
4. Quick sort partition(_code_)
* Just splitting lists again
* Checking for partition results as well
5. Graph traversal(_code_)
DFS/BFS is fair game
List/matrix meme allowed so don't even bother with other trash
6. Emperical Graph Traversal(_conceptual_)
Time complexity of either dfs/bfs will be /v\*e/ or something like that
7. Topological sort(_code_)
big meme matrix/list allowed