Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 12 pages
Exam (elaborations)

CS 302 Midterm Exam QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED| GUARANTEED SUCCESS

Document preview thumbnail
Preview 2 out of 12 pages

CS 302 Midterm Exam QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED| GUARANTEED SUCCESS

Content preview

CS 302 Midterm Exam QUESTIONS WITH CORRECT ANSWERS 100% VERIFIED|
GUARANTEED SUCCESS


What is the reason for using an adjacency matrix instead of an adjacency list to represent a
graph? - allow you to check if an edge exists between two vertices in O(1) time

- if graph is dense (a lot of edges) then a matrix is more space efficient



what data structure is commonly used to implement a graph adjacency list



What is the worst-case scenario for quick sort? O(n^2)



What algorithm is used to find the shortest path from x node to y node in a weighted graph?
Dijkstra's



Which sorting algorithm always used a pivot to partition the data quick sort



What is the Big O running time for merge sort n log n



Which of the following is true about Dijkstra's algorithm Dijkstra's algorithm uses a priority
queue to select the next node with the smallest known distance.



Which sorting algorithm is theoretically the fastest merge/quick sort



What does DFS stand for Depth First Search



Which graph searching algorithm should not be implemented recursively BFS

, What does Dijkstra's algorithm do Find the shortest path between two vertices.



For disjoint sets, which of the following is NOT a way to construct a union union by width



Name a sorting algorithm that is stable bubble, insertion, merge



Which sorting algorithm does not divide and conquer bogo/monkey sort



What container does BFS use queue



What container does DFS use stack



In a disjoint set, what is the difference between union by height and union by rank with path
compression union by height:

the height of the root is the number of elements in the longest path in the set.



union by rank:

equivalent to union by height but path compression is performed on find operations. each time
you call find(), the links field of all elements on the path to the root are updated so they all
equal the root



Which sorting algorithm involves selecting a random partition and sorting the elements on each
side of the partition quicksort



What is a disjoint set and how is union used with them a disjoint set partitions elements into
different sets. No item belongs to more than one set, but all items belong to some set. The

Document information

Uploaded on
May 12, 2025
Number of pages
12
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$11.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
DrJon
3.8
(160)
Sold
585
Followers
188
Items
20922
Last sold
5 days ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions