Quiz Space

January 2022 term · Computational Thinking · BSCS1001

Computational Thinking (CT) Quiz 2: 13 March 2022, Set QPE2 (January 2022 term)

The IIT Madras BS Computational Thinking (Computational Thinking (CT)) Quiz 2 paper sat on 13 Mar 2022, in the January 2022 term, set QPE2: 19 questions for 50 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
19
Marks
50
Duration
120 min
MCQ
14
MSQ
3
Numerical
2

Updated

Official paper: IIT M FOUNDATION QUIZ2 EXAM QPE2 13 Mar 2022 · No negative marking.

Question 1

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

Elements of L can be lists.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 2

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

Let a be a key of dictionary D , then a must be an integer

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 3

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

For keys a and b in D , if a ≠ b then D [a] ≠ D[b] is always True.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 4

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

For keys a and b in D , a ≠ b is always True.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 5

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

For a key a in D , D [a] can be a dictionary.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • A

    TRUE

Question 6

+1 markOne correct option

Let L be a non-empty list, and D be a non-empty dictionary. Choose whether the given statements are true or false:

Let D = { 3 : {‘a’: 5, ‘b’ : 4}, 5 : {‘c’ : 6}}, then the value of D [‘c’] is 6.

  1. A

    TRUE

  2. B

    FALSE

Show answer

Correct answer

  • B

    FALSE

Question 7

+3 marksOne correct option

Consider the procedure doSomething given below. If A = [4, 5, 3, 1, 9, 4, 6, 5, 9] and B = doSomething(A).

text
1 Procedure doSomething(A)
2 outList = [first(A)]
3 foreach X in rest(A) {
4 if (X ≠ first(A)) {
5 outList = outList ++ [X]
6 }
7 }
8 return (outList)
9 End doSomething

Choose the correct option.

  1. A

    B = [4, 5, 3, 1, 9, 6, 5, 9]

  2. B

    B = [4, 5, 3, 1, 9, 6]

  3. C

    B = [3, 1, 6]

  4. D

    B = [5, 3, 1, 9, 4, 6, 5, 9]

Show answer

Correct answer

  • A

    B = [4, 5, 3, 1, 9, 6, 5, 9]

Question 8

+4 marksOne correct option

The following table contains information regarding authors from the “Library” dataset. Each row in the table corresponds to an author and list of publication years. There are n authors, each author is being assigned a unique index between 0 and n−1.

The table is represented by a dictionary named authors, with S.No as keys and lists of publication years as values. Assume that authors has already been computed. For example, we have: authors [0] = [1998,..., 2015]
isCommon(L1, L2) returns True if there are at least two common elements in lists L1 and L2.

text
M = createMatrix (n, n)
foreach i in keys (authors) {
foreach j in keys (authors) {
if (i > j and isCommon(authors[i], authors[j])) {
M[i][j] = 1
M[j][i] = 1
}
}
}
A = { }
foreach i in rows (M) {
count = 0
foreach j in columns (M) {
if (M[i][j] ≠ 0) {
count = count + 1
}
}
A[i]= count
}

What does an entry A[i] represent at the end of the execution of the pseudocode above?

  1. A

    Author A[i] has published books in i years

  2. B

    Author i has published books in A[i] years

  3. C

    Author A[i] has published at least two books in common years with i authors

  4. D

    Author i has published at least two books in common years with A[i] authors

Show answer

Correct answer

  • D

    Author i has published at least two books in common years with A[i] authors

Question 9

+4 marksOne correct option

In a shop selling soft drinks, Ritvika wants to combine two soft drinks to see which combinations taste better. The drinks are labeled from 0 to n−1. To keep track of these combinations, she creates a matrix M. For drink i and j such that i ≠ j, if the combination of i and j tastes good, then M[i][j] = 1, otherwise 0. leastSuitable(M) returns the list of drinks which are least suitable for mixing with the maximum number of drinks. Choose the correct code fragment

text
Procedure leastSuitable(M)
min = 10000
minList = [ ]
foreach i in rows(M) {
k = 0
********************
* Fill the code *
********************
}
return (minList)
End leastSuitable
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 10

+3 marksOne correct option

Consider the procedure given below.

text
Procedure eliminate (L1, L2)
L3 = [ ], Found = False
foreach i in L2 {
foreach j in L1 {
if (i == j) {
Found = True
}
}
if (not Found) {
L3 = L3 ++ [i]
}
Found = False
}
return (L3)
End eliminate

If L1 and L2 are two lists, and L = eliminate (L1, L2), then answer the given subquestions.

What will L represent?

  1. A

    It will contain all elements of L2 that are not present in L1.

  2. B

    It will contain all elements of L1 that are not present in L2 .

  3. C

    It will contain the elements common to L1 and L2 .

  4. D

    It will contain the elements present in L1 or L2 but not both.

Show answer

Correct answer

  • A

    It will contain all elements of L2 that are not present in L1.

Question 11

+2 marksOne or more correct options

Consider the procedure given below.

text
Procedure eliminate (L1, L2)
L3 = [ ], Found = False
foreach i in L2 {
foreach j in L1 {
if (i == j) {
Found = True
}
}
if (not Found) {
L3 = L3 ++ [i]
}
Found = False
}
return (L3)
End eliminate

If L1 and L2 are two lists, and L = eliminate (L1, L2), then answer the given subquestions.

Which of the following option(s) is/are always correct? It is a Multiple Select Question (MSQ).

Select all that apply.

  1. A

    length(L2) − length(L1 ) = length(L)

  2. B

    length(L2) > length(L1)

  3. C

    length(L2) ≥ length(L)

  4. D

    length(L1 ) ≤ length(L)

Show answer

Correct answer

  • C

    length(L2) ≥ length(L)

Question 12

+3 marksNumerical answer

What will countSomething(M, 0, 5) return?
NOTE: Enter your answer to the nearest integer.

Show answer

Correct answer: 1

Question 13

+2 marksNumerical answer

If Line 2 is replaced by count = M[i][j], then what will countSomething(M, 0, 5) return? NOTE: Enter your answer to the nearest integer.

Show answer

Correct answer: 1

Question 14

+3 marksOne correct option

The following pseudocode is executed using the “Words” dataset. Assume that words are arranged in increasing order of sequence number.

text
B = 0
sList = [ ], wList = [ ]
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
wList = wList ++ [X.PartOfSpeech]
if (X.Word ends with a full stop) {
A = doSomething(wList)
if (A > B) {
B = A
}
sList = sList ++ [wList]
wList = [ ]
}
}
Procedure doSomething(L)
count = 0
foreach p in L {
if (p == "Noun") {
count = count + 1
}
}
return(count)
End doSomething

Based on the above data, answer the given subquestions.

What will B represent at the end of the execution?

  1. A

    Maximum number of nouns in a sentence across all sentences.

  2. B

    Total number of nouns across all sentences.

  3. C

    Minimum number of nouns in a sentence across all sentences.

  4. D

    Number of sentences having maximum number of nouns.

Show answer

Correct answer

  • A

    Maximum number of nouns in a sentence across all sentences.

Question 15

+4 marksOne correct option

The following pseudocode is executed using the “Words” dataset. Assume that words are arranged in increasing order of sequence number.

text
B = 0
sList = [ ], wList = [ ]
while (Table 1 has more rows) {
Read the first row X in Table 1
Move X to Table 2
wList = wList ++ [X.PartOfSpeech]
if (X.Word ends with a full stop) {
A = doSomething(wList)
if (A > B) {
B = A
}
sList = sList ++ [wList]
wList = [ ]
}
}
Procedure doSomething(L)
count = 0
foreach p in L {
if (p == "Noun") {
count = count + 1
}
}
return(count)
End doSomething

Based on the above data, answer the given subquestions.

What will length(sList) represent at the end of execution.

  1. A

    Total number of words in “Words” dataset

  2. B

    Total number of sentences in “Words” dataset

  3. C

    Total number of words with same part of speech in “Words” dataset

  4. D

    Total number of words with different part of speech in “Words” dataset

Show answer

Correct answer

  • B

    Total number of sentences in “Words” dataset

Question 16

+4 marksOne correct option

The following pseudocode is executed using the “Shopping Bills” dataset.

text
D = { }
while (Pile 1 has more cards) {
Read the top card X in Pile 1
foreach a in X.ItemList {
if (isKey(D, a.Category)) {
if (isKey(D[a.Category], a.ItemName)) {
D[a.Category][a.ItemName] = D[a.Category][a.ItemName] ++ [a.Price]
}
else {
D[a.Category][a.ItemName] = [a.Price]
}
}
else {
D[a.Category] = { }
D[a.Category][a.ItemName] = [a.Price]
}
}
Move card X to Pile 2
}

Based on the above data, answer the given subquestions.

What will each value D[i][j] represent at the end of the execution?

  1. A

    Price of item i of category j across all bills

  2. B

    Price of item j of category i across all bills

  3. C

    List of prices of item i of category j across all bills

  4. D

    List of prices of item j of category i across all bills

Show answer

Correct answer

  • D

    List of prices of item j of category i across all bills

Question 17

+4 marksOne correct option

The following pseudocode is executed using the “Shopping Bills” dataset.

text
D = { }
while (Pile 1 has more cards) {
Read the top card X in Pile 1
foreach a in X.ItemList {
if (isKey(D, a.Category)) {
if (isKey(D[a.Category], a.ItemName)) {
D[a.Category][a.ItemName] = D[a.Category][a.ItemName] ++ [a.Price]
}
else {
D[a.Category][a.ItemName] = [a.Price]
}
}
else {
D[a.Category] = { }
D[a.Category][a.ItemName] = [a.Price]
}
}
Move card X to Pile 2
}

Based on the above data, answer the given subquestions.

Using the dictionary D created in the previous question, what will the value of L represent at the end of the execution of the pseudocode below?

text
A = 100000, L = [ ]
foreach i in keys(D) {
foreach j in keys(D[i]) {
data = findRange(D[i][j])
B = first(data) - last(data)
if (B == A) {
L = L ++ [j]
}
if (B < A) {
A = B
L = [j]
}
}
}
Procedure findRange(Y)
p = 0, q = 100000
foreach k in Y{
if (k > p) {
p = k
}
if (k < q) {
q = k
}
}
return([p, q])
End findRange
  1. A

    List of items for which the difference between the highest and lowest price is the same

  2. B

    List of items for which the difference between the highest and lowest price is maximum

  3. C

    List of items for which the difference between the highest and lowest price is minimum

  4. D

    List of items with same price in all shops

Show answer

Correct answer

  • C

    List of items for which the difference between the highest and lowest price is minimum

Question 18

+4 marksOne or more correct options

The following pseudocode is executed using the “Shopping Bills” dataset. Procedure similar(X, Y) returns True if the difference between X and Y is less than 100.

text
A = { }
while (Pile 1 has more cards) {
Read the top card X in Pile 1
A[X.Seq_No] = [X.ShopName, X.Total]
Move card X to Pile 2
}
n = length(keys(A))
S = CreateMatrix(n, n)
foreach i in keys(A) {
foreach j in keys(A) {
if (i > j and isPair(A[i], A[j])) {
S[i][j] = 1
S[j][i] = 1
}
}
}
Procedure isPair(P, Q)
if (first(P) ≠ first(Q) and similar(last(P), last(Q))) {
return (True)
}
else {
return (False)
}
End isPair

A graph is constructed using matrix S created by the above pseudocode. Based on the given information answer the subquestions.

Choose the correct statement(s). It is a Multiple Select Question (MSQ).

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • C
  • D

Question 19

+4 marksOne or more correct options

The following pseudocode is executed using the “Shopping Bills” dataset. Procedure similar(X, Y) returns True if the difference between X and Y is less than 100.

text
A = { }
while (Pile 1 has more cards) {
Read the top card X in Pile 1
A[X.Seq_No] = [X.ShopName, X.Total]
Move card X to Pile 2
}
n = length(keys(A))
S = CreateMatrix(n, n)
foreach i in keys(A) {
foreach j in keys(A) {
if (i > j and isPair(A[i], A[j])) {
S[i][j] = 1
S[j][i] = 1
}
}
}
Procedure isPair(P, Q)
if (first(P) ≠ first(Q) and similar(last(P), last(Q))) {
return (True)
}
else {
return (False)
}
End isPair

A graph is constructed using matrix S created by the above pseudocode. Based on the given information answer the subquestions.

There will be an edge between bills i and j if:
It is a Multiple Select Question (MSQ).

Select all that apply.

  1. A

    The total bill amount of i is lower than the total bill amount of j by less than 100 and both bills are from the different shops.

  2. B

    The total bill amount of i is greater than the total bill amount of j by less than 100 and both bills are from the different shops.

  3. C

    The total bill amounts of bills i and j are same but both bills are from the different shops.

  4. D

    The total bill amounts of bills i and j are same and both bills are from the same shop.

Show answer

Correct answers

  • A

    The total bill amount of i is lower than the total bill amount of j by less than 100 and both bills are from the different shops.

  • B

    The total bill amount of i is greater than the total bill amount of j by less than 100 and both bills are from the different shops.

  • C

    The total bill amounts of bills i and j are same but both bills are from the different shops.