CS 302 Midterm Questions and Answers with Verified Solutions |
Latest 2026 Update
Q: What is the reason for using an adjacency matrix instead of an adjacency list to
represent a graph?
Answer:
- 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
Q: what data structure is commonly used to implement a graph
Answer:
adjacency list
Q: What is the worst-case scenario for quick sort?
Answer:
O(n^2)
, CS 302 Midterm Questions and Answers with Verified Solutions |
Latest 2026 Update
Q: What algorithm is used to find the shortest path from x node to y node in a
weighted graph?
Answer:
Dijkstra's
Q: Which sorting algorithm always used a pivot to partition the data
Answer:
quick sort
Q: What is the Big O running time for merge sort
Answer:
n log n
Q: Which of the following is true about Dijkstra's algorithm
Answer:
Dijkstra's algorithm uses a priority
queue to select the next node with the smallest known distance.
, CS 302 Midterm Questions and Answers with Verified Solutions |
Latest 2026 Update
Q: Which sorting algorithm is theoretically the fastest
Answer:
merge/quick sort
Q: What does DFS stand for
Answer:
Depth First Search
Q: Which graph searching algorithm should not be implemented recursively
Answer:
BFS
Q: What does Dijkstra's algorithm do
Answer:
Find the shortest path between two vertices.
Latest 2026 Update
Q: What is the reason for using an adjacency matrix instead of an adjacency list to
represent a graph?
Answer:
- 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
Q: what data structure is commonly used to implement a graph
Answer:
adjacency list
Q: What is the worst-case scenario for quick sort?
Answer:
O(n^2)
, CS 302 Midterm Questions and Answers with Verified Solutions |
Latest 2026 Update
Q: What algorithm is used to find the shortest path from x node to y node in a
weighted graph?
Answer:
Dijkstra's
Q: Which sorting algorithm always used a pivot to partition the data
Answer:
quick sort
Q: What is the Big O running time for merge sort
Answer:
n log n
Q: Which of the following is true about Dijkstra's algorithm
Answer:
Dijkstra's algorithm uses a priority
queue to select the next node with the smallest known distance.
, CS 302 Midterm Questions and Answers with Verified Solutions |
Latest 2026 Update
Q: Which sorting algorithm is theoretically the fastest
Answer:
merge/quick sort
Q: What does DFS stand for
Answer:
Depth First Search
Q: Which graph searching algorithm should not be implemented recursively
Answer:
BFS
Q: What does Dijkstra's algorithm do
Answer:
Find the shortest path between two vertices.