0% found this document useful (0 votes)
34 views17 pages

W6 Practice

Uploaded by

joyaljeslinsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views17 pages

W6 Practice

Uploaded by

joyaljeslinsa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Week-6, Practice

Week-6, Practice
Question-1 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
(e)
Answer
Question-2 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-3 [4 Marks]
Statement
Options
(a)
(b)
(c)
(d)
(e)
Answer
Question-4 [4 Marks]
Statement
Options
(a)
(b)
(c)
(d)
(e)
(f)
Answer
Question-(5 to 6) [6 Marks]
Statement
Question-5 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-6 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-(7 to 8)
Statement
Question-7 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-8 [2 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-(9 to 11)
Statement
Question-9 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-10 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
Answer
Question-11 [3 Marks]
Statement
Options
(a)
(b)
(c)
(d)
(e)
(f)
Answer

Question-1 [3 Marks]
Statement
The following pseudocode is executed on the "Scores" table. What will A represent at the end of
the execution? It is a Multiple Select Questions (MSQ).

1 A = 0, S = []
2 while(Table 1 has more rows){
3 Read the first row X in Table 1
4 if(X.CityTown == "Madurai" or X.Gender == "F"){
5 S = S ++ [X.SeqNo]
6 }
7 Move X to Table 2
8 }
9 A = length(S)

Options
(a)

Number of female students from Madurai

(b)

(Number of female students) + (Number of students from Madurai)

(c)

(Number of female students) + (Number of students from Madurai) - (Number of female students
from Madurai)

(d)

(Number of female students) + (Number of male students from Madurai)

(e)

(Number of female students not from Madurai) + (Number of students from Madurai)

Answer
(c), (d), (e)
Question-2 [3 Marks]
Statement
topMath and topPhy are lists of cards having Mathematics marks and Physics marks greater
than 80 respectively. Each element in both lists is a record. The fields in the record are the same
as the ones in the header of the "Scores" table. What will the list someList represent at the end
of the execution of the pseudocode given below?

1 someList = []
2 foreach X in topMath{
3 foreach Y in topPhy{
4 if(X.SeqNo == Y.SeqNo and X.Chemistry > 80){
5 someList = someList ++ [X.Name]
6 }
7 }
8 }

Options
(a)

It stores the names of students who have scored above 80 in Chemistry

(b)

It stores the names of students who have scored above 80 in both Mathematics and Physics

(c)

It stores the names of students who have scored above 80 in at least one subject

(d)

It stores the names of students who have scored above 80 in all three subjects

Answer
(d)
Question-3 [4 Marks]
Statement
We call two sentences similar if both of them have the same number of words and satisfy the
following conditions:

The ith word in the first sentence has the same part of speech as the ith word in the second
sentence, for 1 <= i <= L, where L is the total number of words in either sentence.
aList and bList are lists that contain the part of speech of words in two sentences A and B
respectively.
isSimilar is a procedure that accepts these two lists as parameters and checks for the
similarity of A and B.

Select the correct code fragment to complete the pseudocode.

1 Procedure isSimilar(aList, bList){


2 if(length(aList) != length(bList)){
3 return(False)
4 }
5 cList = bList
6 *************************
7 * Fill the code *
8 *************************
9 End isSimilar

Options
(a)

1 foreach x in aList{
2 if(x == first(cList)){
3 return(True)
4 }
5 cList = init(cList)
6 }

(b)

1 foreach x in aList{
2 if(x != first(cList)){
3 return(False)
4 }
5 cList = init(cList)
6 }
(c)

1 foreach x in aList{
2 if(x != first(cList)){
3 return(False)
4 }
5 cList = rest(cList)
6 }

(d)

1 foreach x in aList{
2 if(x != first(cList)){
3 return(False)
4 }
5 cList = rest(cList)
6 }
7 return(False)

(e)

1 foreach x in aList{
2 if(x != first(cList)){
3 return (False)
4 }
5 cList = rest(cList)
6 }
7 return(True)

Answer
(e)
Question-4 [4 Marks]
Statement
For a given train, we have a list called days that contains the sequence of entries contained in the
column Day in the "Trains" dataset. As an example, for the train "12281", days will be the
following list of integers: [1, 1, 1, 1, 2, 2].

Madhuram is a passenger who boards this train at its starting station and gets down at its ending
station. He has a peculiar habit of treating himself to exactly one sweet at midnight whenever he
is on a train. Which of the following expressions gives the number of "midnight sweets" that he
consumes during the course of his journey? It is a Multiple Select Question (MSQ).

Options
(a)

last(days) - first(days)

(b)

last(days) - first(days) + 1

(c)

last(init(days)) - first(rest(days))

(d)

length(days)

(e)

last(days) - 1

(f)

length(days) - 1

Answer
(a), (e)
Question-(5 to 6) [6 Marks]
Statement
trainList is a non-empty list that contains information about all trains associated with a station.
Each element in trainList is a list of running days for a train. For example, given a station that
handles two trains, we could have [ ["M", "W"], ["Sa"] ]. Assume that all the elements of trainList
are non-empty lists. Consider the following pseudocode.

1 m = 0, tu = 0, w = 0, th = 0, fr = 0, sa = 0, su = 0
2 foreach x in trainList{
3 foreach y in x{
4 if (y == "M"){
5 m = 1
6 }
7 if (y == "Tu"){
8 tu = 1
9 }
10 if (y == "W"){
11 w = 1
12 }
13 if (y == "Th"){
14 th = 1
15 }
16 if (y == "F"){
17 f = 1
18 }
19 if (y == "Sa"){
20 sa = 1
21 }
22 if (y == "Su"){
23 su = 1
24 }
25 }
26 }

The above pseudocode is executed on the trainList for some arbitrary station. After execution,
we run the following code.

1 someVar = 0
2 someVar = 7 - (m + tu + w + th + f + sa + su)
Question-5 [3 Marks]
Statement
What does the variable someVar store at the end of execution?

Options
(a)

It stores the number of days in a week when at least one train visits the station

(b)

It stores the number of days in a week when no train visits the station

(c)

It stores the number of trains that visit the station in a week

(d)

It does not store anything meaningful

Answer
(b)
Question-6 [3 Marks]
Statement
Which of the following is an accurate bound for the variable someVar?

Options
(a)

0 <= someVar <= 7

(b)

0 < someVar <= 7

(c)

0 <= someVar < 7

(d)

0 < someVar < 7

Answer
(c)
Question-(7 to 8)
Statement
The following pseudocode is executed using the "Words" dataset. Assume that the rows in the
table are sorted in the ascending order of sequence number.

1 start = True
2 outList = []
3 while(Table 1 has more rows){
4 Read the first row X in Table 1
5 if(start){
6 inList = []
7 start = False
8 }
9 inList = inList ++ [[X.Word, X.PartOfSpeech]]
10 if(X.Word ends with a full stop){
11 outList = outList ++ [inList]
12 start = True
13 }
14 Move X to Table 2
15 }
Question-7 [3 Marks]
Statement
At the end of execution, which of the following statements are true about the variable outList? It
is a Multiple Select Question (MSQ).

Options
(a)

Each element in outList corresponds to one sentence from the paragraph

(b)

Each element in outList corresponds to one word from the paragraph

(c)

Each element in outList corresponds to one character from the paragraph

(d)

outList is a list of lists

Answer
(a), (d)
Question-8 [2 Marks]
Statement
Which of the following statements are true about the variable start during the course of the
execution of the above pseudocode? It is a Multiple Select Question (MSQ).

Options
(a)

The variable start is set to False at the last word of every sentence

(b)

The variable start is set to True at the last word of every sentence

(c)

The variable start is set to False at the first word of every sentence

(d)

The variable start is set to True at the first word of every sentence

Answer
(b), (c)
Question-(9 to 11)
Statement
We take the variable outList obtained at the end of execution of the pseudocode in the previous
question. Now, we execute the following pseudocode.

1 someVar = 0, count = 0, i = 0
2 foreach x in outList{
3 someVar = someVar + length(x)
4 foreach y in x{
5 if (last(y) == "Noun"){
6 count = count + 1
7 }
8 }
9 i = i + 1
10 }
Question-9 [3 Marks]
Statement
What does the variable count store at the end of execution?

Options
(a)

It is the number of nouns in the paragraph

(b)

It is the number of nouns in the first sentence of the paragraph

(c)

It is the number of sentences in the paragraph that begin with a noun

(d)

None of the above

Answer
(a)
Question-10 [3 Marks]
Statement
What does the variable someVar store at the end of execution?

Options
(a)

It is the number of words in the paragraph

(b)

It is the number of sentences in the paragraph

(c)

It is the number of characters in the paragraph

(d)

None of the above

Answer
(a)
Question-11 [3 Marks]
Statement
Which of the following statements are true about the variable i at the end of execution? It is a
Multiple Select Question.

Options
(a)

It is the number of words in the paragraph

(b)

It is the number of sentences in the paragraph

(c)

It is equal to the number of elements in outList

(d)

It is equal to the number of elements in inList

(e)

It is equal to length(outList)

(f)

It is the number of characters in the paragraph

Answer
(b), (c), (e)

You might also like