Question
1
What happens when the following statement is used? DELETE (‘JEAN COOK EVANS’, 6, 5)
JEAN OOK ANS
|
|
JEAN EVANS
|
|
JEANCANS
|
|
None
|
|
Question
2
What happens when the following statements are used? INSERT (‘AAAAA’, 3, ‘BBB’) INSERT (‘AAAAA’, 1, ‘BBB’) INSERT (‘AAAAA’, 7, ‘BBB’)
AABBBAAA, (II) ABBBAAAA, (III) Nothing
|
|
AABBBAAA, (II) BBBAAAAA, (III) Nothing
|
|
AABBBAAA, (II) ABBBAAAA, (III) AAAAA BBB
|
|
AABBBAAA, (II) BBBAAAA, (III) Nothing
|
|
Question
3
Following is a Pseudocode:
1 Set K:= 1 and MAX:= S - R + 1
2 Repeat Steps 3 to 5 while K <= MAX:
3 Repeat for L = 1 to R:
4 If P[L] <> T[K + L – 1], then:
5 Set INDEX = K, and Exit.
6 Set K:= K + 1. [End of Step 2 outer loop]
7 Set INDEX = 0
8 Exit
Where P and T are strings with lengths R and S, respectively, and are stores as list with one character per element. What should be added to the above algorithm to make it run?
L is not getting incremented, so the line Set L:= L + 1
|
|
MAX should have MAX: = S + R - 1
|
|
‘Go to Step 6’ line is missing.
|
|
Nothing
|
|
Question
4
Following is a Pseudocode:
1 Set NUM:= 0 and BLANK:= ‘□ □ □ □ □’
2 Set K:= 2
3 Repeat Steps 4 and 5 while K <= N - 1 If SUBSTRING(LINE[K], 1, 5) = BLANK, then: Set NUM:= NUM +1. [End of If structure]
6 Set K:= K + 1
7 Return
What is missing in the code above? Note that N is a variable.
The if structure should be If SUBSTRING (LINE [K], J, N) = BLANK
|
|
Nothing
|
|
K should be initialized to K:= 1
|
|
K <= N –1 should be replaced by K < N - 1
|
|
Question
5
What is the following Pseudocode doing?
1 Set ITEM:= LIST[P]
2 Repeat for J = P to N – 1: Set LIST[J]:= LIST[J+1] [End of Step 2 loop]
6 Set N:= N - 1
7 Exit
Where LIST is a Linear list with N elements and P is a positive integer such that P <= N.
Copies from one linear list to another
|
|
Deletes an element in the Pth position
|
|
Sets the value of LIST to the highest value
|
|
None
|
|
Question
6
Following is a Flowchart. What will be printed when the following values are passed to the flowchart?

X = 150 and Y = 75X = 90 and Y = 50X = 40 and Y = 80X = 10 and Y = 120
“GOOD”, 50, 80, 120
|
|
“GOOD”, Nothing, Nothing, 120
|
|
“GOOD”, 90, 40, 120
|
|
Nothing, Nothing, Nothing, 120
|
|
Question
7
Following is a series of numbers? 2, 4, 6, 8, 10, 12, 14, 12, 10, 8, 6, 4, 2 Which is the flowchart that prints such a series?
Question
8
Following is a Flowchart. What series will be generated and printed by this flowchart?

2, 1, 3, 3, 6
|
|
none
|
|
2, 1, 3, 3
|
|
2, 1, 3, 6, 9
|
|
Question
9
Following is a sequence of numbers stored in a list ARRAY: 12, 54, 89, 67, 45, 77, 34, 99
If this pseudocode is run on this list ARRAY what would be sequence of the numbers as the output:
1 Repeat Steps 2 and 3 for K = 1 to N - 1
2 Set PTR:= 1
3 Repeat while PTR <= N-K: If ARRAY[PTR] > ARRAY[PTR + 1], then: Change ARRAY[PTR] with ARRAY[PTR + 1] [End of If structure] Set PTR:= PTR + 1 [End of inner loop] [End of Step 1 outer loop]
4 Exit
Note that N is a variable.
12, 34, 45, 54, 67, 77, 89, 99
|
|
12, 34, 54, 45, 67, 77, 89, 99
|
|
99, 89, 77, 67, 45, 54, 34, 12
|
|
99, 89, 77, 67, 54, 45, 34, 12
|
|
Question
10
Following is a Sequence of numbers stored in a list ARRAY: 32, 51, 27, 85, 66, 23, 13, 57
If this list has to be sorted in ascending order, how many comparisons would be required for this output? 13, 23, 27, 32, 51, 57, 66, 85
|
|