Prasnya
Prasnya
Prasnya
Continue with Google
Prasnya
Continue with Google
Week 5 Computational Thinking Questions | Prasnya
Computational Thinking > Week 5
All PYQs
Topic-Wise PYQs
Start Weekly Test
Mock tests
Week mock
Topic mock
Subject mock
Type:
All
Difficulty:
All
Year:
All
50Q
01
What will be the value of `outList` at the end of execution of the given pseudocode? ``` L = [[10, 20, 'Z'], [30, 40, 'Y'], [50, 60, 'X']] outList = [] foreach element in L { z = process(element) outList = [z] ++ outList } Procedure process(K) val = last(K) return(val) End process ```
Single correct
EASY
4 marks
06 April 2026
02
Use the procedure `doSomething` given below. The following pseudocode is executed using the Words dataset and the procedure `doSomething`. What will `sList` store at the end of execution? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList{ if(not isKey(bDict, a)){ bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething sList = [] wList = [] while(Table 1 has more rows){ Read the first row X from Table 1 wList = wList ++ [X.Word] if(X.Word ends with a full stop){ wList = doSomething(wList) sList = sList ++ [wList] wList = [] } Move row X to Table 2 } ```
Single correct
MEDIUM
5 marks
06 April 2026
03
Two players play a game with dice. The results are stored in `diceRolls`, a list of pairs where each pair `(A, B)` represents a roll: `A` is Player 1's roll and `B` is Player 2's roll. A player gets 1 point if their roll is higher than the other's. If both roll the same, no one gets a point. The procedure `getWinner` should return `1` if Player 1 wins, `2` if Player 2 wins, and `0` for a tie. Which procedure(s) is/are correct?
Multiple correct
MEDIUM
4 marks
06 April 2026
04
Let `SortedL` be a list of integers sorted in ascending order. The procedure `deleteVal(SortedL, X)` is supposed to delete the first instance of `X` from `SortedL`, if it exists, while maintaining the sorted order. Identify the correct implementation(s). Assume `member` checks existence and `remove` removes the first occurrence in-place.
Multiple correct
MEDIUM
5 marks
06 April 2026
05
We have a non-empty list called `authList` that stores the names of all authors in the "Library" table sorted by alphabetical order of author name. Every book in the table creates an entry in `authList` for each of its authors. This results in many duplicates in `authList`. The following procedure attempts to extract the unique list of authors, while preserving the sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` uniqueList = [] uniqueList = uniqueList ++ [last(authList)] prev = first(authList) foreach x in rest(authList) { if(x == prev) { uniqueList = uniqueList ++ [x] } prev = x } ```
Multiple correct
MEDIUM
5 marks
03 August 2025
06
What is the value of `L` at the end of execution?
Comprehension
EASY
4 marks
03 August 2025
07
What is the value of `LC` at the end of execution?
Comprehension
MEDIUM
4 marks
03 August 2025
08
Consider the following pseudocode. If at the end of the execution,
m
L
i
s
t
mList
m
L
i
s
t
stores
[
10
,
20
,
30
,
40
,
50
]
[10, 20, 30, 40, 50]
[
10
,
20
,
30
,
40
,
50
]
, then choose the correct code fragment. ``` L = [[10, 'Raj', 5.0], [20, 'Ramesh', 3.5], [30, 'Rakesh', 2.0], [40, 'Rajat', 1.5], [50, 'Ram', 4.0]] mList = [] ******************** **Fill the code** ******************** ```
Single correct
EASY
4 marks
16 March 2025
09
What will `length(sList)` represent at the end of the execution?
Comprehension
EASY
4 marks
16 March 2025
10
Which of the following statements is/are correct?
Comprehension
MEDIUM
5 marks
16 March 2025
11
Which of the following statements is/are correct?
Comprehension
HARD
5 marks
16 March 2025
12
What will the value of `mList` be at the end of the execution of the following pseudocode? ``` L = [[1, 20, 'A'], [2, 40, 'B'], [3, 60, 'C'], [4, 80, 'D'], [5, 100, 'E']] mList = [] for element in L { z = doSomething(element) mList = mList ++ [z] } Procedure doSomething(X) a = init(X) return(last(a) / 2) End doSomething ```
Single correct
EASY
4 marks
01 December 2024
13
Consider the following pseudocode. If `numList = [3, -2, 4, -1, 7, -5]`, then what will `categorizeNumbers(numList)` return at the end of execution? ``` Procedure categorizeNumbers(numList) posList = [] negList = [] foreach n in numList { if(n >= 0) { posList = posList ++ [n] } else { negList = negList ++ [n] } } sumpos = 0 foreach p in posList { sumpos = sumpos + p } sumneg = 0 foreach q in negList { sumneg = sumneg + q } if(sumneg < sumpos) { return(posList) } else { return(negList) } End categorizeNumbers ```
Single correct
MEDIUM
5 marks
01 December 2024
14
We have a non-empty list `Publisher` that stores the publisher name in each card from the Library dataset, sorted in alphabetical order. This results in many duplicates. The following procedure attempts to extract the unique list of publishers, while preserving the sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` 1 uniqueList = [first(Publisher)] 2 prev = last(Publisher) 3 for each x in rest(Publisher) { 4 if(x != prev) { 5 uniqueList = uniqueList ++ x 6 } 7 prev = x 8 } ```
Multiple correct
MEDIUM
4 marks
01 December 2024
15
Based on the two Words-dataset pseudocodes above, which of the following statements is/are correct?
Comprehension
HARD
5 marks
01 December 2024
16
What changes/modification should we make to Pseudocode 2 so that, at the end of execution, `count` represents the number of words having at least 4 distinct letters in the dataset?
Comprehension
HARD
5 marks
01 December 2024
17
What will the value of `mList` be at the end of the execution of the pseudocode below? ``` L = [[10, 'Raj', 5.0], [20, 'Ramesh', 3.5], [30, 'Rakesh', 2.0], [40, 'Rafat', 1.5], [50, 'Ram', 4.0]] mList = [] foreach element in L { x = DoSomething(element) mList = mList ++ [x] } Procedure DoSomething(X) a = init(X) return(first(a)) End DoSomething ```
Single correct
EASY
3 marks
04 August 2024
18
Consider the procedure given below. If `L1` and `L2` are two lists, and `L = eliminate(L1, L2)`, choose the correct option regarding `L`. ``` Procedure eliminate(L1, L2) L3 = [], Found = False foreach i in L1 { foreach j in L2 { if (i == j) { Found = True } } if (not Found) { L3 = L3 ++ [i] } Found = False } return(L3) End eliminate ```
Single correct
EASY
4 marks
04 August 2024
19
The following pseudocode is executed using the Scores dataset. Let `M`, `P`, and `C` be the lists of sequence numbers of students who scored more than 75 marks in Mathematics, Physics, and Chemistry respectively. At the end, `dict` maps each student's sequence number to the number of subjects in which the student scored more than 75. Choose the correct implementation(s) of `nSub`. ``` dict = {} while (Table 1 has more rows) { Read the first row X in Table 1 dict[X.SeqNo] = nSub(X.SeqNo) Move X to Table 2 } ```
Multiple correct
MEDIUM
5 marks
04 August 2024
20
Let `N` be a list of the first 50 positive integers, i.e., `N = [1, 2, 3, ..., 49, 50]`. What will be the value of `count` at the end of execution? ``` count = 0 A = someList(N) B = someList(rest(N)) foreach Y in A { foreach Z in B { if (Z == Y) { count = count + 1 } } } Procedure someList(X) outList = [], newList = X while (length(newList) > 1) { outList = outList ++ [first(newList)] newList = rest(rest(newList)) } return(outList) End someList ```
Numerical
MEDIUM
4 marks
04 August 2024
21
If `A = [4, 3, 1, 3, 4, 5, 1, 2, 7]`, then what will the value of `B` be at the end of execution?
Comprehension
MEDIUM
4 marks
04 August 2024
22
If `A = [4, 3, 2, 4, 3, 5, 6, 7, 8, 6, 2]`, then what will the value of `B` be at the end of execution?
Comprehension
MEDIUM
4 marks
04 August 2024
23
What will the value of `mList` be at the end of execution of the pseudocode below? ``` L = [[10, 'apple', 5.0], [20, 'banana', 3.5], [30, 'cherry', 2.0], [40, 'date', 1.5], [50, 'elderberry', 4.0]] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a)) End DoSomething ```
Single correct
EASY
3 marks
24 March 2024
24
The following pseudocode is executed using the Words dataset and `explode(X)` returns letters in word `X` as a list. What will `count` represent at the end of execution? ``` count = 0, letterList = [] while (Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + processLetters(letterList) Move X to Table 2 } Procedure processLetters(L) prevLetter = first(L) restList = rest(L) foreach letter in restList { if (letter == prevLetter) { return(0) } prevLetter = letter } return(1) End processLetters ```
Single correct
MEDIUM
4 marks
24 March 2024
25
The following pseudocode is executed using the Words dataset. What will `count` represent at the end of execution? ``` count = 0 L = [] while (Table 1 has more rows) { Read the first row X in Table 1 L = addSomething(L, X) if (X.Word ends with a full stop) { if (length(L) >= 10) { count = count + 1 } L = [] } Move X to Table 2 } Procedure addSomething(M, Y) i = 1 while (i <= Y.LetterCount) { P = ith letter of Y.Word if (not member(M, P)) { M = M ++ [P] } i = i + 1 } return(M) End addSomething ```
Single correct
MEDIUM
4 marks
24 March 2024
26
We have a non-empty list `Publisher` storing publisher names sorted alphabetically. This results in duplicates. The following procedure attempts to extract the unique list of publishers while preserving sorted order. Identify all mistakes, if any. ``` uniqueList = [first(Publisher)] prev = last(Publisher) for each x in rest(Publisher) { if (x != prev) { uniqueList = uniqueList ++ x } prev = x } ```
Multiple correct
HARD
4 marks
24 March 2024
27
What will be the values of `mList` after execution of the following pseudocode? ``` L = [[1, 100, 'A'], [2, 99, 'B'], [3, 98, 'C'], [4, 97, 'D'], [5, 96, 'E']] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a) * 2) End DoSomething ```
Single correct
EASY
3 marks
03 December 2023
28
Alex and Elena play a game. Each round score is `[x, y]`, where `x` is Alex's score and `y` is Elena's score. The procedure `findGameWinner(S)` returns `winner = 1` if Alex wins, `winner = 2` if Elena wins, and `winner = 0` for a draw. Which procedure(s) correctly identify the winner?
Multiple correct
MEDIUM
5 marks
03 December 2023
29
Let `explode(W)` return the list of letters in word `W`. What will be the value of `count` at the end of execution? ``` count = 0 letterList = [] wordList = ["bookkeeper", "inspects", "things", "choose"] foreach word in wordList { letterList = explode(word) lastLetter = "" flag = False foreach letter in letterList { if (letter is a vowel and letter == lastLetter) { flag = True } lastLetter = letter } if (flag) { count = count + 1 } } ```
Numerical
MEDIUM
4 marks
03 December 2023
30
The given pseudocode is executed on the Words dataset. `C` stores the number of nouns which have at least one verb adjacent to it. Choose the correct code fragment to complete the pseudocode. ``` A = [] B = [] C = 0 while (Table 1 has more rows) { Read the first row X in Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } foreach Y in B { if (member(A, Y - 1) or member(A, Y + 1)) { C = C + 1 } } ```
Single correct
MEDIUM
4 marks
03 December 2023
31
Based on the parent pseudocode, what will be the value of `M` at the end of execution?
Comprehension
MEDIUM
3 marks
03 December 2023
32
Based on the parent pseudocode, what will be the value of `MC` at the end of execution?
Comprehension
MEDIUM
3 marks
03 December 2023
33
The procedure below should build a list of serial numbers of specific parts of speech in the Words dataset. The procedure may have mistakes. Identify all mistakes, if any. ``` 1: Procedure BuildList(field) 2: L = {} 3: while (Table 1 has more rows) { 4: Read the first row X in Table 1 5: if (X.PartOfSpeech == field) { 6: L = L ++ [[X.SerialNumber, field]] 7: } 8: Move X to Table 2 9: } 10: return(field) 11: End BuildList 12: L1 = BuildList("Pronoun") 13: L2 = BuildList("Verb") ```
Multiple correct
MEDIUM
4 marks
03 December 2023
34
What will be the value of `mList` at the end of the given pseudocode? ``` L = [[1, 100, 'A'], [2, 99, 'B'], [3, 98, 'C'], [4, 97, 'D'], [5, 96, 'E']] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a)) End DoSomething ```
Single correct
EASY
2 marks
06 August 2023
35
The following pseudocode is executed using the Words dataset and `explode(X)` returns the list of letters in the word `X`. For example, `explode("sweet")` returns `['s', 'w', 'e', 'e', 't']`. What will `count` represent at the end of execution? ``` count = 0, letterList = [] while(Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + checkSomething(letterList) Move X to Table 2 } Procedure checkSomething(L) lastLetter = first(L) restList = rest(L) foreach letter in restList { if(letter == lastLetter) { return(1) } lastLetter = letter } return(0) End checkSomething ```
Single correct
MEDIUM
4 marks
06 August 2023
36
The following pseudocode is executed using the Words dataset. What will `count` represent at the end of execution? ``` A = 10000, count = 0 L = [] while(Table 1 has more rows) { Read the first row X in Table 1 L = addSomething(L, X) if(X.Word ends with a full stop) { if(length(L) == A) { count = count + 1 } if(length(L) < A) { A = length(L) count = 1 } L = [] } Move X to Table 2 } Procedure addSomething(M, Y) i = 1 while(i <= Y.LetterCount) { p = ith letter of Y.Word if(not(member(M, p))) { M = M ++ [p] } i = i + 1 } return(M) End addSomething ```
Single correct
MEDIUM
4 marks
06 August 2023
37
Let `LA` be a sorted list of integers in ascending order, and `X` be an integer. The procedure `insert(LA, X)` returns a list `LB` where `X` is added to `LA` such that `LB` remains sorted. The procedure may have mistakes. Identify all such mistakes, if any. ``` Procedure insert(LA, X) LB = [] flag = True foreach A in LA { if(flag) { if(X <= A) { LB = LB ++ [A] flag = False } } LB = LB ++ [A] } if(not flag) { LB = LB ++ [X] } return(LB) End insert ```
Multiple correct
HARD
5 marks
06 August 2023
38
We have a non-empty list `Location` that stores city names from the Scores dataset, sorted in alphabetical order. This results in many duplicates. The following procedure attempts to extract the unique list of cities while preserving sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` uniqueList = [] uniqueList = uniqueList ++ [first(Location)] prev = last(Location) foreach x in rest(Location) { if(x != prev) { uniqueList = uniqueList ++ x } prev = x } ```
Multiple correct
MEDIUM
4 marks
06 August 2023
39
Alice and Bob play a coin-toss game. Each entry in `aList` is `[i, j]`, where `i` is Alice's outcome and `j` is Bob's outcome. Procedure `findWinner(aList)` should return `c`: `0` for Bob, `1` for Alice, and `2` for a draw. Which procedure correctly identifies the winner?
Multiple correct
MEDIUM
4 marks
06 August 2023
40
What will `flag` represent at the end of each sentence?
Comprehension
EASY
3 marks
06 August 2023
41
`wList` will contain all words of the last sentence of the Words dataset at the end of execution of the given pseudocode.
Comprehension
EASY
2 marks
06 August 2023
42
The value of `length(sList)` will be the same as the number of sentences in the Words dataset at the end of execution of the given pseudocode.
Comprehension
EASY
2 marks
06 August 2023
43
Consider the following pseudocode. At the end of execution, if `flag` has value `True`, choose the possible value of `L` from the choices. ``` flag = False position = 0 foreach element in L { if((position == 1) and (element == 'Y')) { flag = True } position = position + 1 } ```
Single correct
EASY
2 marks
02 April 2023
44
Consider the following procedure, where `L1` and `L2` are two non-empty lists. `findSomething(L1, L2)` will return `True` when: ``` Procedure findSomething(L1, L2) if(length(L1) != length(L2)) { return(False) } while(length(L1) > 0) { if(first(L1) != last(L2)) { return(False) } L1 = rest(L1) L2 = init(L2) } return(True) End findSomething ```
Single correct
MEDIUM
3 marks
02 April 2023
45
The following pseudocode is executed using the Words dataset and `explode(W)` returns the list of letters in word `W`. At the end of execution, `count` stores the number of words with at least two consecutive occurrences of the same letter. Choose the correct code fragment to complete the procedure. ``` count = 0, letterList = [] while(Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + consecute(letterList) Move X to Table 2 } Procedure consecute(L) lastLetter = first(L) restList = rest(L) *************** * Fill the code * *************** End consecute ```
Single correct
MEDIUM
4 marks
02 April 2023
46
Consider the procedure below, where `aList` is a non-empty list of real numbers. At the end of execution, which options are correct? ``` Procedure cumulative(aList) sum = 0, cumulList = [] foreach element in aList { sum = sum + element cumulList = cumulList ++ [sum] } return(cumulList) End cumulative ```
Multiple correct
EASY
4 marks
02 April 2023
47
Consider the procedure below. If `C = [3, 4, 1, 9, 5, 3, 1, 9]` and `B = doSomething(C)`, what will be the value of `first(B)`? ``` Procedure doSomething(A) outList = [last(A)] foreach X in A { if(X != last(outList)) { outList = [X] ++ outList } } return(outList) End DoSomething ```
Numerical
MEDIUM
3 marks
02 April 2023
48
Let `timeList` be a list of pairs containing information about trains associated with a station `stn`. Each element is `[Arrival, Departure]`. If arrival or departure time is empty, it is represented as "None". What does `count` represent at the end of execution? ``` count = 0 foreach x in timeList { if((first(x) != "None" and last(x) != "None")) { count = count + 1 } } ```
Single correct
MEDIUM
3 marks
20 November 2022
49
Let `explode(W)` return the list of letters in word `W`. What will `count` store at the end of execution? ``` count = 0, letterList = [] wordList = ["keep", "exploring", "and", "keep", "learning"] foreach word in wordList { letterList = explode(word) lastLetter = "", flag = False foreach letter in letterList { if(letter is a vowel and letter == lastLetter) { flag = True } lastLetter = letter } if(flag) { count = count + 1 } } ```
Single correct
MEDIUM
4 marks
20 November 2022
50
Consider the procedure below, where `aList` is a list of integers. Which options are correct at the end of execution? ``` procedure cumulative(aList) sum = 0, cumulList = [] foreach element in aList { sum = sum + element cumulList = cumulList ++ [sum] } return(cumulList) end cumulative ```
Multiple correct
MEDIUM
3 marks
20 November 2022
Showing 50 questions.
Computational Thinking > Week 5
All PYQs
Topic-Wise PYQs
Start Weekly Test
Mock tests
Week mock
Topic mock
Subject mock
Type:
All
Difficulty:
All
Year:
All
50Q
01
What will be the value of `outList` at the end of execution of the given pseudocode? ``` L = [[10, 20, 'Z'], [30, 40, 'Y'], [50, 60, 'X']] outList = [] foreach element in L { z = process(element) outList = [z] ++ outList } Procedure process(K) val = last(K) return(val) End process ```
Single correct
EASY
4 marks
06 April 2026
02
Use the procedure `doSomething` given below. The following pseudocode is executed using the Words dataset and the procedure `doSomething`. What will `sList` store at the end of execution? ``` Procedure doSomething(aList) bDict = {} bList = [] foreach a in aList{ if(not isKey(bDict, a)){ bDict[a] = True bList = bList ++ [a] } } return(bList) End doSomething sList = [] wList = [] while(Table 1 has more rows){ Read the first row X from Table 1 wList = wList ++ [X.Word] if(X.Word ends with a full stop){ wList = doSomething(wList) sList = sList ++ [wList] wList = [] } Move row X to Table 2 } ```
Single correct
MEDIUM
5 marks
06 April 2026
03
Two players play a game with dice. The results are stored in `diceRolls`, a list of pairs where each pair `(A, B)` represents a roll: `A` is Player 1's roll and `B` is Player 2's roll. A player gets 1 point if their roll is higher than the other's. If both roll the same, no one gets a point. The procedure `getWinner` should return `1` if Player 1 wins, `2` if Player 2 wins, and `0` for a tie. Which procedure(s) is/are correct?
Multiple correct
MEDIUM
4 marks
06 April 2026
04
Let `SortedL` be a list of integers sorted in ascending order. The procedure `deleteVal(SortedL, X)` is supposed to delete the first instance of `X` from `SortedL`, if it exists, while maintaining the sorted order. Identify the correct implementation(s). Assume `member` checks existence and `remove` removes the first occurrence in-place.
Multiple correct
MEDIUM
5 marks
06 April 2026
05
We have a non-empty list called `authList` that stores the names of all authors in the "Library" table sorted by alphabetical order of author name. Every book in the table creates an entry in `authList` for each of its authors. This results in many duplicates in `authList`. The following procedure attempts to extract the unique list of authors, while preserving the sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` uniqueList = [] uniqueList = uniqueList ++ [last(authList)] prev = first(authList) foreach x in rest(authList) { if(x == prev) { uniqueList = uniqueList ++ [x] } prev = x } ```
Multiple correct
MEDIUM
5 marks
03 August 2025
06
What is the value of `L` at the end of execution?
Comprehension
EASY
4 marks
03 August 2025
07
What is the value of `LC` at the end of execution?
Comprehension
MEDIUM
4 marks
03 August 2025
08
Consider the following pseudocode. If at the end of the execution,
m
L
i
s
t
mList
m
L
i
s
t
stores
[
10
,
20
,
30
,
40
,
50
]
[10, 20, 30, 40, 50]
[
10
,
20
,
30
,
40
,
50
]
, then choose the correct code fragment. ``` L = [[10, 'Raj', 5.0], [20, 'Ramesh', 3.5], [30, 'Rakesh', 2.0], [40, 'Rajat', 1.5], [50, 'Ram', 4.0]] mList = [] ******************** **Fill the code** ******************** ```
Single correct
EASY
4 marks
16 March 2025
09
What will `length(sList)` represent at the end of the execution?
Comprehension
EASY
4 marks
16 March 2025
10
Which of the following statements is/are correct?
Comprehension
MEDIUM
5 marks
16 March 2025
11
Which of the following statements is/are correct?
Comprehension
HARD
5 marks
16 March 2025
12
What will the value of `mList` be at the end of the execution of the following pseudocode? ``` L = [[1, 20, 'A'], [2, 40, 'B'], [3, 60, 'C'], [4, 80, 'D'], [5, 100, 'E']] mList = [] for element in L { z = doSomething(element) mList = mList ++ [z] } Procedure doSomething(X) a = init(X) return(last(a) / 2) End doSomething ```
Single correct
EASY
4 marks
01 December 2024
13
Consider the following pseudocode. If `numList = [3, -2, 4, -1, 7, -5]`, then what will `categorizeNumbers(numList)` return at the end of execution? ``` Procedure categorizeNumbers(numList) posList = [] negList = [] foreach n in numList { if(n >= 0) { posList = posList ++ [n] } else { negList = negList ++ [n] } } sumpos = 0 foreach p in posList { sumpos = sumpos + p } sumneg = 0 foreach q in negList { sumneg = sumneg + q } if(sumneg < sumpos) { return(posList) } else { return(negList) } End categorizeNumbers ```
Single correct
MEDIUM
5 marks
01 December 2024
14
We have a non-empty list `Publisher` that stores the publisher name in each card from the Library dataset, sorted in alphabetical order. This results in many duplicates. The following procedure attempts to extract the unique list of publishers, while preserving the sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` 1 uniqueList = [first(Publisher)] 2 prev = last(Publisher) 3 for each x in rest(Publisher) { 4 if(x != prev) { 5 uniqueList = uniqueList ++ x 6 } 7 prev = x 8 } ```
Multiple correct
MEDIUM
4 marks
01 December 2024
15
Based on the two Words-dataset pseudocodes above, which of the following statements is/are correct?
Comprehension
HARD
5 marks
01 December 2024
16
What changes/modification should we make to Pseudocode 2 so that, at the end of execution, `count` represents the number of words having at least 4 distinct letters in the dataset?
Comprehension
HARD
5 marks
01 December 2024
17
What will the value of `mList` be at the end of the execution of the pseudocode below? ``` L = [[10, 'Raj', 5.0], [20, 'Ramesh', 3.5], [30, 'Rakesh', 2.0], [40, 'Rafat', 1.5], [50, 'Ram', 4.0]] mList = [] foreach element in L { x = DoSomething(element) mList = mList ++ [x] } Procedure DoSomething(X) a = init(X) return(first(a)) End DoSomething ```
Single correct
EASY
3 marks
04 August 2024
18
Consider the procedure given below. If `L1` and `L2` are two lists, and `L = eliminate(L1, L2)`, choose the correct option regarding `L`. ``` Procedure eliminate(L1, L2) L3 = [], Found = False foreach i in L1 { foreach j in L2 { if (i == j) { Found = True } } if (not Found) { L3 = L3 ++ [i] } Found = False } return(L3) End eliminate ```
Single correct
EASY
4 marks
04 August 2024
19
The following pseudocode is executed using the Scores dataset. Let `M`, `P`, and `C` be the lists of sequence numbers of students who scored more than 75 marks in Mathematics, Physics, and Chemistry respectively. At the end, `dict` maps each student's sequence number to the number of subjects in which the student scored more than 75. Choose the correct implementation(s) of `nSub`. ``` dict = {} while (Table 1 has more rows) { Read the first row X in Table 1 dict[X.SeqNo] = nSub(X.SeqNo) Move X to Table 2 } ```
Multiple correct
MEDIUM
5 marks
04 August 2024
20
Let `N` be a list of the first 50 positive integers, i.e., `N = [1, 2, 3, ..., 49, 50]`. What will be the value of `count` at the end of execution? ``` count = 0 A = someList(N) B = someList(rest(N)) foreach Y in A { foreach Z in B { if (Z == Y) { count = count + 1 } } } Procedure someList(X) outList = [], newList = X while (length(newList) > 1) { outList = outList ++ [first(newList)] newList = rest(rest(newList)) } return(outList) End someList ```
Numerical
MEDIUM
4 marks
04 August 2024
21
If `A = [4, 3, 1, 3, 4, 5, 1, 2, 7]`, then what will the value of `B` be at the end of execution?
Comprehension
MEDIUM
4 marks
04 August 2024
22
If `A = [4, 3, 2, 4, 3, 5, 6, 7, 8, 6, 2]`, then what will the value of `B` be at the end of execution?
Comprehension
MEDIUM
4 marks
04 August 2024
23
What will the value of `mList` be at the end of execution of the pseudocode below? ``` L = [[10, 'apple', 5.0], [20, 'banana', 3.5], [30, 'cherry', 2.0], [40, 'date', 1.5], [50, 'elderberry', 4.0]] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a)) End DoSomething ```
Single correct
EASY
3 marks
24 March 2024
24
The following pseudocode is executed using the Words dataset and `explode(X)` returns letters in word `X` as a list. What will `count` represent at the end of execution? ``` count = 0, letterList = [] while (Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + processLetters(letterList) Move X to Table 2 } Procedure processLetters(L) prevLetter = first(L) restList = rest(L) foreach letter in restList { if (letter == prevLetter) { return(0) } prevLetter = letter } return(1) End processLetters ```
Single correct
MEDIUM
4 marks
24 March 2024
25
The following pseudocode is executed using the Words dataset. What will `count` represent at the end of execution? ``` count = 0 L = [] while (Table 1 has more rows) { Read the first row X in Table 1 L = addSomething(L, X) if (X.Word ends with a full stop) { if (length(L) >= 10) { count = count + 1 } L = [] } Move X to Table 2 } Procedure addSomething(M, Y) i = 1 while (i <= Y.LetterCount) { P = ith letter of Y.Word if (not member(M, P)) { M = M ++ [P] } i = i + 1 } return(M) End addSomething ```
Single correct
MEDIUM
4 marks
24 March 2024
26
We have a non-empty list `Publisher` storing publisher names sorted alphabetically. This results in duplicates. The following procedure attempts to extract the unique list of publishers while preserving sorted order. Identify all mistakes, if any. ``` uniqueList = [first(Publisher)] prev = last(Publisher) for each x in rest(Publisher) { if (x != prev) { uniqueList = uniqueList ++ x } prev = x } ```
Multiple correct
HARD
4 marks
24 March 2024
27
What will be the values of `mList` after execution of the following pseudocode? ``` L = [[1, 100, 'A'], [2, 99, 'B'], [3, 98, 'C'], [4, 97, 'D'], [5, 96, 'E']] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a) * 2) End DoSomething ```
Single correct
EASY
3 marks
03 December 2023
28
Alex and Elena play a game. Each round score is `[x, y]`, where `x` is Alex's score and `y` is Elena's score. The procedure `findGameWinner(S)` returns `winner = 1` if Alex wins, `winner = 2` if Elena wins, and `winner = 0` for a draw. Which procedure(s) correctly identify the winner?
Multiple correct
MEDIUM
5 marks
03 December 2023
29
Let `explode(W)` return the list of letters in word `W`. What will be the value of `count` at the end of execution? ``` count = 0 letterList = [] wordList = ["bookkeeper", "inspects", "things", "choose"] foreach word in wordList { letterList = explode(word) lastLetter = "" flag = False foreach letter in letterList { if (letter is a vowel and letter == lastLetter) { flag = True } lastLetter = letter } if (flag) { count = count + 1 } } ```
Numerical
MEDIUM
4 marks
03 December 2023
30
The given pseudocode is executed on the Words dataset. `C` stores the number of nouns which have at least one verb adjacent to it. Choose the correct code fragment to complete the pseudocode. ``` A = [] B = [] C = 0 while (Table 1 has more rows) { Read the first row X in Table 1 ******************** * Fill the code * ******************** Move X to Table 2 } foreach Y in B { if (member(A, Y - 1) or member(A, Y + 1)) { C = C + 1 } } ```
Single correct
MEDIUM
4 marks
03 December 2023
31
Based on the parent pseudocode, what will be the value of `M` at the end of execution?
Comprehension
MEDIUM
3 marks
03 December 2023
32
Based on the parent pseudocode, what will be the value of `MC` at the end of execution?
Comprehension
MEDIUM
3 marks
03 December 2023
33
The procedure below should build a list of serial numbers of specific parts of speech in the Words dataset. The procedure may have mistakes. Identify all mistakes, if any. ``` 1: Procedure BuildList(field) 2: L = {} 3: while (Table 1 has more rows) { 4: Read the first row X in Table 1 5: if (X.PartOfSpeech == field) { 6: L = L ++ [[X.SerialNumber, field]] 7: } 8: Move X to Table 2 9: } 10: return(field) 11: End BuildList 12: L1 = BuildList("Pronoun") 13: L2 = BuildList("Verb") ```
Multiple correct
MEDIUM
4 marks
03 December 2023
34
What will be the value of `mList` at the end of the given pseudocode? ``` L = [[1, 100, 'A'], [2, 99, 'B'], [3, 98, 'C'], [4, 97, 'D'], [5, 96, 'E']] mList = [] foreach element in L { z = DoSomething(element) mList = mList ++ [z] } Procedure DoSomething(X) a = rest(X) return(first(a)) End DoSomething ```
Single correct
EASY
2 marks
06 August 2023
35
The following pseudocode is executed using the Words dataset and `explode(X)` returns the list of letters in the word `X`. For example, `explode("sweet")` returns `['s', 'w', 'e', 'e', 't']`. What will `count` represent at the end of execution? ``` count = 0, letterList = [] while(Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + checkSomething(letterList) Move X to Table 2 } Procedure checkSomething(L) lastLetter = first(L) restList = rest(L) foreach letter in restList { if(letter == lastLetter) { return(1) } lastLetter = letter } return(0) End checkSomething ```
Single correct
MEDIUM
4 marks
06 August 2023
36
The following pseudocode is executed using the Words dataset. What will `count` represent at the end of execution? ``` A = 10000, count = 0 L = [] while(Table 1 has more rows) { Read the first row X in Table 1 L = addSomething(L, X) if(X.Word ends with a full stop) { if(length(L) == A) { count = count + 1 } if(length(L) < A) { A = length(L) count = 1 } L = [] } Move X to Table 2 } Procedure addSomething(M, Y) i = 1 while(i <= Y.LetterCount) { p = ith letter of Y.Word if(not(member(M, p))) { M = M ++ [p] } i = i + 1 } return(M) End addSomething ```
Single correct
MEDIUM
4 marks
06 August 2023
37
Let `LA` be a sorted list of integers in ascending order, and `X` be an integer. The procedure `insert(LA, X)` returns a list `LB` where `X` is added to `LA` such that `LB` remains sorted. The procedure may have mistakes. Identify all such mistakes, if any. ``` Procedure insert(LA, X) LB = [] flag = True foreach A in LA { if(flag) { if(X <= A) { LB = LB ++ [A] flag = False } } LB = LB ++ [A] } if(not flag) { LB = LB ++ [X] } return(LB) End insert ```
Multiple correct
HARD
5 marks
06 August 2023
38
We have a non-empty list `Location` that stores city names from the Scores dataset, sorted in alphabetical order. This results in many duplicates. The following procedure attempts to extract the unique list of cities while preserving sorted order. The pseudocode may have mistakes. Identify all such mistakes, if any. ``` uniqueList = [] uniqueList = uniqueList ++ [first(Location)] prev = last(Location) foreach x in rest(Location) { if(x != prev) { uniqueList = uniqueList ++ x } prev = x } ```
Multiple correct
MEDIUM
4 marks
06 August 2023
39
Alice and Bob play a coin-toss game. Each entry in `aList` is `[i, j]`, where `i` is Alice's outcome and `j` is Bob's outcome. Procedure `findWinner(aList)` should return `c`: `0` for Bob, `1` for Alice, and `2` for a draw. Which procedure correctly identifies the winner?
Multiple correct
MEDIUM
4 marks
06 August 2023
40
What will `flag` represent at the end of each sentence?
Comprehension
EASY
3 marks
06 August 2023
41
`wList` will contain all words of the last sentence of the Words dataset at the end of execution of the given pseudocode.
Comprehension
EASY
2 marks
06 August 2023
42
The value of `length(sList)` will be the same as the number of sentences in the Words dataset at the end of execution of the given pseudocode.
Comprehension
EASY
2 marks
06 August 2023
43
Consider the following pseudocode. At the end of execution, if `flag` has value `True`, choose the possible value of `L` from the choices. ``` flag = False position = 0 foreach element in L { if((position == 1) and (element == 'Y')) { flag = True } position = position + 1 } ```
Single correct
EASY
2 marks
02 April 2023
44
Consider the following procedure, where `L1` and `L2` are two non-empty lists. `findSomething(L1, L2)` will return `True` when: ``` Procedure findSomething(L1, L2) if(length(L1) != length(L2)) { return(False) } while(length(L1) > 0) { if(first(L1) != last(L2)) { return(False) } L1 = rest(L1) L2 = init(L2) } return(True) End findSomething ```
Single correct
MEDIUM
3 marks
02 April 2023
45
The following pseudocode is executed using the Words dataset and `explode(W)` returns the list of letters in word `W`. At the end of execution, `count` stores the number of words with at least two consecutive occurrences of the same letter. Choose the correct code fragment to complete the procedure. ``` count = 0, letterList = [] while(Table 1 has more rows) { Read the first row X in Table 1 letterList = explode(X.Word) count = count + consecute(letterList) Move X to Table 2 } Procedure consecute(L) lastLetter = first(L) restList = rest(L) *************** * Fill the code * *************** End consecute ```
Single correct
MEDIUM
4 marks
02 April 2023
46
Consider the procedure below, where `aList` is a non-empty list of real numbers. At the end of execution, which options are correct? ``` Procedure cumulative(aList) sum = 0, cumulList = [] foreach element in aList { sum = sum + element cumulList = cumulList ++ [sum] } return(cumulList) End cumulative ```
Multiple correct
EASY
4 marks
02 April 2023
47
Consider the procedure below. If `C = [3, 4, 1, 9, 5, 3, 1, 9]` and `B = doSomething(C)`, what will be the value of `first(B)`? ``` Procedure doSomething(A) outList = [last(A)] foreach X in A { if(X != last(outList)) { outList = [X] ++ outList } } return(outList) End DoSomething ```
Numerical
MEDIUM
3 marks
02 April 2023
48
Let `timeList` be a list of pairs containing information about trains associated with a station `stn`. Each element is `[Arrival, Departure]`. If arrival or departure time is empty, it is represented as "None". What does `count` represent at the end of execution? ``` count = 0 foreach x in timeList { if((first(x) != "None" and last(x) != "None")) { count = count + 1 } } ```
Single correct
MEDIUM
3 marks
20 November 2022
49
Let `explode(W)` return the list of letters in word `W`. What will `count` store at the end of execution? ``` count = 0, letterList = [] wordList = ["keep", "exploring", "and", "keep", "learning"] foreach word in wordList { letterList = explode(word) lastLetter = "", flag = False foreach letter in letterList { if(letter is a vowel and letter == lastLetter) { flag = True } lastLetter = letter } if(flag) { count = count + 1 } } ```
Single correct
MEDIUM
4 marks
20 November 2022
50
Consider the procedure below, where `aList` is a list of integers. Which options are correct at the end of execution? ``` procedure cumulative(aList) sum = 0, cumulList = [] foreach element in aList { sum = sum + element cumulList = cumulList ++ [sum] } return(cumulList) end cumulative ```
Multiple correct
MEDIUM
3 marks
20 November 2022
Showing 50 questions.