*Computational Thinking week 6 graded assignment Complete Solutions Are Discussed In This Blog. We Hope This Might Help You All In Matching Answers . Or For Some Others Reasons If Not Able To Complete Graded Assignments *

#### In the “Scores” table, let S be the list of sequence numbers of rows which have marks greater than 75 in at least one subject. What does the variable count represent at the end of the execution of the pseudocode given below?

`1`

`count = 0`

`2`

`while(Table 1 has more rows){`

`3`

` Read the first row X in Table 1`

`4`

` foreach c in S{`

`5`

` if (X.SeqNo == c){`

`6`

` if(X.Mathematics < 75 and X.Physics < 75){`

`7`

` count = count + 1`

`8`

` }`

`9`

` }`

`10`

` }`

`11`

` Move X to Table 2`

`12`

`}`

Number of students who have scored less than 75 in both Mathematics and Physics

Number of students who have scored more than 75 in Chemistry

Number of students who have scored less than 75 in both Mathematics and Physics, but more than 75 in Chemistry

Number of students who have scored less than 75 in all three subjects

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

Number of students who have scored less than 75 in both Mathematics and Physics, but more than 75 in Chemistry

*3 points*

#### 2. The following pseudocode is executed using the “Words” dataset. Assume that the rows in Table 1 are sorted in the increasing order of sequence number. What does the list L contain at the end of execution?

`1`

`L = []`

`2`

`A = "None"`

`3`

`Read the first row X in Table 1`

`4`

`A = X.PartOfSpeech`

`5`

`Move X to Table 2`

`6`

`while(Table 1 has more rows){`

`7`

` Read the first row X in Table 1`

`8`

` if(X.PartOfSpeech == "Noun"){`

`9`

` if(A == "Adjective"){`

`10`

` L = L ++ [X.Word]`

`11`

` }`

`12`

` }`

`13`

` A = X.PartOfSpeech`

`14`

` Move X to Table 2`

`15`

`}`

The list of nouns that come immediately after an adjective

The list of adjectives that come immediately after a noun

The list of nouns that come immediately before an adjective

The list of adjectives that come immediately before a noun

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

The list of nouns that come immediately after an adjective

*3 points*

3.We have a non-empty list called authList that stores the names of all authors in the “Library” table sorted in alphabetical order of author names. There is one element corresponding to each book in the table. This results in many duplicates. 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). It is a Multiple Select Question (MSQ).

`1`

`uniqueList = [], prev = "None"`

`2`

`uniqueList = uniqueList ++ first(authList)`

`3`

`prev = first(authList)`

`4`

`foreach x in rest(authList){`

`5`

` if(x == prev){`

`6`

` uniqueList = uniqueList ++ [x]`

`7`

` }`

`8`

` prev = x`

`9`

`}`

Error in line 1

Error in line 2

Error in line 3

Error in line 5

Error in line 8

No error

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

Error in line 2

Error in line 5

*4 points*

4. The procedure visitedShop returns the list of names of people who have visited a particular shop in the “Shopping Bills” dataset. It accepts the shop’s name as a parameter. Additionally, each customer must be represented exactly once in the returned list. The following pseudocode may have mistakes. Identify all such mistakes(if any). It is a Multiple Select Question (MSQ).

`1`

`Procedure visitedShop(shop)`

`2`

` S = "None"`

`3`

` while(Pile 1 has more cards){`

`4`

` Read the top card X from Pile 1`

`5`

` if(X.ShopName == shop){`

`6`

` if(not(member(S, X.CustomerName))){`

`7`

` S = S ++ [X.ShopName]`

`8`

` }`

`9`

` }`

`10`

` Move X to Pile 2`

`11`

` }`

`12`

` return(S)`

`13`

`End visitedShop`

`14`

` `

`15`

`Procedure member(L, name)`

`16`

` present = True`

`17`

` foreach x in L{`

`18`

` if(x == name){`

`19`

` present = True`

`20`

` exitloop`

`21`

` }`

`22`

` }`

`23`

` return(present)`

`24`

`End member`

Error in line 2

Error in line 6

Error in line 7

Error in line 16

Error in line 18

Error in line 19

No error

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

Error in line 2

Error in line 7

Error in line 16

Question – (5-6)

stations is a list that contains the sequence of stations visited by a train from the “Trains” dataset. Each element in stations is a list: [*Name*, *Distance*], the first entry is the name of the station, while the second entry is the distance of this station from the first station in the list.

minDist is a procedure that accepts stations as a parameter and returns the names of a pair of consecutive stations which have the shortest distance between them on this route. Complete the following procedure.

`1`

`Procedure minDist(stations)`

`2`

` pair = ["None", "None"]`

`3`

` min = 10000, diff = 0`

`4`

` prev = first(stations)`

`5`

` foreach x in rest(stations){`

`6`

` diff = last(x) - last(prev)`

`7`

` *************************`

`8`

` * Fill the code *`

`9`

` *************************`

`10`

` prev = x`

`11`

` }`

`12`

` return(pair)`

`13`

`End minDist`

*4 points*

5. There may be multiple pairs having the same minimum distance. If we wish to find a pair of stations closest to the first station in the list, which of the following is the correct code fragment?

`if(diff < min){`

` min = diff`

` pair = [first(prev), first(x)]`

`}`

`if(diff <= min){`

` min = diff`

` pair = [first(prev), first(x)]`

`}`

`if(diff < min){`

` min = diff`

` pair = [last(prev), last(x)]`

`}`

`if(diff <= min){`

` min = diff`

` pair = [last(prev), last(x)]`

`}`

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

`if(diff < min){ min = diff pair = [first(prev), first(x)] }`

*4 points*

6. There may be multiple pairs having the same minimum distance. If we wish to find a pair of stations closest to the last station in the list, which of the following is the correct code fragment?

`if(diff < min){`

` min = diff`

` pair = [first(prev), first(x)]`

`}`

`if(diff <= min){`

` min = diff`

` pair = [first(prev), first(x)]`

`}`

`if(diff < min){`

` min = diff`

` pair = [last(prev), last(x)]`

`}`

`if(diff <= min){`

` min = diff`

` pair = [last(prev), last(x)]`

`}`

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

`if(diff <= min){ min = diff pair = [first(prev), first(x)] }`

*4 points*

7. stns is a list that contains information about the sequence of stations visited by a train. Specifically, each element in this list is itself a list: [*Arrival*, *Departure*]. The first element in stns corresponds to the starting station for the train and the last element corresponds to the ending station for the train.

waitTime(arr, dep) is a procedure that accepts the arrival time and departure time of a train at a given station as input and returns the waiting time at that station in minutes.

We wish to find the average waiting time across all intermediate stations where the train stops and store this result in variable avg. The pseudocode may have mistakes. Identify all such mistakes (if any). It is a Multiple Select Question (MSQ).

`1`

`total = 0, count = 0, avg = 0`

`2`

`foreach x in init(rest(stns)){`

`3`

` total = total + waitTime(first(x), last(x))`

`4`

` count = count + 1`

`5`

`}`

`6`

`if(count != 0){`

`7`

` avg = total / count`

`8`

`}`

Error in line 2

Error in line 3

Error in line 4

Error in line 6

Error in line 7

No error

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

No error

Questions – (8 to 10)

trains is a list that contains information about trains associated with a station stn. Specifically, each element in this list is another list: [*Arrival*, *Departure*]. If the arrival or departure time is empty, it is represented as “None”.

`1`

`flag1 = False, flag2 = True`

`2`

`count = 0`

`3`

`foreach x in trains{`

`4`

` if(first(x) == "None" or last(x) == "None"){`

`5`

` flag1 = True`

`6`

` }`

`7`

` else{`

`8`

` count = count + 1`

`9`

` }`

`10`

`}`

`11`

`if(count == length(trains)){`

`12`

` flag2 = False`

`13`

`}`

*3 points*

#### 8. Which of the following statements about the variable flag1 is True at the end of execution of the above pseudocode?

It is True if and only if stn is a starting or ending station for at least one train in the list

It is False if and only if stn is a starting or ending station for at least one train in the list

It is True if and only if stn is a starting station for one train and ending station for some other train in the list

It is False if and only if stn is a starting station for one train and ending station for some other train in the list

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

It is True if and only if stn is a starting or ending station for at least one train in the list

*3 points*

#### 9. What does the variable count represent at the end of execution of the above pseudocode?

It is number of trains associated with stn

It is the number of trains for which stn is a starting station

It is the number of trains for which stn is an ending station

It is the number of trains for which stn is neither a starting nor an ending station

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

It is the number of trains for which stn is neither a starting nor an ending station

*4 points*

#### 10. At the end of execution of the code given above, what can be said about the values stored by the Boolean variables flag1 and flag2?

flag1 and flag2 always store the same value

flag1 and flag2 always store opposite values

flag1 always stores the value True

flag2 always stores the value True

There is no relationship between these two variables

### No, the answer is incorrect.

Score: 0

### Accepted Answers:

flag1 and flag2 always store the same value

Thanks for sharing. I read many of your blog posts, cool, your blog is very good.

Your point of view caught my eye and was very interesting. Thanks. I have a question for you.

Thanks for sharing. I read many of your blog posts, cool, your blog is very good.