Algorithms
Algorithms
Set-1
1. Suppose that, the time to service a page fault is 10 sec on average, memory access time
is 1 msec. If a page fault occurs for every 10,000 references, what is the average memory
access time?
• Explanation:
Average memory access time (EAT) is calculated using:
EAT=H⋅MAT+(1−H)⋅(P.F.T)\text{EAT} = H \cdot \text{MAT} + (1 - H) \cdot (\text{P.F.T})
Where:
2. If an instruction takes ‘n’ microseconds and page fault takes an additional ‘m’
microseconds. If the average page fault occurs for every ‘k’ instructions, then effective
access time is ____?
• Explanation:
Effective access time (EAT) incorporates the average time for instruction execution
and the average page fault penalty. For every kk instructions, a page fault occurs:
EAT=n+mk\text{EAT} = n + \frac{m}{k}.
3. What will be the minimum partition size required to execute the program with the
overlay tree?
• Explanation:
Analyze the overlay tree: the largest memory requirement occurs during the
execution of module M8, requiring a partition of 20K20K.
4. Dirty bit for a page table helps in:
• Explanation:
The dirty bit ensures that only modified pages are written to disk, reducing
unnecessary writes and page fault penalties.
• Explanation:
Requests larger than the largest available partition (400 KB) will be denied.
6. The address sequence generated during the execution of a program is given. With pure
demand paging and a single frame, the number of page faults is:
• Explanation:
Every address access generates a page fault except for the first repeated page.
Analyze the sequence for exact computation.
7. The sequence of memory requests using First Fit, Best Fit, and Worst Fit strategies is
analyzed. The outcome is:
• Explanation:
First Fit and Worst Fit can allocate memory for all requests, while Best Fit fails to
allocate the 50 KB
8. Consider a system with 128 MB physical memory and a 32-bit virtual address space. If
the page size is 2 KB, what is the approximate page table size?
• Correct Answer: (B) 4 MB
• Explanation:
Number of Pages=Virtual MemoryPage Size=232211=221
Page Table Size=221⋅Entry Size (4 bytes)=4 MB
• Explanation:
10. For a memory allocation using the best-fit strategy, the completion time for process P7
is:
• Explanation:
Analyze the allocation queue:
11. For the given memory allocation request sequence using the first-fit strategy, the
allocated blocks are:
• Explanation:
The first-fit strategy allocates the first available block that is large enough for the
request.
12. Considering the fragmentation properties of paging and segmentation, the correct
statements are:
• Correct Answer: (C) S1, S2
• Explanation:
• Explanation:
An inverted page table reduces redundancy and includes fields for uniquely
identifying the page (Page Number, Process ID) and links to other entries.
14. For the given paging system, the matching of attributes results in:
• Explanation:
15. Page faults for the reference sequence with 6 frames using LRU, FIFO, and Optimal
replacement are:
• Explanation:
All three algorithms result in equal page faults when the number of frames matches
the number of unique pages referenced.
16. For the given file system with i-node block specifications, the approximate maximum
file size is:
17. For the file sizes given with block sizes of 100B and 200B, the total blocks required are:
• Explanation:
Calculate the number of data blocks and bookkeeping blocks for each file, summing
them for both block sizes.
18. For a DMA transfer size of 10 KB, the processor time consumed is:
• Explanation:
Processor clocks used: 24002400. Total clocks in 1 second: 1.2×1091.2 10^9.
CPU time =24001.2×109×100=0.4%
19. The capacity of the disk and the number of bits required to address a sector uniquely
are:
• Explanation:
Disk capacity: 16×2×256×512×1 KB=4 GB16 2 256 512 1 Sectors:
16×2×256×512=22216 2 256 512 = 2^{22}.
20. For the given request set, the head changes direction after every request in SSTF:
• Correct Answer: (B) 0, 128, 160, 168, 171, 175, 191, 255
• Explanation:
SSTF minimizes the distance traveled, causing a direction change at each request.
21. What is the maximum cardinality of the request set such that the head changes its
direction for every request service?
• Correct Answer: (C) 12
• Explanation:
The total number of tracks =4096= 4096. The cardinality ensures the head changes
its direction on each request, considering edge cases.
22. For SSTF scheduling with the given cylinder sequence, the total seek time is:
• Explanation:
SSTF minimizes the distance by servicing the nearest request first. The total cylinder
movements =72= 72, and Seek Time=72×2 msec=144 msec
23. For FCFS scheduling with the given cylinder sequence, the total seek time is:
• Explanation:
FCFS services requests in order. Calculate the total track movements:
∣0−25∣+∣25−45∣+∣45−65∣+...=807|0 - 25| + |25 - 45| + |45 - 65| + ... = 807.
24. For FIFO replacement policy and the given reference string, the final content of
memory is:
• Explanation:
FIFO replaces the oldest page in memory. After processing the reference string, the
final memory state contains pages 6,1,26, 1, 2.
25. For the same reference string, the number of page faults using LRU is:
• Explanation:
LRU replaces the least recently used page. Count the page faults explicitly while
processing the reference string.
SET-2
To address your request for complete answers and detailed explanations for all 35 questions
in your uploaded PDF, I will format each question with its corresponding answer and a full
explanation. This will take significant space due to the detailed explanations for every
question. Let’s begin:
• Explanation:
• Explanation:
Master theorem requires aa (in T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n)) to be constant,
but here a=2na = 2n, which is variable.
• Explanation:
All operations (enqueue, dequeue, check, and delete) in a standard queue take
constant time.
• Explanation:
All given applications (Huffman coding, Priority Queues, Expression Trees, and Binary
Search Trees) use binary trees.
• Explanation:
The method involves visiting nodes level by level, typical of Level Order Traversal.
• Explanation:
The formula is Cn=1n+1(2nn)C_n = \frac{1}{n+1} \binom{2n}{n}. For n=8n = 8,
calculate C8=248C_8 = 248.
• Explanation:
After constructing the BST, the left subtree contains 11 nodes and the right subtree
contains 3.
• Explanation:
Summation considers node depths, where hh is the height of the tree.
• Explanation:
Total edges =(n2)= \binom{n}{2}. Solve n(n−1)2=29+7\frac{n(n-1)}{2} = 29 + 7,
yielding n=9n = 9.
• Explanation:
Dijkstra uses a priority queue, is greedy, and does not work with negative weights.
11. Minimum vertex cover for Km,nK_{m,n}:
• Explanation:
Covering all edges in a bipartite graph requires vertices equal to the smaller set size.
• Explanation:
Euler’s formula: V+R−E=2V + R - E = 2. Substitute V=7,E=10V = 7, E = 10.
• Explanation:
Both Merge Sort and Heap Sort consistently achieve O(nlogn)O(n \log n) in all
cases.
• Explanation:
Merge Sort, Quick Sort, and Binary Search all follow Divide-and-Conquer.
• Explanation:
Comparisons traverse each list completely, proportional to K+LK + L.
• Correct Answer: (D) h(n)∈O(g(n))h(n) \in O(g(n)) and g(n)∈O(f(n))g(n) \in O(f(n))
• Explanation:
Growth orders: nlogn≥log(n!)≥2lognn \log n \geq \log(n!) \geq 2^{\log n}.
• Explanation:
• Explanation:
Using Master Theorem, compare n0.52n^{0.52} with nlogban^{\log_b a}. Case 3
applies.
• Explanation:
Perform the operations as specified, tracking push and pop operations step by step.
• Explanation:
Follow the sequence, updating the stack after each push and pop.
• Correct Answer: (C) 77, 88, 42, 72, 81, 61, 60, 22, 80
• Explanation:
Reverse level order traversal processes levels bottom-to-top, left-to-right.
• Correct Answer: (C) Finding whether two binary trees are structurally identical.
• Explanation:
Recursive comparison checks the data and structure of both trees.
• Explanation:
Total BST arrangements with nn nodes = Cn⋅n!C_n \cdot n!, where Cn=1n+1(2nn)C_n
= \frac{1}{n+1} \binom{2n}{n}.
• Explanation:
For nn leaf nodes, a full binary tree has n−1n - 1 internal nodes with degree 2.
• Explanation:
To maximize height, each node except the last has a single child, leading to h=n−1h =
n - 1.
• Explanation:
With 7 children for one node and others having one child each, h=n−7h = n - 7.
27. Maximum nodes at height hh in a KK-ary tree:
• Explanation:
At height hh, each node can have KK children, leading to KhK^h nodes.
• Explanation:
Minimum: all nodes on a single path; Maximum: fully populated levels.
• Explanation:
Min-Heap property ensures the preorder traversal results in sorted order.
• Explanation:
Max-Heap property ensures the largest value is the root, followed by descending
order.
• Explanation:
Minimum nodes fill one branch; maximum nodes fill all branches.
• Explanation:
A valid partition must divide the array into two non-empty parts.
33. Sorting algorithm that is not stable:
• Explanation:
Quick Sort swaps elements without preserving relative order of equal elements.
• Explanation:
By analyzing traversal patterns, determine order correspondence.
• Explanation:
The tree structure matches the given traversal outputs in all orders.
SET-3
1. What is the worst-case time complexity of search operation on unordered and ordered
lists using Linear Search?
• Explanation:
o For both unordered and ordered lists, the worst-case requires nn checks,
leading to O(n)O(n).
• Explanation:
o Binary Search divides the problem size by 2 at each step and performs
constant additional work.
o Solving the recurrence T(n)=T(n/2)+O(1)T(n) = T(n/2) + O(1) yields
O(logn)O(\log n).
• Explanation:
o Median calculation requires sorting the numbers O(nlogn)O(n \log n), and
the median extraction takes O(1)O(1).
4. Time complexity to find a number appearing more than n/2n/2 times in an array:
• Explanation:
o Using a basic nested loop approach, count occurrences of each element and
identify if one appears >n/2> n/2.
5. Number of comparisons to find the smallest and largest keys in arrays of even and odd
sizes:
• Explanation:
• Explanation:
o Sequentially finding the largest, second largest, third largest, and fourth
largest elements requires 2n−52n - 5 comparisons.
7. Time complexity of Bellman-Ford Algorithm:
• Explanation:
8. Location of key '4' in the hash table with size 8 and hash function h(k)=(2k+1)mod 8h(k)
= (2k + 1) \mod 8:
• Explanation:
9. Length of the longest common subsequence for given strings str1 and str2
• Correct Answer: 8
• Explanation:
10. Regular expression for strings of the form amb2nc3pa^m b^{2n} c^{3p}, where
m,n,p≥2m, n, p \geq 2:
• Explanation:
o At least 2 'a's, 4 'b's, and 6 'c's are required. Subsequent counts are multiples
of 1, 2, and 3, respectively.
12. Bits required to store the string 'abfeg' using fixed-length encoding:
• Correct Answer: 15
• Explanation:
o Fixed-length encoding assigns equal bits to each character. With 3 bits per
character and 5 characters: 5×3=155 3 = 15.
• Explanation:
o Each vertex is visited (pushed) and then fully explored (popped), leading to
two accesses.
• Explanation:
15. Time complexity of Bellman-Ford Algorithm on a KK-regular graph (K≥3K \geq 3):
• Explanation:
• Correct Answer: (B) Use brute force; compare every element with others.
• Explanation:
• Explanation:
o Greedy picks the smallest edge weights at each step. Path S→A→E→G gives
2+5+9=162 + 5 + 9 = 16.
• Explanation:
• Explanation:
• Explanation:
• Explanation:
• Explanation:
o Analyze BFS order from adjacency lists. Option DD does not follow BFS rules.
23. Resultant hash table after inserting keys with linear probing:
o Hash Table:
0 1 2 3 4 5 6 7 8 9
97 31 22 42 61 64 46 71 58 83
• Explanation:
24. Bits required to store a file of 200 characters using fixed-length encoding:
• Explanation:
25. Bits required to store the file using variable-length encoding (Huffman coding):
• Explanation:
o Using Huffman coding:
▪ a=000(25×3)
Set-4
Question 1
Options:
(A) Only II
(B) Only III
(C) Only I, II
(D) I, II, and III
Question 2
Consider an array with ‘n’ values. To return the maximum sum of 3 values in an array, what
is the time complexity of performing this task?
Options:
(A) O(n)
(B) O(n² log n)
(C) O(n²)
(D) O(log n)
Answer: (C) O(n²)
Explanation: To compute the maximum sum of three values, we can iterate through the
array in O(n²) time by fixing two indices and finding the third. Sorting is not needed in this
approach.
Question 3
What is the length of the longest increasing subsequence of ‘6, 4, 5, 2, 7, 11, 8, 12, 13, 9,
10’?
Options:
(A) 2
(B) 3
(C) 4
(D) 5
Answer: (B) 3
Explanation: Two longest increasing subsequences are:
1. {2, 7, 11}
Question 4
Consider two sequences: S = gacggattag, and X = gatcggaatag. What is the length of the
longest common subsequence?
Options:
(A) 7
(B) 8
(C) 9
(D) 11
Answer: (C) 9
Explanation: The longest common subsequence (LCS) is "gacggatag," which has a length of
9.
Question 5
How does the key in a node compare to the keys of its children in:
I. Binary search tree
II. A Max HEAP
Options:
(A) I - P, II - Q
(B) I - P, II - P
(C) I - Q, II - P
(D) I - Q, II - Q
Here:
P. node.key > node.left.key, node.right.key
Q. node.left.key < node.key < node.right.key
Answer: (C) I - Q, II - P
Explanation: In a binary search tree (BST), keys in the left subtree are smaller, and those in
the right are larger than the node's key. In a Max Heap, the key in a parent node is greater
than or equal to its children.
Question 6
A hash table has 11 slots, uses the hash function h(k) = k mod 11, and resolves collisions
using separate chaining. What is the minimum chain length after inserting the elements 3,
43, 8, 11, 14, 25?
Options:
(A) 0
(B) 1
(C) 2
(D) 3
Answer: (A) 0
Explanation: The hash values are:
3 mod 11 = 3
43 mod 11 = 10
8 mod 11 = 8
11 mod 11 = 0
14 mod 11 = 3
25 mod 11 = 3
The slots with hash values 1, 2, 4, 5, 6, 7, and 9 are empty, hence the minimum chain length
is 0.
Question 7
Which priority queue implementation with N elements allows for new entries to be
inserted in O(1) time?
Options:
(A) Sorted array
(B) MAX HEAP
(C) MIN HEAP
(D) Unsorted array
Question 8
In order to search for an element in a dynamic set, which of the following techniques is
the asymptotically most time-efficient in the worst case for the search operation?
Options:
(A) Store elements in an unsorted array and apply linear search
(B) Store elements in a hash table and use hashing
(C) Store elements in a sorted array and apply binary search
(D) All the above
Question 9
Which of the following problems has solutions (algorithms) that run in θ(n) time in the
worst case?
Options:
(A) Finding the median of ‘n’ integers
(B) Finding the sum of ‘n’ integers
(C) Finding the largest of ‘n’ integers
(D) All the above
Options:
(A) I only
(B) I and II
(C) II and III
(D) I, II, and III
Question 11
Let ‘OPT’ be an optimal solution and ‘x’ the solution we found. If OPT equals x then we are
done; otherwise, we can find another optimal solution that ‘agrees more with x’. Which of
the following algorithms achieves ‘OPT = x’ in the first attempt?
Options:
(A) Fractional knapsack
(B) Travelling salesman problem
(C) Kruskal’s algorithm
(D) None of the above
Question 12
Options:
(A) I–P, II–P, III–P, IV–Q
(B) I–P, II–P, III–Q, IV–Q
(C) I–Q, II–Q, III–P, IV–P
(D) I–Q, II–P, III–P, IV–Q
Question 13
The distance matrix of a graph with vertices A, B, C, and D is given. What is the shortest
path from B to D?
Options:
(A) BC and CD
(B) BD
(C) AB and CD
(D) There is no shortest path
Question 14
Options:
(A) I–P, II–R, III–Q, IV–Q
(B) I–P, II–R, III–Q, IV–S
(C) I–R, II–P, III–Q, IV–Q
(D) I–R, II–P, III–Q, IV–S
Question 15
Given a set of objects with (Weight, Profit) pairs and a knapsack of limited weight capacity
(M = 9), find the subset of objects that maximizes total profit using the 0/1 knapsack
approach:
Options:
(A) 5
(B) 6
(C) 21
(D) 7
Answer: (B) 6
Explanation: Select objects (3, 2) and (6, 4), which fit within the weight capacity of 9 and
maximize profit to 6.
Question 16
Options:
(A) 5×1,1×4,4×6,6×35 \times 1, 1 \times 4, 4 \times 6, 6 \times 3
(B) 4×3,3×5,5×6,6×14 \times 3, 3 \times 5, 5 \times 6, 6 \times 1
(C) 5×1,1×4,4×3,3×65 \times 1, 1 \times 4, 4 \times 3, 3 \times 6
(D) 1×4,4×3,3×5,5×61 \times 4, 4 \times 3, 3 \times 5, 5 \times 6
Question 17
Suppose symbols a, b, c, d, e occur with given frequencies. What is the Huffman encoding
of the alphabets a, b, and c?
Options:
(A) 1101, 111, 1101
(B) 1100, 1101, 111
(C) 1100, 10, 0
(D) 1101, 1100, 111
Question 18
What is the maximal sum of a subset such that no three consecutive numbers are selected
from the sequence: \n‘7, 5, 6, 3, 8, 12, 9, 13, 14, 10, 11’?
Options:
(A) 66
(B) 68
(C) 69
(D) 72
Answer: (C) 69
Explanation: Using a dynamic programming approach, the subset maximizing the sum
without selecting three consecutive numbers is determined.
Question 19
Consider the coin change problem with coin values {1, 5, 6}. Does the greedy algorithm
always find an optimal solution?
Options:
(A) No, for even numbers
(B) Yes, for odd numbers
(C) Yes, for even numbers
(D) No
Answer: (D) No
Explanation: The greedy algorithm does not guarantee an optimal solution in all cases. For
example, for value 10, the optimal solution is {5, 5}, but greedy chooses {6, 1, 1, 1, 1}.
Question 20
If a data structure supports an operation ‘foo’ such that a sequence of ‘n’ foo operations
takes O(nlogn)O(n \log n) time in the worst case, then the amortized time of a single
‘foo’ operation is:
Options:
(A) O(n)O(n)
(B) O(logn)O(\log n)
(C) O(logn)O(\log n)
(D) O(n)O(n)
Question 21
Which of the following is CORRECT about computing the median and shortest paths in
graphs?
Options:
(A) I-TRUE, II-FALSE
(B) I-TRUE, II-TRUE
(C) I-FALSE, II-TRUE
(D) I-FALSE, II-FALSE
Question 22
Options:
(A) Quick sort
(B) Selection sort
(C) Insertion sort
(D) Bubble sort
Answer: (C) Insertion sort
Explanation: The algorithm iteratively places the current element in its correct position, as
seen in the steps.
Question 23
Options:
(A) Selection sort
(B) Heap sort
(C) Bubble sort
(D) Radix sort
Set-5
Answer: (C)
Explanation: A tree is a connected, acyclic graph. If there is any cycle, the graph ceases to be
a tree. The graph in option (C) contains a cycle, so it is not a tree.
Answer: (A)
Explanation: For a tree with nn vertices, the number of edges is n−1n - 1. Given 57 edges,
the number of vertices is 5858.
Question 4: How many spanning trees does the given graph contain (assuming all edges
have the same weight)?
Answer: (B)
Explanation: The number of spanning trees for the given graph is 33. The structure of the
graph and its adjacency matrix dictate this result.
Question 5: Suppose we have a graph where each edge value appears at most twice. What
is the maximum number of minimum spanning trees?
Answer: (C)
Explanation: At most 4 minimum spanning trees can exist when edge values appear at most
twice.
Question 6: If we run Dijkstra's algorithm starting from ‘S’ to find the shortest path to ‘T,’
which of the following is TRUE?
1. Dijkstra’s algorithm returns the shortest path with minimum total weight.
2. Dijkstra’s algorithm returns the shortest path with the minimum number of edges.
Answer: (A)
Explanation: Dijkstra's algorithm minimizes total weight, not the number of edges.
Hence, statement 1 is true, and statement 2 is false.
Question 7: Why use Bellman-Ford for finding shortest paths instead of Dijkstra’s
algorithm?
1. Bellman-Ford is faster.
1. BFS on a tree with equal weights finds the minimum distance from the root to any
node.
Question 9: Consider the set of keys {1, 4, 5, 10, 16, 17, 21}. Construct a binary search tree
with height ‘2.’ Which values appear at internal nodes?
Answer: (B)
Explanation: For height 2, the tree is constructed as follows:
• Root: 10
Question 10: Consider the set of keys {2, 5, 6, 11, 17, 18, 22}. Draw a binary search tree
with height ‘6.’ What will the child node values be?
Answer: (C)
Explanation: Either 22 or 2222 can serve as a child node depending on the specific
arrangement of the tree.
Question 11: Identify the correct strongly connected components in the graph:
Answer: (C)
Explanation: The graph has five strongly connected components: a,b,c,d,e,f,g{a, b, c}, {d}, {e},
{f}, {g}.
Question 12: Why can't the bold edges in the graph form a spanning tree?
Answer: (A)
Explanation: The bold edges are not connected, so they cannot form a spanning tree.
Question 13: Consider the given statements:
3. The sorted edges algorithm for the traveling salesman problem always gives the
optimal result.
Answer: (D)
Explanation: Only statement 2 is true. The other two are incorrect.
Question 14: How many rotations are required to balance the AVL tree after inserting 12?
Answer: (B)
Explanation: One left rotation is required to balance the tree after inserting 12.
Question 15: What is the order of insertion into an AVL tree to avoid single rotations?
Answer: (A)
Explanation: The order 4,2,6,1,3,5,74, 2, 6, 1, 3, 5, 7 avoids the need for single rotations.
Question 16: For the given tree with MAX HEAP property applied, what is the best action
for node 6?
Answer: (C)
Explanation: Compare 66 with its children 1818 and 1515, and then swap with the larger
child if required.
Question 17: Consider the following statements about Depth First Search:
2. DFS on a directed graph with nn vertices and at least nn edges is guaranteed to find a
back edge.
Answer: (A)
Explanation: Only statement 1 is true. Statement 2 is false because DFS may not
always find a back edge.
Question 18: What happens if we add 6 to the weight of every edge in a graph?
Answer: (B)
Explanation: Adding 6 to every edge increases the total weight by 6(∣V∣−1)6(|V| - 1), where
∣V∣|V| is the number of vertices.
Answer: (A)
Explanation: In BACEDFGHBACEDFGH, EE appears before DD, which violates the order
constraint.
Question 20: What is the time complexity to print all the keys of a binary search tree in
sorted order?
Answer: (B)
Explanation: Using in-order traversal, the complexity is O(n)O(n).
Question 21: Which tasks are not completed based on their deadlines and profits?
Tasks:
T1 2 6
T2 1 4
T3 3 3
T4 2 7
T5 3 2
T6 1 8
Answer: (C)
Explanation: Based on the maximum profit scheduling, tasks T1,T2,T5T1, T2, T5 are not
completed.
Question 22: What sorting algorithm does the given code implement?
Answer: (B)
Explanation: The code implements insertion sort, as it removes elements from the input
array and inserts them into the correct position in the sorted portion.
Question 23: What is the best-case time complexity of the insertion sort algorithm in
Question 22?
Answer: (C)
Explanation: The best case occurs when the array is already sorted, and the time complexity
is O(n)O(n).
Question 24: What is the acyclic component graph of the given directed graph?
Answer: (D)
Explanation: The strongly connected components are identified as {a,b,e}\{a, b, e\}, {f,g}\{f,
g\}, {c,d}and {h}The resulting acyclic component graph is shown as abe,cd,fg,habe, cd, fg, h.
Question 25: In the given undirected graph, which node has the highest degree?
Answer: (B)
Explanation: Node xx has the highest degree of 4, as it connects to the maximum number of
other nodes.
Question 26: What is the relationship between the number of vertices and edges in a
spanning tree?
Answer: n−1n - 1
Explanation: For a graph with nn vertices, a spanning tree contains n−1n - 1 edges.
Question 27: What does the Bellman-Ford algorithm ensure in graphs with negative
weights?
Answer: It guarantees finding the shortest path, unlike Dijkstra's algorithm, which does not
work with negative weights.
Question 28: How does Kruskal’s algorithm choose edges for a minimum spanning tree?
Answer: DFS does not account for edge weights, so it may not find the shortest path in
weighted graphs.
Question 30: How does the greedy algorithm solve the fractional knapsack problem?
Answer: By choosing items with the highest value-to-weight ratio until the knapsack is filled,
ensuring an optimal solution.
Question 31: What is the key difference between BFS and DFS in terms of traversal?
Answer: BFS explores all neighbors at the current depth before moving deeper, while DFS
goes as deep as possible along a branch before backtracking.
Question 32: What is the time complexity of Dijkstra's algorithm using a priority queue?
Answer: A tree is an acyclic connected graph, whereas a graph can have cycles and may not
be connected.
Answer: To connect all vertices in a graph with the minimum total edge weight without
forming cycles.
Question 35: What does the term "back edge" signify in DFS?
Answer: A back edge points from a node to one of its ancestors in the DFS tree, indicating a
cycle in the graph.