Graded Assignment - (Sep 2025 - CT - Qualifier)

The due date for submitting this assignment has passed. Due on 2025-12-03, 23:59 IST. You may submit any number of times before the due date. The final submission will be considered for grading.

Last Submitted: You have last submitted on: 2025-12-03, 13:00 IST

Note: ++++++++++++++++++++++++++++++++++


Question 1

If matrixPh[i] [j] = 1, then

  • i scored at most 10 and at least 20 more marks in Physics than j
  • i scored at least 10 and at most 20 more marks in Physics than j
  • j scored at least 10 and at most 20 more marks in Physics than i
  • j scored at most 10 and at least 20 more marks in Physics than i

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • i scored at least 10 and at most 20 more marks in Physics than j

Question 2

Choose the correct statement based on above pseudocode.

  • For all i, j with i j, matrixPh[i][j] + matrixPh[j][i] = 1
  • For all i, j with i j, if matrixPh[i][j] = 1 then matrixPh[j][i] = 0
  • For all i, j with i j, if matrixPh[i][j] = 0 then matrixPh[j][i] = 1
  • For all i, j with i j, if matrixPh[i][j] = 1 then matrixPh[j][i] = 1
  • For all i, j with i j, if matrixPh[i][j] = 0 then matrixPh[j][i] = 0

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • For all i, j with i j, if matrixPh[i][j] = 1 then matrixPh[j][i] = 0

Question 3

Consider the dictionary D, and the matrices matrixPh, matrixCh and matrixMa computed in the previous question. The following pseudocode generate the adjacency matrix matrixHelp.

xxxxxxxxxx

1

n = length(keys(D))

2

matrixHelp = createMatrix(n, n)

3

    foreach i in rows(matrixHelp){

4

        foreach j in columns(matrixHelp){

5

            matrixHelp[i][j] = matrixCh[i][j] + matrixPh[i][j] + matrixMa[i][j]

6

        }

7

}

Let i and j be indices of two students. Choose the correct statement(s) from the given options. It is a Multiple Select Question (MSQ)

  • 0 ⇐ matrixHelp[i][j] ⇐ 3
  • matrixHelp[i][j] + matrixHelp[j][i] ⇐ 3
  • matrixHelp[i][j] matrixHelp[j][i]
  • if matrixHelp[i][j] = 0, then matrixHelp[j][i] = 3
  • if matrixHelp[i][j] = 3, then matrixHelp[j][i] = 0

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • 0 ⇐ matrixHelp[i][j] ⇐ 3
  • matrixHelp[i][j] + matrixHelp[j][i] ⇐ 3
  • if matrixHelp[i][j] = 3, then matrixHelp[j][i] = 0

Question 4

At the end of the following pseudocode, A captures the number of distinct pairs of students who can help each other in at least one subject, and B captures the number of distinct pairs of students where one can help the other in all subjects. Choose the correct code fragment to complete the pseudocode.

xxxxxxxxxx

1

A = 0, B = 0

2

foreach i in rows(matrixHelp){

3

    foreach j in columns(matrixHelp){

4

        ***********************

5

         *** Fill the code ***

6

        ***********************

7

    }

8

}

9

​
  • xxxxxxxxxx 1 if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ 2 A = A + 1 3 } 4 if(matrixHelp[i][j] == 3){ 5 B = B + 1 6 }
  • xxxxxxxxxx 1 if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ 2 A = A + 1 3 } 4 if(matrixHelp[i][j] > 2){ 5 B = B + 1 6 }
  • xxxxxxxxxx 1 if(i < j){ 2 if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ 3 A = A + 1 4 } 5 if(matrixHelp[i][j] > 2){ 6 B = B + 1 7 } 8 }
  • xxxxxxxxxx 1 if(i < j){ 2 if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ 3 A = A + 1 4 } 5 } 6 if(matrixHelp[i][j] > 2){ 7 B = B + 1 8 }

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • if(i < j){ if(matrixHelp[i][j] > 0 and matrixHelp[j][i] > 0){ A = A + 1 } } if(matrixHelp[i][j] > 2){ B = B + 1 }

Question 5

The following pseudocode generates a graph G from books. Each node corresponds to an author. There is an edge between two different authors i and j if they have co-authored a book, and the edge is labeled with the number of books they have co-authored. Choose the correct code fragment to complete the following pseudocode.

xxxxxxxxxx

1

matrix = createMatrix(n, n)

2

foreach i in keys(books){

3

    foreach j in books[i]{

4

        foreach k in books[i]{

5

           ***********************

6

            *** Fill the code ***

7

           ***********************        

8

        }

9

    }

10

}
  • xxxxxxxxxx 1 matrix[j][k] = matrix[j][k] + 1
  • xxxxxxxxxx 1 if(j != k){ 2 matrix[j][k] = matrix[j][k] + 1 3 }
  • xxxxxxxxxx 1 if(j != k){ 2 matrix[j][k] = matrix[j][k] + 1 3 matrix[k][j] = matrix[k][j] + 1 4 }
  • xxxxxxxxxx 1 matrix[j][k] = matrix[j][k] + 1 2 matrix[k][j] = matrix[k][j] + 1

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • if(j != k){ matrix[j][k] = matrix[j][k] + 1 }

Question 6

The following pseudocode creates adjacency matrix matrix2 of another graph H from books. For two different authors i and j, what does the value matrix2[i][j] represent at the end of the execution?

xxxxxxxxxx

1

matrix2 = createMatrix(n, n)

2

foreach j in rows(matrix2){

3

    foreach k in columns(matrix2){

4

        matrix2[j][k] = []

5

    }

6

}

7

foreach i in keys(books){

8

    foreach j in book[i]{

9

        foreach k in books[i]{

10

            foreach h in books[i]{

11

                if(j != k and j != h and k != h and not member(matrix2[j][k], h)){

12

                    matrix2[j][k] = matrix2[j][k] ++ [h]

13

                    matrix2[k][j] = matrix2[k][j] ++ [h]

14

                }

15

            }

16

        }

17

    }

18

}
  • List of authors who have co-authored a book with both i and j
  • List of authors who have co-authored a book with either i or j
  • List of authors who have co-authored at least two book with both i and j
  • List of authors who have co-authored at least two book with either i or j

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • List of authors who have co-authored a book with both i and j

Question 7

Which of the following combinations of entries in matrix and matrix2 is possible for two different authors i and j? It is Multiple Select Question (MSQ).

  • matrix[i] [j] = 0 and matrix2[i] [j] = [ ]
  • matrix[i][j] = 0 and matrix2[i][j] [ ]
  • matrix[i][j] > 0 and matrix2[i][j] = [ ]
  • matrix[i][j] > 0 and matrix2[i][j] [ ]

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • matrix[i] [j] = 0 and matrix2[i] [j] = [ ]
  • matrix[i][j] > 0 and matrix2[i][j] = [ ]
  • matrix[i][j] > 0 and matrix2[i][j] [ ]

Question 8

Consider the matrices matrix and matrix2 constructed in the previous questions.

findAuthor(matrix) finds an author who has the maximum number of co-authors. Choose the correct implementation of the procedure findAuthor. It is a Multiple Select Question.

  • xxxxxxxxxx 1 Procedure findAuthor(M) 2 Max = 0 3 A = 0 4 foreach i in rows(M){ 5 Sum = 0 6 foreach j in columns(M){ 7 if(M[i][j] > 0){ 8 Sum = Sum + 1 9 } 10 } 11 if(Sum > Max){ 12 Max = Sum 13 A = i 14 } 15 } 16 return(A) 17 End findAuthor
  • xxxxxxxxxx 1 Procedure findAuthor(M) 2 Max = 0 3 A = 0 4 foreach i in rows(M){ 5 Sum = 0 6 foreach j in columns(M){ 7 if(M[i][j] > 0){ 8 Sum = Sum + M[i][j] 9 } 10 } 11 if(Sum > Max){ 12 Max = Sum 13 A = i 14 } 15 } 16 return(A) 17 End findAuthor
  • xxxxxxxxxx 1 Procedure findAuthor(M) 2 Max = 0 3 A = 0 4 foreach i in columns(M){ 5 Sum = 0 6 foreach j in rows(M){ 7 if(M[j][i] > 0){ 8 Sum = Sum + 1 9 } 10 } 11 if(Sum > Max){ 12 Max = Sum 13 A = i 14 } 15 } 16 return(A) 17 End findAuthor
  • xxxxxxxxxx 1 Procedure findAuthor(M) 2 Max = 0 3 A = 0 4 foreach i in columns(M){ 5 Sum = 0 6 foreach j in rows(M){ 7 if(M[j][i] > 0){ 8 Sum = Sum + M[j][i] 9 } 10 } 11 if(Sum > Max){ 12 Max = Sum 13 A = i 14 } 15 } 16 return(A) 17 End findAuthor

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • Procedure findAuthor(M) Max = 0 A = 0 foreach i in rows(M){ Sum = 0 foreach j in columns(M){ if(M[i][j] > 0){ Sum = Sum + 1 } } if(Sum > Max){ Max = Sum A = i } } return(A) End findAuthor
  • Procedure findAuthor(M) Max = 0 A = 0 foreach i in columns(M){ Sum = 0 foreach j in rows(M){ if(M[j][i] > 0){ Sum = Sum + 1 } } if(Sum > Max){ Max = Sum A = i } } return(A) End findAuthor

Question 9

Consider the adjacency matrix matrix constructed above. Assume that there exists a procedure removeDuplicate which receives a list as input and removes all duplicate elements in the list. When will findGoodSet(matrix) return True?

xxxxxxxxxx

1

Procedure findGoodSet(M)

2

    foreach i in rows(M){

3

        foreach j in columns(M){

4

            foreach h in rows(M){

5

                list1 = []

6

                if(length(M[i][j]) == 1 and member(D[h], first(M[i][j]))){

7

                    list1 = list1 ++ M[i][j]

8

                }

9

                if(length(M[i][h]) == 1 and member(D[j], first(M[i][h]))){

10

                    list1 = list1 ++ M[i][h]

11

                }

12

                if(length(M[j][h]) == 1 and member(D[i], first(M[j][h]))){

13

                    list1 = list1 ++ M[j][h]

14

                }

15

                list1 = removeDuplicate(list1)

16

                if(length(list1) == 1){

17

                    return(True)

18

                }

19

            }

20

        }

21

    }

22

    return(False)

23

End findGoodSet
  • If there exists three customers who have visited all three shops.
  • If there exist three customers such that every pair of customers among them have visited only one and the same shop in common.
  • If there exists three customers who have visited exactly one shop.
  • If there exists three customers where each pair among them have visited exactly one shop in common.

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • If there exist three customers such that every pair of customers among them have visited only one and the same shop in common.

Question 10

For a pair of customers i and j, j is said to be shopping partner of i if i and j have visited at least two shops in common. findTopCustomer(matrix) finds a customer who has the maximum shopping partners. Choose the correct implementation of findTopCustomer.

  • xxxxxxxxxx 1 Procedure findTopCustomer(M) 2 Max = 0, A = 0 3 foreach i in rows(M){ 4 C = 0 5 foreach j in columns(M) { 6 if(length(M[i][j]) == 2){ 7 C = C + 1 8 } 9 } 10 if(C > Max){ 11 Max = C 12 A = i 13 } 14 } 15 return(A) 16 End findTopCustomer
  • xxxxxxxxxx 1 Procedure findTopCustomer(M) 2 Max = 0, A = 0 3 foreach i in rows(M){ 4 C = 0 5 foreach j in columns(M){ 6 if(length(M[i][j]) > 1){ 7 C = C + 1 8 } 9 } 10 if(C > Max){ 11 Max = C 12 A = i 13 } 14 } 15 return(A) 16 End findTopCustomer
  • xxxxxxxxxx 1 Procedure findTopCustomer(M) 2 Max = 0, A = 0 3 foreach i in rows(M){ 4 C = 0 5 foreach j in columns(M) { 6 if(length(M[i][j]) == 2){ 7 C = C + 1 8 } 9 } 10 if(C > Max){ 11 Max = C 12 A = i 13 } 14 } 15 return(Max) 16 End findTopCustomer
  • xxxxxxxxxx 1 Procedure findTopCustomer(M) 2 Max = 0, A = 0 3 foreach i in rows(M){ 4 C = 0 5 foreach j in columns(M){ 6 if(length(M[i][j]) > 1){ 7 C = C + 1 8 } 9 } 10 if(C > Max){ 11 Max = C 12 A = i 13 } 14 } 15 return(Max) 16 End findTopCustomer

Status: Yes, the answer is correct. Score: 5

Accepted Answers:

  • Procedure findTopCustomer(M) Max = 0, A = 0 foreach i in rows(M){ C = 0 foreach j in columns(M){ if(length(M[i][j]) > 1){ C = C + 1 } } if(C > Max){ Max = C A = i } } return(A) End findTopCustomer