Week 5 - Graded Assignment 5 - (Sep 2025 - CT - Qualifier)

The due date for submitting this assignment has passed. Due on 2025-10-31, 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-10-30, 21:54 IST


Question 1

What will be the value of mList at the end of the execution of the given pseudocode?

xxxxxxxxxx

1

L = [[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]

2

mList = []

3

foreach element in L{

4

    mList = mList ++ [last(element)]

5

}
  • [0, 210, 1, 198, 2, 188, 3, 173, 4, 240]
  • [0, 1, 2, 3, 4]
  • [[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]
  • [210, 198, 188, 173, 240]

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

Accepted Answers:

  • [210, 198, 188, 173, 240]

Question 2

What will be the value of mList at the end of the execution of the given pseudocode?

xxxxxxxxxx 1 L = [[0, 210, 78], [1, 198, 91], [2, 188, 77], [3, 173, 78], [4, 240, 89]] 2 mList = [] 3 foreach element in L{ 4 mList = mList ++ [last(init(element))] 5 }

  • [0, 210, 1, 198, 2, 188, 3, 173, 4, 240]
  • [0, 1, 2, 3, 4]
  • [[0, 210], [1, 198], [2, 188], [3, 173], [4, 240]]
  • [210, 198, 188, 173, 240]

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

Accepted Answers:

  • [210, 198, 188, 173, 240]

Question 3

Let N be a list of first 50 positive integers (i.e., N = [1, 2, 3, …, 49, 50]). What will be the value of count at the end of the execution of the given pseudocode? (NAT)

xxxxxxxxxx

1

count = 0

2

A = someList(N)

3

B = someList(rest(N))

4

foreach Y in A{

5

    foreach Z in B{

6

        if(Z == Y){

7

            count = count + 1

8

        }

9

    }

10

}

11

Procedure someList(X)

12

    outlist = [], newList = X

13

    while(length(newList) > 0){

14

        outlist = outlist ++ [first(newList)]

15

        newList = rest(rest(newList))

16

    }

17

    return(outlist)

18

End someList

Your Answer: 0

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

Accepted Answers:

(Type: Numeric) 0


Question 4

Choose the correct options(s) regarding L. It is a Multiple Select Question (MSQ).

  • It will contain all the elements of L2 that are not present in L1
  • It will contain all the elements of L1 that are not present in L2
  • It will contain all the elements common to L1 and L2
  • It will contain the elements present in L1 or L2 but not both

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

Accepted Answers:

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

Question 5

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

  • length(L1) - length(L2) = Length(L)
  • length(L1) > length(L2)
  • length(L1) >= length(L)
  • length(L2) length(L)

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

Accepted Answers:

  • length(L1) >= length(L)

Question 6

A word is said to be perfect if no letter is repeated. Let isPerfect be a procedure that takes a row X in the “Words” table as input and returns True if the word in row X is a perfect word otherwise returns False. Choose the correct implementation of the procedure isPerfect.

  • xxxxxxxxxx 1 Procedure isPerfect(X) 2 C = [] 3 i = 1 4 while(i <= X.LetterCount){ 5 A = ith letter in X.Word 6 if(member(C,A)){ 7 return(False) 8 } 9 else{ 10 return(True) 11 } 12 i = i + 1 13 } 14 End isPerfect
  • xxxxxxxxxx 1 Procedure isPerfect(X) 2 C = [] 3 i = 1 4 while(i <= X.LetterCount){ 5 A = ith letter in X.Word 6 if(member(C,A)){ 7 return(False) 8 } 9 else{ 10 C = C ++ [A] 11 } 12 i = i + 1 13 } 14 return(True) 15 End isPerfect
  • xxxxxxxxxx 1 Procedure isPerfect(X) 2 C = [] 3 i = 1 4 while(i <= X.LetterCount){ 5 A = ith letter in X.Word 6 if(member(C,A)){ 7 C = C ++ [A] 8 } 9 else{ 10 return(False) 11 } 12 i = i + 1 13 } 14 return(True) 15 End isPerfect
  • xxxxxxxxxx 1 Procedure isPerfect(X) 2 C = [] 3 i = 1 4 while(i <= X.LetterCount){ 5 A = ith letter in X.Word 6 if(member(C,A)){ 7 return(True) 8 } 9 else{ 10 C = C ++ [A] 11 } 12 i = i + 1 13 } 14 return(False) 15 End isPerfect

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

Accepted Answers:

  • Procedure isPerfect(X) C = [] i = 1 while(i <= X.LetterCount){ A = ith letter in X.Word if(member(C,A)){ return(False) } else{ C = C ++ [A] } i = i + 1 } return(True) End isPerfect

Question 7

The given pseudocode is executed using a dataset having the same fields as the “Words” dataset, and contains the following words -

“I ordered this product from Gitark. I am very happy to share my review regarding this awesome product. It is not only nice to use, but also has a very cool look. I think this is the best product which can be bought in this price range. ”

Consider the following information:

1. unique(L) returns a list of unique elements of list L. For example unique([“think”, “like”, “toppers”, “think”]) will return [“think”, “like”, “toppers”].

2. comNo(L1, L2) returns the number of common elements in lists L1 and L2.

3. Ignore the upper and lower case, and punctuation symbols while comparing with other words

xxxxxxxxxx

1

positiveList = [“happy”, “awesome”, “nice”, “fine”, “best”, “cool”]

2

posSen = 0, L = []

3

while(Table 1 has more rows){

4

    Read the first row X in Table 1

5

    L = L ++ [X.Word]

6

    if(X.Word ends with full stop){

7

        L = unique(L)

8

        posCount = comNo(positiveList, L)

9

        if(posCount >= 2){

10

            posSen = posSen + 1

11

        }

12

        L = []

13

    }

14

    Move X to Table 2

15

}

What will be the value of posSen at the end of the execution of the above pseudocode? Your Answer: 2

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

Accepted Answers:

(Type: Numeric) 2


Question 8

Mona tells Sona that at least 50 percent of sentences have nouns just after an adjective. Sona writes the following pseudocode to find if Mona is right or not. At the end of the execution of the pseudocode given below, A stores True if Mona is right otherwise False. But Sona might have made mistakes in one or more lines. Identify such lines (if any). It is a Multiple Select Question (MSQ). Assume that there is at least one adjective in every sentence.

xxxxxxxxxx

1

A = False, trueCount = 0, totalCount = 0, posList = []

2

while(Table 1 has more rows){

3

    Read the first row X in Table 1

4

    posList = posList ++ [X.PartOfSpeech]

5

    if(X.Word ends with a full stop){

6

        if(isTrue(posList) == 0){

7

            trueCount = trueCount ++ [1]

8

        }

9

        else{

10

            totalCount = totalCount + 1

11

        }

12

        posList = []

13

    }

14

    Move X to Table 2

15

}

16

if(trueCount / totalCount >= 0.5){

17

    A = True

18

}

19

20

Procedure isTrue(L)

21

    count = 0

22

    while(length(L) >= 2){

23

        if(first(L) == "Adjective"){

24

            count = count + 1

25

            if(first(rest(L)) == "Noun"{

26

                count = count - 1

27

            }   

28

        }

29

        L = rest(L)

30

    }

31

    return(count)

32

End isTrue
  • Line 4: Invalid addition operation for appending in posList
  • Line 7: Invalid increment of trueCount
  • Line 9 - 11: These three lines should be replaced by xxxxxxxxxx 1 totalCount = totalCount + 1
  • Line 26: The current statement should be replaced by xxxxxxxxxx 1 count = count + 1
  • No mistakes

Accepted Answers:

  • Line 7: Invalid increment of trueCount
  • Line 9 - 11: These three lines should be replaced by

totalCount = totalCount + 1


Question 9

When will procedure doSomething(X) return True?

  • X is a prime number
  • X is an even number
  • X is an odd number
  • X is more than 1

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

Accepted Answers:

  • X is a prime number

Question 10

Consider the procedure discussed above. What will be the value of M at the end of the execution of the given pseudocode below?

xxxxxxxxxx

1

L = [6, 10, 11, 23, 7, 50]

2

M = []

3

position = 1

4

foreach element in L{

5

    if(doSomething(position) and doSomething(element)){

6

        M = M ++ [element]

7

    }

8

    position = position + 1

9

}
  • M = [11, 7]
  • M = [11, 23, 7]
  • M = [11]
  • M = [23, 7]

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

Accepted Answers:

  • M = [11, 7]