Worksheetsuntitled
Total questions: 52
Worksheet time: 27mins
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
A series of values stored in memory is called ___
an array
a tree
a matrix
a struct
In some languages, arrays are also called ___
groups or arrows
roots or leaves
lists or vectors
lines or strings
Almost all programming languages start arrays at ___
index 0
index 1
index 2
the null character
If a struct contains more than one pointer, what abstract data type is created?
a queue
a stack
a tree
a node
In a tree data structure, any nodes that hang from other nodes are called ___
branched nodes
leaf nodes
children nodes
daughter nodes
An important property of trees is that there’s a one-way path from ___
branch to branch
roots to leaves
parent to daughter
peak to trough
In ___________ data structures all elements may or may not be of same type.
linear
non linear
homogeneous
non- homogeneous
In ___________ data structure data items are not in sequence.
non linear
linear
non-homogeneous
all of above
A function calls itself is called ___________.
queue
recursion
function
none of above
In preorder traversal of a binary tree the second step is ____________
traverse the right subtree
traverse the left subtree
traverse right subtree and visit the root
visit the root
Which of these tree traversal methods is used to output the contents of a binary tree in ascending order?
Pre-Order
In-Order
Post-Order
Monastic Orders
When traversing a binary tree, which diagram is post-order?
When traversing a binary tree, which diagram is pre-order?
A Data Structure is:
A C++ vector
A way of organizing, storing and performing operations on data.
A function in any programming language
A sequence of steps to solve a problem.
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?
3
4
5
6
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?
5,15,27,34,47,54,63,70,72,75,83,85,88,94,99,101
72,54,34,5,27,15,47,63,70,83,75,88,85,101,94,99
15,27,5,47,34,70,63,54,75,85,99,94,101,88,83,72
15,27,5,47,34,63,54,70,75,85,99,94,101,88,83,72
none of the above
A binary search tree whose left subtree and right subtree differ in height by at most 1 unit is called
AVL tree
Red-black tree
Lemma tree
None of the above
________is very useful in situation when data have to stored and then retrieved in reverse order.
Stack
Queue
List
Link list
The disadvantage in using a circular linked list is __________
it is possible to get into infinite loop
last node points to fist node.
time consuming
requires more memory space.
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.
True, True
False, True
True, False
False, False
A tree sort is also known as__________ sort.
quick
heap
shell
selection
______________the condition indicate the queue is empty.
Front=Null
Null=Front
Front=Rear
Rear=Null
TREE[1]=NULL indicates is _____________
Overflow
Empty
Underflow
Full
A terminal node in a binary tree is called __________
Root
Branch
Child
Leaf
If node N is a terminal node in a binary tree then its ________
Right tree is empty
Left tree is empty
Both left & right sub trees are empty
Root node is empty
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?
1
2
3
4 or more
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);
Overflow Occurs
Stack Operations will be performed Smoothly
Underflow Occurs
None of these
What is the value of the postfix expression 6 3 2 4 + – *
1
40
74
-18
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
6,1
5,7
3,2
1,5
To evaluate an expression without any embedded function calls:
One stack is enough
Two stacks are needed
As many stacks as the height of the expression tree are needed
A Turing machine is needed in the general case
What will be the postfix form of the above expression -
(A+B)∗(C∗D-E)∗F/G
None of these
A B + C D ∗ E − F G ∗ / ∗
A B + C D E ∗ − F G / ∗ ∗
A B + C D ∗ E − F G / ∗ ∗
Example of linear data structure except
array
tree
queue
stack
The number of edges from the node to the deepest leaf is called ___ of the tree.
Height
Depth
Length
Width
What is a full binary tree?
Each node has exactly zero or two children
Each node has exactly two children
All the leaves are at the same level
Each node has exactly one or two children
What is a complete binary tree?
Each node has exactly zero or two children
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from right to left
A binary tree, which is completely filled, with the possible exception of the bottom level, which is filled from left to right
A tree In which all nodes have degree 2
Which of the following is not an advantage of trees?
Hierarchical structure
Faster search
Router algorithms
Undo/Redo operations in a notepad
In a full binary tree if number of internal nodes is I, then number of leaves L are?
L = 2*I
L = I + 1
L = I – 1
L = 2*I – 1
Any node is the path from the root to the node is called
Successor node
Ancestor node
Internal node
None of the above
Which of the following options is not true about the Binary Search tree?
The value of the left child should be less than the root node
The value of the right child should be greater than the root node
The left and right sub trees should also be a binary search tree
None of the above
What is the maximum number of children that a node can have in a binary tree?
3
1
4
2
The maximum number of nodes in a binary tree of depth 5 is
31
16
32
15
n elements of a Queue are to be reversed using another queue. The number of "ADD" and "REMOVE"operations required to do so is:
2*n
4*n
n
The task cannot be accomplished
If two trees have same structure and but different node content,
then they are called
Synonyms trees
Joint trees
Equivalent trees
Similar trees
If two trees have same structure and node content, then they are
called
Synonyms trees
Joint trees
Equivalent trees
Similar trees
What should be the value of rear (end) if the queue is full (elements are completely occupied )?
a. 1
b. - 1
c. MAX + 1
d. MAX - 1
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) xyz*+pq*r+s*+
b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+
d) xyzp+**qr+s*+
