Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Quiz81-DS

Total questions: 45

Worksheet time: 26mins

Name
Class
Date
1.

The following postfix expression with single digit operands is evaluated using a stack:

              8 2 3 ^ / 2 3 * + 5 1 * - 

The top two elements of the stack after the first * is evaluated are:

 

a)

6, 1

b)

5, 7

c)

3, 2

d)

1

2.

Consider Stack is implemented using the array.

   #define MAX 10

    struct STACK

     {

    int arr[MAX];

    int top = ___________;

    }

What will be the initial value with which top is initialized?

 

a)

0

b)

-1

c)

Garbage 

d)

None

3.

User perform following operations on stack of size 5 then -

push(1); pop(); push(2); push(3); pop(); push(4); pop(); pop(); push(5);

at the end of last operation, total number of elements present in the stack are –

 

a)

3

b)

4

c)

2

d)

1

4.

User perform following operations on stack of size 5 then -

push(1); pop(); push(2); push(3); pop(); push(2); pop();

pop(); push(4); pop(); pop(); push(5);

Which of the following is correct statement for stack ?

a)

Stack Operations will be performed Smoothly

b)

Underflow Occurs

c)

Overflow Occurs

d)

None of these

5.

The post fix form of the expression

 (A+B)*(C*D-E)*F/G is

a)

AB+CD * E-FG/**

b)

AB+CD *E-F **G/

c)

AB+CD *E- *F*G/

d)

AB+CDE* -*F*G/

6.

In linked representation of stack the null pointer of the last node in the list signals ......

a)

Beginning of the stack

b)

Bottom of the stack

c)

Middle of the stack

d)

In between some value

7.

The five items: A, B, C, D, and E are pushed in a stack, one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then 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)

E

b)

B

c)

C

d)

D

8.

Using Pop (S1,Item) ,Push(S1, Item),  Getlist(Item), Pop(S2,Item), and the variables S1,S2(stacks with Top1 and Top2) and Item and given the input file: A,B,C,D,E,F Which stack are possible?

a)

All possible stacks with A,B,C,D,E and F

b)

No possible stacks with A,B,C,D,E and F

c)

Exact and only those stacks which can be produced with S1 alone

d)

Twice as many stacks as can be produced with S1 alone

9.

Process of Removing element from the stack is called as __________.

a)

pop

b)

 push

c)

delete

d)

remove

10.

What happens when you push a new node onto a stack?

a)

The new node is placed at the front of the linked list

b)

The new node is placed at the back of the linked list

c)

The new node is placed at the middle of the linked list

d)

No Changes happens

11.

The result of evaluating the post fix expression 10, 5, 4, +, *, 3, 9, 3, /,/ +  is?

a)

91

b)

90

c)

900

d)

93

12.

In liked representation of stack ....... holds the elements of the stack.

a)

INFO fields

b)

TOP fields

c)

LINK fields                        

d)

NULL fields

13.

How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.

a)

1

b)

2

c)

3

d)

4

14.

In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into a NONEMPTY queue?

a)

Only front pointer

b)

Only rear pointer 

c)

Both front and rear pointer

d)

None of the front and rear pointer

15.

Deletion operation is done using ......... in a queue.

a)

Front

b)

Rear

c)

Top

d)

List

16.

If the elements “E”, “F”, “G” and “H” are placed in a queue and are deleted one at a time, in what order will they be removed?

a)

EFGH 

b)

GHEF

c)

HGFE 

d)

EFHG

17.

In linked list implementation of queue, if only front pointer is maintained, which of the following operation take worst case linear time?

 

a)

Insertion

b)

 Deletion

c)

To empty a queue

d)

Both INSERTION and DELETION

18.

......... form of access is used to add and remove nodes from a queue.

a)

LIFO, Last In First Out    

b)

FIFO, First In First Out     

c)

Both a and b    

d)

None of these

19.

New nodes are added to the ......... of the queue.

a)

Front

b)

Last

c)

Middle

d)

Both A and B

20.

Deletion operation is done using ......... in a queue.

a)

Front

b)

Rear

c)

Top

d)

List

21.

……………. Is a pile in which items are added at one end and removed from the other.

a)

Stack        

b)

 Queue      

c)

 List        

d)

None of the above

22.

Which data structure allows deleting data elements at front and inserting at rear?

a)

Stacks           

b)

Queues              

c)

Dequeue             

d)

Binary search tree

23.

Identify the data structure which allows deletions at both ends of the list but insertion at only one end.

a)

Input restricted dequeue

b)

Output restricted qequeue

c)

Priority queues

d)

Stack

24.

………… is not the operation that can be performed on queue.

a)

Insertion

b)

Deletion

c)

Traversal

d)

None of these

25.

Which of the following is not the type of queue?

a)

Ordinary queue

b)

Single ended queue

c)

Circular queue

d)

Priority queue

26.

In the array implementation of circular queue, which of the following operation take worst case linear time?

a)

Insertion

b)

Deletion

c)

To empty a queue

d)

None

27.

A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.

a)

0

b)

7

c)

9

d)

10

28.

Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables,

respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are

a)

Full: (REAR+1) mod (n-1) == FRONT, empty: REAR == FRONT ==-1

b)

Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR

c)

Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT

d)

None of these

29.

If the MAX_SIZE is the size of the array used in the implementation of circular queue.

How is rear manipulated while inserting an element in the queue?

a)

rear=(rear%1)+MAX_SIZE

b)

rear=rear%(MAX_SIZE+1)

c)

rear=(rear+1)%MAX_SIZE

d)

rear=rear+(1%MAX_SIZE)

30.

If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index

start with 0, front point to the first element in the queue, and rear point to the last element in the queue.

Which of the following condition specify that circular queue is FULL?

a)

Front==rear= -1

b)

Front==(rear+1)%MAX_SIZE

c)

Rear==front+1

d)

Rear==(front+1)%MAX_SIZE

31.

If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index start with 0,

front point to the first element in the queue, and rear point to the last element in the queue.

Which of the following condition specify that circular queue is EMPTY?

a)

Front=rear=0

b)

Front= rear=-1

c)

Front=rear+1

d)

Front=(rear+1)%MAX_SIZE

32.

Let the following circular queue can accommodate maximum six elements with the following data

front = 2 rear = 4 queue = _______; L, M, N, ___, ___

What will happen after ADD O operation takes place?

a)

front = 2 rear = 5 queue = ______; L, M, N, O, ___

b)

front = 3 rear = 5 queue = L, M, N, O, ___

c)

front = 3 rear = 4 queue = ______; L, M, N, O, ___

d)

front = 2 rear = 4 queue = L, M, N, O, ___

33.

In a circular queue the value of r will be ..

a)

r=r+1

b)

r=(r+1)% [MAXSIZE – 1]

c)

r=(r+1)% MAXSIZE

d)

r=(r-1)% MAXSIZE

34.

A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The DELETION of next element takes place at the array index.

a)

0

b)

6

c)

7

d)

5

35.

void main()

{

      char str1[] = "abcd";

      char str2[] = "abcd";

      if(str1==str2)

            printf("Equal");

      else

            printf("Unequal");

}

 

a)

Equal

b)

Unequal

c)

Error

d)

None of these.

36.

If the two strings are identical, then strcmp() function returns

a)

1

b)

0

c)

-1

d)

True

37.

Which of the following function is more appropriate for reading in a multi-word string?

a)

scanf()

b)

gets()

c)

printf()

d)

puts()

38.

What will be the output of the program ?

#include<stdio.h>

#include<string.h>

void main()

{

    char str1[20] = "Hello", str2[20] = " World";

    printf("%s", strcpy(str2, strcat(str1, str2)));

}

a)

HelloWorld

b)

World

c)

WorldHello

d)

Hello

39.

What will be the output of the program ?

#include<stdio.h>

void main()

{

    printf(5+"Good Morning");

}

a)

Good Morning

b)

M

c)

Good

d)

Morning

40.

What will be the output of the program ?

#include<stdio.h>

void main()

{

char str[] = "Exam\0Glau";

printf("%s", str);

}

a)

Exam

b)

Exam Glau

c)

Exam\0Glau

d)

Glau

41.

Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

a)

arr[6]

b)

arr[7]

c)

arr{6}

d)

arr{7}

42.

What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");

a)

33

b)

-1

c)

1

d)

0

43.

String concatenation means -

a)

Combining two strings.

b)

Extracting a substring out of a string.

c)

Partitioning the string into two strings.

d)

Merging two strings.

44.

"My salary was increased by 15%" Select the statement, which will EXACTLY reproduce the line of text above.

a)

printf("My salary was increased by 15/%!");

b)

printf("My salary was increased by 15%!");

c)

printf("My salary was increased by 15'%'!");

d)

printf("My salary was increased by 15%%!");

45.

short testarray[4][3] = { {1}, {2,3}, {4,5,6}};

printf("%d", sizeof(testarray));

Assuming a short is two bytes long, what will be printed by the above code?

a)

6

b)

7

c)

12

d)

24