Consider the following undirected graph represented as an adjacency list:
1: [2, 3], 2: [1, 4, 5], 3: [1,6], 4: [2], 5: [2,6], 6: [3,5]
If the BFS is used to find the shortest path from node 1 to node 6, trace the process and calculate
the length of the path. At each step, explain how the algorithm determines the next node to visit
and maintain its queue structure.
In the 0/1 Knapsack Problem, how does dynamic programming ensure that the solution
respects the problem's constraints? Solve the problem for the following data using a DP
table and explain the choice-making process:
Items: 1, 2, 3
Weights: 2, 3, 4
Values: 3, 4, 5
Knapsack Capacity: 5