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

1.9 KiB

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

  1. 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.

  1. Binary tree lookup(code)

Recursion is the smollest way of doing this so just go with that.

  1. Quick sort partition(code)

    • Just splitting lists again
    • Checking for partition results as well
  2. Graph traversal(code)

DFS/BFS is fair game List/matrix meme allowed so don't even bother with other trash

  1. Emperical Graph Traversal(conceptual)

Time complexity of either dfs/bfs will be /v*e/ or something like that

  1. Topological sort(code)

big meme matrix/list allowed