wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

untitled

Total questions: 52

Worksheet time: 27mins

Name
Class
Date
1.

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)

a) Prints all nodes of linked lists

b)

b) Prints all nodes of linked list in reverse order

c)

c) Prints alternate nodes of Linked List

d)

d) Prints alternate nodes in reverse order

2.

A series of values stored in memory is called ___

a)

an array

b)

a tree

c)

a matrix

d)

a struct

3.

In some languages, arrays are also called ___

a)

groups or arrows

b)

roots or leaves

c)

lists or vectors

d)

lines or strings

4.

Almost all programming languages start arrays at ___

a)

index 0

b)

index 1

c)

index 2

d)

the null character

5.

If a struct contains more than one pointer, what abstract data type is created?

a)

a queue

b)

a stack

c)

a tree

d)

a node

6.

In a tree data structure, any nodes that hang from other nodes are called ___

a)

branched nodes

b)

leaf nodes

c)

children nodes

d)

daughter nodes

7.

An important property of trees is that there’s a one-way path from ___

a)

branch to branch

b)

roots to leaves

c)

parent to daughter

d)

peak to trough

8.

In ___________ data structures all elements may or may not be of same type.

a)

linear

b)

non linear

c)

homogeneous

d)

non- homogeneous

9.

In ___________ data structure data items are not in sequence.

a)

non linear

b)

linear

c)

non-homogeneous

d)

all of above

10.

A function calls itself is called ___________.

a)

queue

b)

recursion

c)

function

d)

none of above

11.
A Kind of tree where every node in a tree can have at most two children.
a)
Binary Tree
b)
Binary Expression Tree
c)
Tree
d)
Binary Search Tree
12.

In preorder traversal of a binary tree the second step is ____________

a)

traverse the right subtree

b)

traverse the left subtree

c)

traverse right subtree and visit the root

d)

visit the root

13.
In this tree, where would the new value "7" be placed?
a)
On the left "leaf" of "4"
b)
On the right "leaf" of "6"
c)
On the left "leaf" of "15"
d)
Over the top of the current number "5"
14.

Which of these tree traversal methods is used to output the contents of a binary tree in ascending order?

a)

Pre-Order

b)

In-Order

c)

Post-Order

d)

Monastic Orders

15.

When traversing a binary tree, which diagram is post-order?

a)
b)
c)
16.

When traversing a binary tree, which diagram is pre-order?

a)
b)
c)
17.

A Data Structure is:

a)

A C++ vector

b)

A way of organizing, storing and performing operations on data.

c)

A function in any programming language

d)

A sequence of steps to solve a problem.

18.

Given a sequence of number below:

50,60,40,70,45,55,30,80,65,35,25,75,85


When creating a binary search tree, what is the height of the tree?

a)

3

b)

4

c)

5

d)

6

19.

Given a binary search tree, insert 27, 15, 63, 99, 70 and 85 (in this order) into the binary search tree. What is the post-order traversal?

a)

5,15,27,34,47,54,63,70,72,75,83,85,88,94,99,101

b)

72,54,34,5,27,15,47,63,70,83,75,88,85,101,94,99

c)

15,27,5,47,34,70,63,54,75,85,99,94,101,88,83,72

d)

15,27,5,47,34,63,54,70,75,85,99,94,101,88,83,72

e)

none of the above

20.
A Balanced Tree has equal number of items on each subtree.
a)
True
b)
False
21.
Root has more left descendants than the right descendants or vice versa.
a)
Balanced Tree
b)
Perfect Tree
c)
Right Tree
d)
Unbalanced Tree
22.

A binary search tree whose left subtree and right subtree differ in height by at most 1 unit is called

a)

AVL tree

b)

Red-black tree

c)

Lemma tree

d)

None of the above

23.

________is very useful in situation when data have to stored and then retrieved in reverse order.

a)

Stack

b)

Queue

c)

List

d)

Link list

24.

The disadvantage in using a circular linked list is __________

a)

it is possible to get into infinite loop

b)

last node points to fist node.

c)

time consuming

d)

requires more memory space.

25.

State true of false.

i) A node is a parent if it has successor nodes.

ii) A node is child node if out degree is one.

a)

True, True

b)

False, True

c)

True, False

d)

False, False

26.

A tree sort is also known as__________ sort.

a)

quick

b)

heap

c)

shell

d)

selection

27.

______________the condition indicate the queue is empty.

a)

Front=Null

b)

Null=Front

c)

Front=Rear

d)

Rear=Null

28.

TREE[1]=NULL indicates is _____________

a)

Overflow

b)

Empty

c)

Underflow

d)

Full

29.

A terminal node in a binary tree is called __________

a)

Root

b)

Branch

c)

Child

d)

Leaf

30.

If node N is a terminal node in a binary tree then its ________

a)

Right tree is empty

b)

Left tree is empty

c)

Both left & right sub trees are empty

d)

Root node is empty

31.

Consider the usual algorithm for determining whether a sequence of parentheses is balanced.

Suppose that you run the algorithm on a sequence that contains 2 left parentheses and 3 right parentheses (in some order).

The maximum number of parentheses that appear on the stack AT ANY ONE TIME during the computation?

a)

1

b)

2

c)

3

d)

4 or more

32.

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);

a)

Overflow Occurs

b)

Stack Operations will be performed Smoothly

c)

Underflow Occurs

d)

None of these

33.

What is the value of the postfix expression 6 3 2 4 + – *

a)

1

b)

40

c)

74

d)

-18

34.

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

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

a)

6,1

b)

5,7

c)

3,2

d)

1,5

35.

To evaluate an expression without any embedded function calls:

a)

One stack is enough

b)

Two stacks are needed

c)

As many stacks as the height of the expression tree are needed

d)

A Turing machine is needed in the general case

36.

What will be the postfix form of the above expression -

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

a)

None of these

b)

A B + C D ∗ E − F G ∗ / ∗

c)

A B + C D E ∗ − F G / ∗ ∗

d)

A B + C D ∗ E − F G / ∗ ∗

37.

Example of linear data structure except

a)

array

b)

tree

c)

queue

d)

stack

38.
What kind of Data structure would you expect to find utilised to store operations in a CPU?
a)
Stack
b)
Queue
c)
List
d)
Tree
39.

The number of edges from the node to the deepest leaf is called ___ of the tree.

a)

Height

b)

Depth

c)

Length

d)

Width

40.

What is a full binary tree?

a)

Each node has exactly zero or two children

b)

Each node has exactly two children

c)

All the leaves are at the same level

d)

Each node has exactly one or two children

41.

What is a complete binary tree?

a)

 Each node has exactly zero or two children

b)

A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left

c)

A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right

d)

A tree In which all nodes have degree 2

42.

Which of the following is not an advantage of trees?

a)

Hierarchical structure

b)

Faster search

c)

Router algorithms

d)

Undo/Redo operations in a notepad

43.

In a full binary tree if number of internal nodes is I, then number of leaves L are?

a)

L = 2*I

b)

L = I + 1

c)

L = I – 1

d)

L = 2*I – 1

44.

Any node is the path from the root to the node is called

a)

Successor node

b)

Ancestor node

c)

Internal node

d)

None of the above

45.

Which of the following options is not true about the Binary Search tree?

a)

The value of the left child should be less than the root node

b)

The value of the right child should be greater than the root node

c)

The left and right sub trees should also be a binary search tree

d)

None of the above

46.

What is the maximum number of children that a node can have in a binary tree?

a)

3

b)

1

c)

4

d)

2

47.

The maximum number of nodes in a binary tree of depth 5 is

a)

31

b)

16

c)

32

d)

15

48.

n elements of a Queue are to be reversed using another queue. The number of "ADD" and "REMOVE"operations required to do so is:

a)

2*n

b)

4*n

c)

n

d)

The task cannot be accomplished

49.

If two trees have same structure and but different node content,

then they are called

a)

Synonyms trees

b)

Joint trees

c)

Equivalent trees

d)

Similar trees

50.

If two trees have same structure and node content, then they are

called

a)

Synonyms trees

b)

Joint trees

c)

Equivalent trees

d)

Similar trees

51.

What should be the value of rear (end) if the queue is full (elements are completely occupied )?

a)

a. 1

b)

b. - 1

c)

c. MAX + 1

d)

d. MAX - 1

52.

Convert the following Infix expression to Postfix form using a stack

x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.

a)

a) xyz*+pq*r+s*+

b)

b) xyz*+pq*r+s+*

c)

c) xyz+*pq*r+s*+

d)

d) xyzp+**qr+s*+