Question 1
If n has 3, then the statement a[++n]=n++;
assigns 3 to a[5]
assigns 4 to a[5]
assigns 4 to a[4]
what is assigned is compiler dependent
Question 2
The output of the following program is
main()
{
static int x[] = {1,2,3,4,5,6,7,8}
int i;
for (i=2; i<6; ++i)
x[x[i]]=x[i];
for (i=0; i<8; ++i)
printf("%d", x[i]);
}
1 2 3 3 5 5 7 8
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
1 2 3 5 4 6 7 8
Question 3
The best data structure to check whether an arithmetic expression has balanced parenthesis is a
Queue
Stack
Tree
List
Question 4
Which of the following permutation can be obtained in the same order using a stack assuming that input is the sequence 5, 6, 7, 8, 9 in that order?
7, 8, 9, 5, 6
5, 9, 6, 7, 8
7, 8, 9, 6, 5
9, 8, 7, 5, 6
Question 5
If the sequence of operations - push (1), push (2), pop, push (1), push (2), pop, pop, pop, push (2), pop are performed on a stack, the sequence of popped out values
2,2,1,1,2
2,2,1,2,2
2,1,2,2,1
2,1,2,2,2
Question 6
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
A
B
C
D
Question 7
The five items: A, B, C, D, and E are pushed in a stack, one after other starting from A. The stack is popped four items and each element is inserted in a queue. The two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack. The popped item is
A
B
C
D
Question 8
The minimum number of stacks needed to implement a queue is
3
1
2
4
Question 9
A one dimensional array A has indices 1....75. Each element is a string and takes up three memory words. The array is stored at location 1120 decimal. The starting address of A[49] is
1267
1164
1264
1169
Question 10
In an array of 2N elements that is both 2-ordered and 3-ordered, what is the maximum number of positions that an element can be from its position if the array were 1-ordered?
1
2
N/2
2N-1
There are 57 questions to complete.