cs320 final quiz study

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/16

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

17 Terms

1
New cards

What is a requirement for topological sort?

Graph must be a DAG (Directed Acyclic Graph)

2
New cards

What makes a valid topological order?

All edges must go from earlier to later in the order

3
New cards

Which is better for sparse graphs: adjacency list or matrix?

Adjacency list

4
New cards

Why not use adjacency matrix for sparse graphs?

It uses O(V²) space which is wasteful

5
New cards

What makes a graph non-bipartite?

It contains an odd-length cycle

6
New cards

What does Dijkstra’s algorithm do?

Finds shortest path in weighted graphs

7
New cards

What data structure does Dijkstra use?

Priority Queue (Min-Heap)

8
New cards

What does Prim’s algorithm do?

Builds Minimum Spanning Tree starting from one vertex

9
New cards

What does Kruskal’s algorithm use?

Sorted edge list and Union-Find

10
New cards

BFS vs DFS: which guarantees shortest path?

BFS (in unweighted graphs)

11
New cards

BFS vs DFS: which uses a queue?

BFS uses a queue, DFS uses a stack or recursion

12
New cards

What is Counting Sort’s time complexity?

O(n + k)

13
New cards

Why might Counting Sort fail?

Input contains negative integers

14
New cards

How many edges in a tree with n vertices?

n - 1

15
New cards

What is the approximate sum of the Harmonic series?

ln(n) + 0.577

16
New cards

Expected number of rolls to get a 3 on a fair die?

6

17
New cards

How to get count of 3 from cumulative array [2, 2, 4, 6, 7, 8]?

4 - 2 = 2 (3 appears 2 times)