wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

dataStructure

Total questions: 14

Worksheet time: 7mins

Name
Class
Date
1.

The postfix expression of the infix expression a+b-c*d is

a)

abc-d*+

b)

abcd*-+

c)

abcd+-*

d)

+-*abcd

2.

The prefix expression of the infix expression a+b-c*d is

a)

abc-d*+

b)

abcd*-+

c)

abcd+-*

d)

+a-b*cd

3.

In a circular queue of size 7 if front index=5 and rear index =3 then ___ enqueue operations has been performed.

a)

5

b)

7

c)

11

d)

12

4.

In a circular queue of size 7 if front index=5 and rear index =3 then ___ dequeue operations has been performed.

a)

5

b)

7

c)

11

d)

12

5.

What does the following function do for a given Linked List with first node as head?

void fun1(struct node* head)

{

if(head == NULL)

return;

fun1(head->next);

printf("%d ", head->data);

}

a)

Prints all nodes of linked lists

b)

Prints all nodes of linked list in reverse order

c)

Prints alternate nodes of Linked List

d)

Prints alternate nodes in reverse order

6.

Which of the following points is/are true about Linked List data structure when it is compared with array

a)

Arrays have better cache locality that can make them better in terms of performance.

b)

It is easy to insert and delete elements in Linked List

c)

Random access is not allowed in a typical implementation of Linked Lists

d)

The size of array has to be pre-decided, linked lists can change their size any time.

e)

All the Above

7.

In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is

a)

log 2 n

b)

n/2

c)

log 2(n-1)

d)

n

8.

Which one of the following is an application of Stack Data Structure?

a)

Managing function calls

b)

The stock span problem

c)

Arithmetic expression evaluation

d)

All the above

9.

Let A be a square matrix of size n x n. Consider the following program. What is the expected output?

C = 100

for i = 1 to n do

for j = 1 to n do

{

Temp = A[i][j] + C

A[i][j] = A[j][i]

A[j][i] = Temp - C

}

for i = 1 to n do

for j = 1 to n do

Output(A[i][j]);

a)

The matrix A itself

b)

Transpose of matrix A

c)

Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of A

d)

None of the above

10.

O(1) means computing time is

a)

constant

b)

linear

c)

Quadratic

d)

cubic

11.

Sorting which works well for small set of datas are

a)

Quick sort

b)

Selection sort

c)

Merge Sort

d)

count sort

12.

In the following code, after the loop is terminated,ptr points to_________________?


ptr=start;

while(ptr!=NULL)

{

ptr=ptr->next;

}

a)

last node

b)

last but one done

c)

NULL

d)

none of the above

e)

I dont know

13.

In the following code, after the loop is terminated,ptr points to_________________?


ptr=start;

while(ptr->next!=NULL)

{

ptr=ptr->next;

}

a)

NULL

b)

last node

c)

last but one node

d)

none of the above

e)

I dont know

14.

What will be the output of the following code, if list contains 6 nodes?


ptr=start;

x=0;

while(ptr!=NULL)

{

x++;

ptr=ptr->next;

}

printf("x=%d",x);

a)

x=6

b)

x=5

c)

x=7

d)

I dont know