csc445 quiz 3

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/40

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:31 AM on 3/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

41 Terms

1
New cards

What is Prim’s algorithm used for?

finding the minimum spanning tree (MST) in a graph

2
New cards

What is the time complexity of prim’s algorithm using an adjacency matrix?

O(V2)

3
New cards

What is the key idea behind Prim’s algorithm?

always select the edge with the minimum weight

4
New cards

In prim’s algorithm, what does the “key value” of a vertex represent?

the minimum weight edge connecting the vertex to the MST

5
New cards

Which of the following is true about prim’s algorithm?

it works on connected, undirected graphs

6
New cards

What is the first step in prim’s algorithm?

choose a arbitrary vertex to start the MST

7
New cards

What is the total weight of the MST in the following graph?

3 (2 + 1)

8
New cards

What type of algorithm is Kruskal’s algorithm?

greedy algorithm

9
New cards

What does Kruskal’s algorithm find?

minimum spanning tree (MST)

10
New cards

What is the first step in Kruskal’s algorithm?

sort all edges in non-decreasing order of weight

11
New cards

How many edges will be present in the MST of a connected graph with V vertices?

V-1

12
New cards

What is the main purpose of Dijkstra’s algorithm?

find the shortest path from a source to all vertices

13
New cards

 In Dijkstra’s algorithm, what is the initial distance assigned to all vertices except the source?

infinity

14
New cards

Dijkstra’s algorithm follows which type of approach?

greedy algorithm

15
New cards

Which real-world application uses Dijkstra’s algorithm?

finding the shortest path in Google maps

16
New cards

Which algorithm uses a greedy approach to find the shortest path in a graph?

Dijkstra’s algorithm

17
New cards

What is a key difference between a DP-based shortest-path algorithm and and a greedy-based one?

DP considers all possible paths before making a decision, while greedy makes locally optimal choices

18
New cards

The Knapsack problem follows which programming paradigm?

dynamic programming

19
New cards

What is the time complexity of the Knapsack problem using dynamic programming?

O(nW)

20
New cards

What is the main advantage of using dynamic programming for the Knapsack problem?

it always finds the optimal solution

21
New cards

Why does the greedy algorithm fail for the Knapsack problem?

it does not consider all possible item combinations 

22
New cards

What is the primary goal of huffman coding?

to reduce the size of data using variable-length codes

23
New cards

What is the key advantage of using Huffman coding over fixed-length codes like ASCII?

it uses fewer bits for frequent symbols

24
New cards

What is the time complexity of building a Huffman tree?

O(nlogn)

25
New cards

What is the first step in the Huffman coding algorithm?

calculate the frequency of each symbol

26
New cards

Which of the following is true about Huffman coding?

it is a greedy algorithm

27
New cards

What is the main principle behind Huffman coding?

assign shorter codes to more frequent symbols

28
New cards

Which of the following is NOT a step in the Huffman coding algorithm?

sort the symbols alphabetically

29
New cards

What is the minimum number of bits required to encode 6 unique symbols using Huffman coding?

3 bits

30
New cards

What is the size of the encoded message “ABAC” using the following Huffman codes: A = 0, B = 10, C = 11.

6 bits

31
New cards

What data structure is used in BFS?

Queue

32
New cards

What data structure is used in DFS?

Stack

33
New cards

DFS traversal follows which technique?

backtracking

34
New cards

Backtracking is mainly used for:

constraint satisfaction problems

35
New cards

What technique is used in backtracking?

recursion and backtracking

36
New cards

What algorithm is better suited for maze solving?

DFS with backtracking

37
New cards

 Backtracking is most useful when:

the problem has multiple constraints that need to be checked

38
New cards

What is the time complexity of the knapsack problem using dynamic programming?

O(N * W)

39
New cards

What is the worst-case time complexity of the knapsack problem using backtracking?

O(2n)

40
New cards

How does the backtracking approach solve the 0/1 Knapsack problem?

it generates all possible subsets and checks if they satisfy the weight constraint

41
New cards

 What is the main disadvantage of using backtracking for the knapsack problem?

it has a high time complexity in the worst case