ExamPreparation | QuizTime | LearningTools | Education | StudentSupport
CS 6515 Final Questions and Correct
Answers the Latest Update
Quick Sort Runtime
✓ O(n^2)
✓ O(nlogn) with median of medians
Merge Sort Runtime
✓ O(nlogn)
Quick Select Runtime
✓ O(n^2)
✓ O(n) with median of medians (Fast select)
Dijkstra's algorithm
✓ An algorithm for finding the shortest paths between nodes in a weighted graph. For
a given source node in the graph, the algorithm finds the shortest path between
that node and every other. It can also be used for finding the shortest paths from a
single node to a single destination node by stopping the algorithm once the shortest
path to the destination node has been determined. Its time complexity is O(E +
VlogV), where E is the number of edges and V is the number of vertices.
✓
✓ - uses min-heap (prio-queue)
✓ - O((n+m) log n)
✓ - O(m log n) - strongly connected
✓
✓ - prev(u)
Smart Grades Latest update
1
, Examify | OnlineExams | TestPrep | StudyResources | AcademicSuccess |
ExamPreparation | QuizTime | LearningTools | Education | StudentSupport
Kruskal's Algorithm
✓ (Minimum Spanning Trees, O(mlogn) with a union find, which is fast for sparse
graphs) Builds up connected components of vertices, repeatedly considering the
lightest remaining edge and tests whether its two endpoints lie within the same
connected component. If not, insert the edge and merge the two components into
one.
✓
✓ input: undirected G=(V,E) with weights w(e)
✓ 1. sort E by incr weight (O(mlogn))
✓ 2. set X = empty set
✓ 3. for e = (v, w) exists E (go through in order)
✓ if x Ue doesnt have a cycle
✓ then: X = X U e(checks if v and w are in different components: O(log n))
✓ 4. return X
✓
✓ returns MST defined by edges X
Prim's Algorithm for MST
✓ Start with a node and add edge with the lowest weight. Then from the current
existing nodes add the next smallest edge that exists going out from all the existing
nodes. Do this until all vertices are connected.
✓
✓ - min spanning tree defined by array prev[]
✓ - O(m log n)
Ford-Fulkerson Algorithm
✓ Runtime: O(mC)Input: Graph with integer edge weights. (Note: Does not work with
Infinity)Output: max flow f*
✓
✓ 1. set f_e = 0 for all edges
Smart Grades Latest update
1