(a) Analyze the time and space complexity of the following code snippet: for i in N: for j in M: print (i,j) (b) What are the required properties to…

(a) Analyze the time and space complexity of the following code snippet:

for i in N:
    for j in M:
        print (i,j)

(b) What are the required properties to apply dynamic programming? Consider you are given a set of coins of different denominations and an amount in integer. Write an algorithm using dynamic programming that calculates how many coins can make the given amount? If you can not make the amount, the algorithm outputs -1. for example - Coins = {1, 2, 5}, Amount = 11, Output = 3, Explanation: Coin 5+5+1 can make 11.

(c) Find the minimum spanning tree of the following graph using Prim's algorithm:

From the BCS Technical Cadre (CSE) October 2025 – 49th BCS Written (Special) (BPSC) exam, question 100 of 123.

More from this paper