CS301 Data Structures
Solved MCQs
For
a perfect binary tree of height h, having N nodes, the sum of heights of nodes
is _____________.
N
– (h – 1)
N – (h + 1)
N – 1
N – 1 + h
If we want to find median of 50 elements, then after applying buildHeap method, how many times deleteMin method will be called ?
5
25
35
50
N – (h + 1)
N – 1
N – 1 + h
If we want to find median of 50 elements, then after applying buildHeap method, how many times deleteMin method will be called ?
5
25
35
50
Which
of the following heap method increase the value of key at position ‘p’ by the
amount ‘delta’?
increaseKey(p,delta)
decreaseKey(p,delta)
preculateDown(p,delta)
remove(p,delta)
www.vuzs.net
The main reason of using heap in priority queue is
improve performance
code is readable
less code
heap can't be used in priority queues
decreaseKey(p,delta)
preculateDown(p,delta)
remove(p,delta)
www.vuzs.net
The main reason of using heap in priority queue is
improve performance
code is readable
less code
heap can't be used in priority queues
The
total number of nodes on 10th level of a perfect binary tree are :
256
512
1024
Can't be determined
Which property of equivalence relation is satisfied if we say: Ahmad R(is related to) Ahmad
512
1024
Can't be determined
Which property of equivalence relation is satisfied if we say: Ahmad R(is related to) Ahmad
Reflexivity
Symmetry
Transitivity
All of the above
Which of the following heap method lowers the value of key at position ‘p’ by the amount ‘delta’?
Symmetry
Transitivity
All of the above
Which of the following heap method lowers the value of key at position ‘p’ by the amount ‘delta’?
increaseKey(p,delta)
decreaseKey(p,delta)
preculateDown(p,delta)
remove(p,delta)
We can build a heap in _____ time.
decreaseKey(p,delta)
preculateDown(p,delta)
remove(p,delta)
We can build a heap in _____ time.
Linear
Exponential
Polynomial
None of the given options
we can build a heap in linear time using n calls of percolate_down()
Exponential
Polynomial
None of the given options
we can build a heap in linear time using n calls of percolate_down()
If a tree has 50 nodes, then the total edges/links in the tree will be :
CS301- Data Structure-Current-Solved-MCQs-2-1-2012
Consider
a max heap, represented by the following array; 40,30,20,10,15,16,17,18,4 After
inserting a nodes with value 35.Which of following is the updated max heap?
40,30,20,10,15,16,17,8,4,3540,30,20,10,35,16,17,8,4,15
40,35,20,10,30,16,17,8,4,15
40,35,20,10,15,16,17,18,4,30
A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a Link) ___________Successor.
Preorder
Inorder
Postorder
Leveloder
Which of the following is a property of binary tree?
A Binary tree with N internal nodes has 2+N links, N-1 links to internal nodes and N+1 links to external nodes
A Binary tree with N internal nodes has 2*N links, N-1 links to internal nodes and N+1 links to external nodes.
A Binary tree with N internal nodes has 2-N links, N-1 links to internal nodes and N+1 links to external nodes.
A Binary tree with N internal nodes has 2N links, N+1 links to internal nodes and N-1 links to external nodes.
A Threaded Binary tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link)_____________ successor.
Preoder
Inorder
Postorder
Levelorder
If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?
54
55
56
57
Which of the following statement is correct?
A threaded Binary tree is a binary tree in which every node that does not have a left child has a THREAD (in actual sense, a link) to its INORDER successor.
A threaded Binary tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its PREORDER successor.
A threaded Binary tree is a binary tree in which every node that does not have a left child has a THREAD (in actual sense, a link) to its INORDER successor.
A threaded Binary tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its POSTORDER predecessor.
It is necessary fro Huffman encoding tree to be,
AVL tree
Binary tree
Complete binary Tree
None of these
A binary tree with 45 internal nodes has _________ links to external nodes.
44
45
46
90
In which of the following tree, parent nodes has key greater than or equal to its both children?
Max heap
Binary search tree
Threaded Binary tree
Complete Binary tree
If one pointer of the nodes in a binary tree is NULL then it will be a/an
Inner node
Leaf node
External node
Root node
If there are N external nodes is a binary tree then what will be the no. of the internal nodes in this binary tree?
N-1
N
N+1
N+2
See the below code and fill the appropriate answer for? Void fastlnorder(TreeNod+p) {while((p+nextInorder(p)) !+ ? ) cout << p->getInfo();}
Dummy
rootNode
LTH
RTH
In threaded binary tree, the NULL pointer are replaced by the.
Preorder successor or Predecessor
Inorder successor or predecessor
Postorder successor or predecessor
NULL pointer are not replaced
In which of the following tree, parent nodes has a key greater than or equal to its both children?
Max heap
Binary search tree
Threaded Binary three
Complete Binary tree
In Complete binary tree the bottom level is filled from _______.
Left to right
Right to left
Not filled at all
None of the given options
If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a ________
Complete Binary tree
Threaded Binary Tree
Expression tree
Perfectly compete Binary tree
If an expression tree is correct then its root should have,
An operator
(
)
an operand
In threaded binary tree, the NULL pointers are replaced by the.
Preorder successor or predecessor
Inorder successor or predecessor
Postorder successor or predecessor
NULL pointer are not replaced
A complete binary tree is a tree that is ________ filled, with the possible exception of the bottom level.
Partially
Completely
Incompletely
Partly
If the bottom level of a binary tree is not completely filled, depicts that the tree is not a _________.
Expression tree
Threaded binary tree
Complete binary tree
Perfectly complete binary tree
An expression tree will always be a,
Complete binary tree
Binary search tree
Heap AVL tree
Which of the following is a property of binary tree?
A binary tree of N external nodes has N internal node
A Binary tree of N internal nodes has N+1 external node
A Binary tree of N external nodes has N+1 internal node
A Binary tree of N internal has N-1 external node
In a threaded binary tree which nodes have NULL child pointers,
All leaf nodes
Nodes other then leaf nodes
Root Node
None of the nodes
preorder successor or predecessor
inorder successor or predecessor
postorder successor or predecessor
NULL pointers are not replaced
A complete binary tree is a tree that is _______ filled, with the possible exception of the bottom level.
partially
completely
incompletely
partly
Which one of the following is TRUE about iteration?
Iterative function calls consumes a lot of memory
Threaded Binary Trees use the concept of iteration
Iteration extensively uses stack memory
Recursion is more efficient than iteration
We implement the heap by ____________ .
Threaded Tree
AVL tree
Complete binary tree
Expression
Which of the following statement concerning heaps is NOT true?
Traversing a heap in order provides access to the data in numeric or alphabetical order.
Removing the item at the top provides immediate access to the key value with highest (or lowest) priority.
Inserting an item is always done at the end of the array, but requires maintaining the heap property.
A heap may be stored in an array.
Which of the following statement concerning heaps is NOT true?
A heap can be stored in a binary search tree.
A heap can be stored in an array.
A heap can be used to implement a priority queue.
A heap can be used to sort data.
A complete binary tree is a tree that is _________ filled, with the possible exception of the bottom level.
partially
completely
incompletely
partly
By using __________we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.
Binary tree only
Heap data structure
Huffman encoding
Which of the following statement is true about dummy node of threaded binary tree?
The left pointer of dummy node points to the itself while the right pointer points to the root of tree.
The left pointer of dummy node points to the root node of the tree while the right pointer points itself i.e. to dummy node.
The left pointer of dummy node points to the root node of the tree while the right pointer is always NULL.
The right pointer of dummy node points to the itself while the left pointer is always NULL.
Threaded binary tree
When a complete binary tree, represented by an array then for any array element at position i, the parent is at position ______ .
2i-1
2i
2i+1
floor(i/2)
When a complete binary tree represented by an array then if right child is at position 5 then left child will be at position _____
2
3
4
6
A binary tree with N internal nodes has _____ links, _______ links to internal nodes and ________ links to external nodes.
2N, N-1, N+1
N-1, 2N, N+1
N+1, 2N, N-1
N+1, N-1, 2N
If a binary tree has N + 1 external nodes then,
It has N internal nodes.
It has N-1 internal nodes.
It has N/2 internal nodes.
It has N+2 internal nodes.
A binary tree with 45 internal nodes has _______links to external nodes.
44
45
46
90
Consider a binary tree, represented by the following array: 10,7,9,5,2,1,6,3,4 This is a ________.
Min heap
Max heap (Not Sure)
Threaded binary tree
Binary Search tree
Consider a binary tree, represented by the following array: A,B,C,D,E,F,G,I Is it a strictly binary tree ?
Yes
No
In threaded binary tree the NULL pointers are replaced by the
preorder successor or predecessor
inorder successor or predecessor
inorder successor or predecessor
NULL pointers are not replaced
Consider a binary tree, represented by the following array: A,B,C,D,E,F,G,H,I,J,K,L Is it a strictly binary tree?
Yes
No
We implement the heap by ______________ .
Threaded Tree
AVL tree
Complete binary tree
Expression
If there are 56 internal nodes in a binary tree then how many external nodes this binary tree will have?
► 54
► 55
► 56
► 57
Which of the following statements is correct property of binary trees?
► A binary tree with N internal nodes has N+1 internal links.
► A binary tree with N external nodes has 2N internal nodes.
► A binary tree with N internal nodes has N+1 external nodes.
► None of above statement is a property of the binary tree.
Which of the following is a property of binary tree?
► A binary tree of N external nodes has N internal node.
► A binary tree of N internal nodes has N+ 1 external node.
► A binary tree of N external nodes has N+ 1 internal node.
► A binary tree of N internal nodes has N- 1 external node.
Which of the following statement is true about dummy node of threaded binary tree?
► The left pointer of dummy node points to the itself while the right pointer points to the root of tree.
► The left pointer of dummy node points to the root node of the tree while the right pointer points itself i.e. to dummy node
► The left pointer of dummy node points to the root node of the tree while the right pointer is always NULL.
► The right pointer of dummy node points to the itself while the left pointer is always NULL.
If the bottom level of a binary tree is NOT completely filled, depicts that the tree is NOT a
► Expression tree
► Threaded binary tree
► complete Binary tree
► Perfectly complete Binary tree
Which of the following statement is correct about find(x) operation:
► A find(x) on element x is performed by returning exactly the same node that is found.
► A find(x) on element x is performed by returning the root of the tree containing x.
► A find(x) on element x is performed by returning the whole tree itself containing x.
► A find(x) on element x is performed by returning TRUE.
If there are 23 external nodes in a binary tree then what will be the no. of internal nodes in this binary tree?
► 23
► 2
► 21
► 22
f there are N external nodes in a binary tree then what will be the no. of internal nodes in this binary tree?
► N -1
► N+1
► N+2
► N
Which of the following statement is correct?
► A Threaded Binary Tree is a binary tree in which every node that does not have a left child has a THREAD (in actual sense, a link) to its INORDER
successor.
► A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its PREOREDR successor.
► A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its INORDER successor.
► A Threaded Binary Tree is a binary tree in which every node that does not have a right child has a THREAD (in actual sense, a link) to its POSTORDER successor.
By using __________we avoid the recursive method of traversing a Tree, which makes use of stacks and consumes a lot of memory and time.
► Binary tree only
► Threaded binary tree
► Heap data structure
► Huffman encoding
Consider a min heap, represented by the following array:
10,30,20,70,40,50,80,60
After inserting a node with value 31.Which of the following is the updated min heap?
► 10,30,20,31,40,50,80,60,70
► 10,30,20,70,40,50,80,60,31
► 10,31,20,30,40,50,80,60,31
► 31,10,30,20,70,40,50,80,60
In complete binary tree the bottom level is filled from ________.
► Left to right
► Right to left
► Not filled at all
► None of the given options
In case of deleting a node from AVL tree, rotation could be prolong to the root node.
► Yes
► No
When an array of object is created dynamically then there is no way to provide parameterized constructors for array of objects.
True
Flase
Which of the following method is helpful in creating the heap at once?
Insert
add
update
preculateDown
MIDTERM
EXAMINATION
Spring 2010
CS301- Data Structures
Question No: 1 ( Marks: 1 ) - Please choose one
A
queue where the de-queue operation depends not on FIFO, is called a priority
queue
► False
► True (Page
101)
Question No: 2 ( Marks: 1 ) - Please choose one
The
data of the problem is of 2GB and the hard disk is of 1GB capacity, to solve
this problem we should
►
Use better data structures
► Increase the hard disk space (Page 5)
►
Use the better algorithm
►
Use as much data as we can store on the hard
disk
Question No: 3 (
Marks: 1 ) - Please choose one
Consider
the function X as under
int X
(int& Value)
{
return Value;
}
}
Now a
and b are integers in a calling function. Which one of the following is a valid
call to the above function
X.
►
a = X (b) ;
► a = X (&b) ;
► a = X (*b) ;
► a = X (&b) ;
► a = X (*b) ;
►
None of the given
options
Here function argument passing by reference method is
used, so when we call a function we will give the variable reference as parameter.
Question No: 4 ( Marks: 1 ) - Please choose one
In the
call by value methodology, a copy of the object is passed to the called
function.
► False
► True (Page
202)
Question No: 5 ( Marks: 1 ) - Please choose one
The tree data structure is a
► Linear data structure
► Linear data structure
► Non-linear data structure (Page 112)
►
Graphical data structure
►
Data structure like
queue
Question No: 6 ( Marks: 1 ) - Please choose one
When
should you use a const
reference parameter?
►
Whenever the parameter
has huge size.
► Whenever the parameter has huge size, the
function changes the parameter within its body, and you do NOT want these changes to alter the
actual argument.
► Whenever the parameter has huge size, the function changes the parameter
within its body, and you DO want these changes to alter the actual argument.
►
Whenever the parameter
has huge size, and the function does not change the parameter within its body.
Declaring
a parameter as a const simply means that the function can’t change the value of
its parameters.
Question No: 7 (
Marks: 1 ) - Please choose one
Here
is the start of a C++ class declaration:
class foo
class foo
{
public:
void
x(foo f);
void
y(const foo f);
void z(foo f) const;
void z(foo f) const;
Which of the three member functions can alter the PRIVATE
member variables of the foo object that activates the function?
► Only
x can alter the private member variables of the object that activates the
function.
► Only y can alter the private member variables of the object that activates the function.
► Only z can alter the private member variables of the object that activates the function.
► Only y can alter the private member variables of the object that activates the function.
► Only z can alter the private member variables of the object that activates the function.
► Two of the functions can alter the private
member variables of the object that activates the function.
Only the x and y can alter the private member variable of
the foo class object. Last Option is more correct but not exact. In the last
option the two function name are not mentioned
Question No: 8 (
Marks: 1 ) - Please choose one
What
is the maximum depth of recursive calls a function may make?
►
1
►
2
►
n (where n is the
argument)
► There is no fixed maximum
► There is no fixed maximum
Question No: 9 (
Marks: 1 ) - Please choose one
Suppose n is the number of nodes in a complete Binary
Tree then maximum steps required for a search operation are,
► Log2 (n+1) -1 (Page 139)
►
Log2 (n+1)
► Log2 (n) - 1
► Log2 (n)
► Log2 (n) - 1
► Log2 (n)
Question No: 10 ( Marks: 1 ) - Please choose one
In the linked list implementation of the stack class,
where does the push member function places the new entry on the linked list?
► At
the head (Page 53)
►
At the tail
► After
all other entries that are greater than the new entry.
► After all other entries that are smaller than the new entry.
► After all other entries that are smaller than the new entry.
Question No: 11 (
Marks: 1 ) - Please choose one
Suppose we have a circular
array implementation of
the queue class, with ten items in the queue stored at data[2] through data[11]. The CAPACITY
is 42, i.e., the array has been declared to be of size 42. Where does the push member function place the
new entry in the array?
►
data[1]
►
data[2]
► data[11]
► data[12]
► data[11]
► data[12]
Question No: 12 (
Marks: 1 ) - Please choose one
The
expression AB+C* is called?
►
Prefix expression
► Postfix expression (Page 70)
►
Infix expression
► None of these
► None of these
Question No: 13 (
Marks: 1 ) - Please choose one
_________ is a binary tree where every node has a value,
every node's left subtree contains only values less
than or equal to the node's value, and every node's right subtree contains only values that are greater then or
equal?
than or equal to the node's value, and every node's right subtree contains only values that are greater then or
equal?
►
Strictly Binary Tree
► Binary Search tree Click here for detail
►
AVL tree
► All of these
► All of these
Question No: 14 (
Marks: 1 ) - Please choose one
Consider
the following binary search tree (BST):
If
node A in the BST is deleted, which two nodes are the candidates to take its
place?
►
J and I
► H and E
► D and E
► L and M
► H and E
► D and E
► L and M
Question No: 15 (
Marks: 1 ) - Please choose one
Let’s
call the node as that requires re-balancing. Consider the two cases given
below:
1) An
insertion into left sub tree of the left child of a
2) An
insertion into right sub tree of the right child of a.
Which
of the following statement is correct about these two cases?
1) The insertion occurs outside (i.e., left-left or
right-right) in cases 1 and 2 single rotation can fix the balance in these two cases.
2) The insertion occurs inside ((i.e., left-left or
right-right) in cases 1 and 2. single rotation cannot fix the balance in these two cases
Question No: 16 (
Marks: 1 ) - Please choose one
We
access elements in AVL Tree in,
►
Linear way only
►
Non Linear way only
►
Both linear and non
linear ways
► None of the given options.
► None of the given options.
Question No: 17 ( Marks: 2 )
AVL
Tree is,
► Non Linear data structure Click here for
detail
►
Linear data structure
► Hybrid
data structure (Mixture of Linear and Non Linear) ► None of the given options.
MIDTERM
EXAMINATION
Spring 2010
Question No: 1 (
Marks: 1 ) - Please choose one
Which
one of the following statement is NOT correct .
► In linked list
the elements are necessarily to be contiguous Click here for
detail
► In linked list
the elements may locate at far positions in the memory ► In linked list each element also has the next to it
►
In an array the elements
are contiguous
Question No: 2 (
Marks: 1 ) - Please choose one
Each
operator in a postfix expression refers to the previous ________ operand(s).
►
One
►
Two (Page 67)
► Three
► Three
►
Four
Question No: 3 (
Marks: 1 ) - Please choose one
Which one of the following calling methods does not
change the original value of the argument in the calling function?
►
None of the given
options
►
Call by passing the value of the argument
► Call
by passing reference of the argument
► Call by passing the address of the argument
► Call by passing the address of the argument
Question No: 4 (
Marks: 1 ) - Please choose one
A
tree is an AVL tree if
►
Any one node fulfills the
AVL condition
►
At least half of the
nodes fulfill the AVL condition
► All the nodes fulfill the AVL condition (Page 213)
►
None of the given options
Question No: 5 (
Marks: 1 ) - Please choose one
Suppose currentNode refers to a node in a linked list
(using the Node class with member variables called data and nextNode). What
statement changes currentNode so that it refers to the next node?
►
currentNode ++;
►
currentNode = nextNode;
► currentNode += nextNode;
► currentNode += nextNode;
►
currentNode = currentNode->nextNode;
Question No: 6 ( Marks: 1 ) - Please choose one
A
queue where the de-queue operation depends not on FIFO, is called a priority
queue
► False
► True (Page
101)
Question No: 7 ( Marks: 1 ) - Please choose one
Which
one is a self- referential data type?
►
Stack
►
Queue
► Link list
► Link list
► All of these Click here for
detail
Question No: 8 ( Marks: 1 ) - Please choose one
Each
node in doubly link list has,
►
1 pointer
► 2 pointers (Page
39)
►
3 pointers
► 4 pointers
► 4 pointers
Question No: 9 (
Marks: 1 ) - Please choose one
I have implemented the queue with a linked list, keeping
track of a front pointer and a rear pointer. Which of these pointers will change during an
insertion into an EMPTY
queue?
►
Neither changes
►
Only front pointer
changes.
► Only rear pointer changes.
► Both change.
► Only rear pointer changes.
► Both change.
Question No: 10 (
Marks: 1 ) - Please choose one
Consider
the following tree.
How
many of the nodes have at least one sibling?
►
8
► 7
► 5
► 7
► 5
►
6
A
sibling is an element that shares the same parent with another element
Question No: 11 (
Marks: 1 ) - Please choose one
The
nodes with no successor are called _________
►
Root Nodes
►
Leaf Nodes
► Both of these
► None of these
► Both of these
► None of these
Question No: 12 ( Marks: 1 ) - Please choose one
AVL
Tree is,
► Non Linear data structure Click here for
detail
► Linear
data structure
► Hybrid
data structure (Mixture of Linear and Non Linear) ► None of the given options.
Question No: 13 (
Marks: 1 ) - Please choose one
We
access elements in AVL Tree in,
►
Linear way only
►
Non Linear way only
►
Both linear and non
linear ways
► None of the given options.
► None of the given options.
Question No: 14 (
Marks: 1 ) - Please choose one
A
binary search tree should have minimum of one ________ node/s at each level,
► One
► Two Click here for
detail
►
Three
► Four
► Four
Question No: 15 (
Marks: 1 ) - Please choose one
Consider the following statements.
(i) A
binary tree can contain at least 2L Nodes at level L.
(ii) A complete binary
tree of depth d is a binary tree that contains 2L Nodes at each level
L between 0 and d,
both inclusive.
both inclusive.
(iii) The total number of nodes (Tn ) in a complete
binary tree of depth d is 2 d+1 - 1 .
(iv) The height of the complete binary tree can be written as h
= log 2 (Tn+1)-1
where Tn is Total number of
Nodes.
Nodes.
Which one of the following is correct in respect of the above statements
regarding the Binary trees?
►
(i) and
(iii) only
►
(i),
(ii) and (iii) only
► (ii) and (iii) only
► (ii) and (iii) only
► (ii), (iii) and (iv) only Click here for detail
Question No: 16 ( Marks: 1 ) - Please choose one
“+”
is a _________operator.
►
Unary
► Binary (Page
64)
►
Ternary
►
None of the above
MIDTERM
EXAMINATION
Spring 2010
Question No: 1 (
M a r k s: 1 )
A
subscript of an array may be an integer or an integer expression.
►
True Click here for
detail
►
False
Question No: 2 (
M a r k s: 1 )
Doubly
Linked List always has one NULL pointer.
► True
► False (Page
43)
Question No: 3 (
M a r k s: 1 )
In
which of the traversal method, the recursive calls can be used to traverse a
binary tree ?
► In preorder
traversal only (Page 143)
► In inorder traversal only
► In postorder traversal only
► All of the given options
► All of the given options
Question No: 4 ( M a r k s: 1 )
A
tree is an AVL tree if
► Any
one node fulfills the AVL condition
► At
least half of the nodes fulfill the AVL condition
► All the nodes fulfill the AVL condition (Page
213)
►
None of the given options
Question No: 5 (
M a r k s: 1 )
Suppose currentNode refers to a node in a linked list
(using the Node class with member variables called data and nextNode). What
boolean expression will be true when cursor refers to the tail node of the
list?
►
(currentNode == null)
►
(currentNode->nextNode == null)
► (nextNode.data == null)
► (nextNode.data == null)
► (currentNode.data
== 0.0)
Question No: 6 ( M a r k s: 1 ) -
Please choose one
Suppose that the class declaration of SomeClass includes
the following function prototype. bool LessThan( SomeClass anotherObject );
Which
of the following tests in the client code correctly compares two class objects
alpha and beta?
► if
(alpha < beta)
► if (alpha.LessThan(beta)) Click here for
detail
► if
(LessThan(alpha, beta))
► if (LessThan(alpha).beta)
► if (LessThan(alpha).beta)
Question No: 7 ( M a r k s: 1 )
In C what is the operation that you can not do with
primitive types? ► Assign a value to primitive type using a literal
►
Declare primitive types to be constant using the Const keyword
►
Create a new instance of primitive type with New keyword Click here for
Detail
►
None of these
Question No: 8 ( M a r k s: 1 )
The operation for adding an entry to a stack is
traditionally called : ► add
►
append
► insert
► insert
► push (Page
53)
Question No: 9 (
M a r k s: 1 )
The operation for removing an entry from a stack is
traditionally called: ►
delete
►
peek
► pop (Page
53)
►
remove
Question No: 10 ( M a r k s: 1 )
Consider
the following sequence of push operations in a stack:
stack.push(’7’);
stack.push(’8’);
stack.push(’9’);
stack.push(’10’);
stack.push(’11’);
stack.push(’12’);
stack.push(’9’);
stack.push(’10’);
stack.push(’11’);
stack.push(’12’);
►
7 8 9 10 11 12
► 9 8
11 10 7 12
► 9 10 8 11 12 7
► 9 10 8 12 7 11
► 9 10 8 11 12 7
► 9 10 8 12 7 11
Question No: 11 ( M a r k s: 1 )
________ is the maximum number of nodes that you can have
on a stack-linked list ? ►
Zero
► 2n
(where n is the number of nodes in linked list)
►
Any Number Click here for
detail
►
None of these
Question No: 12 ( M a r k s: 1 )
Which
of the following can be used to reverse a string value,
►
Stack Click here for
detail
►
Queue
►
Both of these
► None of these
► None of these
Question No: 14 ( M a r k s: 1 )
AVL
Tree is,
► Non Linear data structure Click here for
detail
►
Linear data structure
► Hybrid data structure (Mixture of Linear and Non
Linear) ► None of the given options.
Question No: 15 ( M a r k s: 1 )
The
following are statements related to queues.
(i) The last item to be added to a queue is
the first item to be removed (ii) A queue is a structure in
which both ends are not used
(iii) The last element hasn’t to wait until all elements
preceding it on the queue are removed (iv)A queue is said to be a
last-in-first-out list or LIFO data structure.
Which
of the above is/are related to normal queues?
► (iii) and (ii) only
► (iii) and (ii) only
►
(i), (ii) and (iv) only
► (ii) and (iv) only
► (ii) and (iv) only
►
None of the given options Click
here for detail
Question No: 16 ( M a r k s: 1 )
An
array is a group of consecutive related memory locations.
► True Click here for
detail
►
False
MIDTERM
EXAMINATION
Spring 2010
Question
No: 1 ( Marks: 1 ) - Please choose one
In an array we can store data elements of different types.
►
True
► False (Page
7)
Question
No: 2 ( Marks: 1 ) - Please choose one
In an array list the current element is
► The first element Click here for detail
►
The
middle element
► The last element
► The last element
►
The
element where the current pointer points to
Question
No: 3 ( Marks: 1 ) - Please choose one
Which one of the following calling
methods does not change the original value of the argument in the calling
function? ►
None of
the given options
► Call by passing the
value of the argument Click
here for detail
►
Call by
passing reference of the argument
►
Call by
passing the address of the argument
Question
No: 4 ( Marks: 1 ) - Please choose one
Which one of the following statements is NOT correct?
► Array size can be changed after its
creation. Click here for
detail
► Link List size can be changed after its creation
► Link List size can be changed after its creation
► Binary Search Tree size can be changed after
its creation ►
AVL
Tree size can be changed after its creation
Question
No: 5 ( Marks: 1 ) - Please choose one
Suppose that the class declaration of
SomeClass includes the following function prototype. bool LessThan( SomeClass anotherObject );
Which
of the following tests in the client code correctly compares two class objects
alpha and beta?
►
if
(alpha < beta)
► if
(alpha.LessThan(beta)) Click here for
detail
►
if
(LessThan(alpha, beta))
►
if
(LessThan(alpha).beta)
Question
No: 6 ( Marks: 1 ) - Please choose one
A queue is a----- data structure, whereas a stack is a -----data structure.
► FIFO, LIFO (Page
161,54)
►
LIFO,FIFO
► none of these
► both of these
► none of these
► both of these
Question
No: 7 ( Marks: 1 ) - Please choose one
Which one of the following operators has higher priority than all of
others?
► Multiplication
operator Click here for
detail
►
Minus
operator
►
Plus
operator
►
Exponentiation
operator
Question
No: 8 ( Marks: 1 ) - Please choose one
Each node in Binary Search Tree has
►
1
pointer
► 2 pointers Click here for detail
►
3
pointers
► 4 pointers
► 4 pointers
Question
No: 9 ( Marks: 1 ) - Please choose one
Four statements about trees are below. Three of them are correct. Which
one is INCORRECT?
►
Trees
are recursively defined multi-dimensional data structures tree
► The order of a tree indicates a maximum
number of children allowed at each node of the ► A search tree is a special type of tree where
all values (i.e. keys) are ordered
► If Tree1's size is greater than Tree2's size, then the
height of Tree1
must
also be greater than Tree2's height.
Click here for detail
Click here for detail
Question
No: 10 ( Marks: 1 ) - Please choose one
Which of the following is "TRUE" about arrays,
►
We can
increase the size of arrays after their creation.
►
We can
decrease the size of arrays after their creation.
►
We can
increase but can't decrease the size of arrays after their creation.
►
We can neither increase nor decrease the array size after their creation. Click here for
detail
Question
No: 11 ( Marks: 1 ) - Please choose one
Searching an element in an AVL tree take maximum in AVL tree,
►
Log2(n+1)
time (where n is no. of nodes
► Log2(n+1) -1
► Log2(n+1) -1
► 1.44 Log2n (Page 227)
►
1.66
Log2n
Question
No: 12 ( Marks: 1 ) - Please choose one
There is/are case/s for rotation in an AVL tree,
► 1
► 1
►
3
► 2
► 2
► 4 (Page
229)
Question
No: 13 ( Marks: 1 ) - Please choose one
Consider the following statements.
(i) A binary tree can contain at least 2L Nodes at level L.
(ii) A complete binary tree of depth d
is a binary tree that contains 2L Nodes at each level L between 0 and d, both inclusive.
(iii) The total number of nodes (Tn ) in a complete binary tree of depth d is 2 d+1 - 1 .
(iv) The height of the complete binary
tree can be written as h = log 2 (Tn+1)-1 where Tn is Total number of Nodes.
Which
one of the following is correct in respect of the above statements regarding
the Binary trees?
►
(i) and
(iii) only
►
(i),
(ii) and (iii) only
► (ii) and (iii) only
► (ii) and (iii) only
► (ii), (iii) and (iv) only Click here for detail
Question
No: 14 ( Marks: 1 ) - Please choose one
Consider the following infix expression.
5 + 6/2
5 + 6/2
If one converts the above expression into postfix, what would be the
resultant expression?
►
56/ + 2
► 5 6 2 / + (Page
66)
►
5 6 / 2
+
► /62 + 5
► /62 + 5
Question
No: 15 ( Marks: 1 ) - Please choose one
Which of the following is a non linear data structure?
►
Linked
List
►
Stack
►
Queue
► Tree (Page
112)
Question
No: 16 ( Marks: 1 ) - Please choose one
“+” is a operator.
“+” is a operator.
►
Unary
► Binary (Page
64)
►
Ternary
►
None of
the above
MIDTERM
EXAMINATION
Spring 2010
1. Addition of new items in stack make the pointer ------------ by 2
a. Increment, bits
b. Increment, bytes
c. Decrement, bits
d. Decrement, bytes Click here for
detail
2. Next item in a linked list is known as
a. Index
b. Item
c. Node Click here for
detail
d. Child
3. What will be the postfix notation of 5+6/2.
a. 56+/2
b. 562+/
c. 562/+ (Page 66)
d. 5+62/
4. In an AVL tree to
delete a parent with two childs in a straight line following rotations will be
required:-
a. Single
b.
Double
c. Triple
d. None.
5. To check the depth of an AVL tree following time will be taken:-
a. 1.66
Log2n
b. 1.44 Log2n (Page
227)
c. Log2 (n+1)-1
d. 1.66
Log2n (n+1)
6. BST is a Structure:-
a. Linear
b. Non Linear
c. Circular
d. None of Above
7. After creation of an array:-
a. Size can be increase but can not be decreased.
b. Size can be decreased but can not be increased.
c.
Size can neither be increased nor be decreased.
Click here for
detail
d. Size can be increased and can also be decreased.
8. Each node in a BST has Pointers:-
a. 1
b. 2
c. 3
d. 4
9. Highest Operators Precedence is of the following operator:-
a. Plus
b. Minus
c. Multiply Click here for
detail
d. Exponentiation
10. Following are the linear data structures:-
a. Stacks
b. Queues
c.
Both a & b (Page 52, 87)
d. None of the above
11. Each entry which points to a null value in a Singly Linked List is
known as:-
a. Node
b. First Node
c.
Last Node
d. Head Node
12. Non recursive calls are faster than the Recursive calls.
a. True (Page
323)
b. False
13. Tree data structure is a
a. Linear
b. Non Linear (Page
112) rep
c. Circular
d. None of Above
14. What will be the valid postfix notation of A+B*C-D
a. ABC+*D-
b. ABC*+D- (According to rule)
c. ABCD+-*
d. AB+D*C
15. When an operator is used in between two operands this is which type
of notation
a. Prefix
b. Postfix
c. Infix (Page
64)
d. None of the Above
MIDTERM
EXAMINATION
Spring 2009
Question
No: 1 ( Marks: 1 ) - Please choose one
Which one of the following is a valid postfix expression?
► ab+c*d-
► ab+c*d-
►
abc*+d- (According to rule)
► abc+*d-
► (abc*)+d-
Question
No: 2 ( Marks: 1 ) - Please choose one
The tree data structure is a
► Linear data structure
►
Non-linear data structure (Page 112)
► Graphical data structure
► Data structure like queue
Question
No: 3 ( Marks: 1 ) - Please choose one
A Compound Data Structure is the data structure
which can have multiple data items of same type or of different types.Which of
the following can be considered compound data structure?
►
Arrays Click here for
detail
► LinkLists
► Binary Search Trees
► All of the given options
Question
No: 4 ( Marks: 1 ) - Please choose one
Suppose a pointer has been declared in
main but has not assigned any variable address then ►That pointer points
to First byte in main function
►That
pointer contains a NULL value
►None of these
►That
pointer points to any memory address
Question
No: 5 ( Marks: 1 ) - Please choose one
Here is the start of a C++ class declaration:
class foo
class foo
{
public:
void x(foo f);
void y(const foo f);
void z(foo f) const;
void z(foo f) const;
Which of the three member functions can alter
the PRIVATE member variables of the foo object that activates the
function?
►Only
x can alter the private member variables of the object that activates the
function.
►Only y can alter the private member
variables of the object that activates the function.
►Only z can alter the private member variables of the object that activates the function.
►Only z can alter the private member variables of the object that activates the function.
►Two
of the functions can alter the private member variables of the object that
activates the function.
Only the x and y can alter the private member variable of
the foo class object. Last Option is more correct but not exact. In the last option the two function
name are not mentioned
Question
No: 6 ( Marks: 1 ) - Please choose one
The operation for removing an entry
from a stack is traditionally called: ► delete
► peek
► pop (Page
53)
► remove
Question No: 7 ( Marks: 1 ) - Please choose one
Which statement of the following
statements is incorrect? ► Lists can be implemented by using arrays or linked
lists ► A list is a sequence of one or more data items
► Stack is a special kind of list in which all insertions and deletions
take place at one end
►
Stacks are easier to implement than lists
Question
No: 8 ( Marks: 1 ) - Please choose one
Parameters in function call are passed using,
►
Stack (Page 80)
► Queue
► Binary Search Tree
► AVL Tree
► AVL Tree
Question
No: 9 ( Marks: 1 ) - Please choose one
Consider the following sequence of
push operations in a stack: stack.push(’7’);
stack.push(’8’);
stack.push(’9’);
stack.push(’10’);
stack.push(’11’);
stack.push(’12’);
stack.push(’9’);
stack.push(’10’);
stack.push(’11’);
stack.push(’12’);
►7
8 9 10 11 12
►9 8 11 10 7 12
►9 10 8 11 12 7
►9 10 8 12 7 11
►9 10 8 11 12 7
►9 10 8 12 7 11
Question No: 10 ( Marks: 1 ) - Please choose one
What is the maximum depth of
recursive calls a function may make?
► 1
► 1
► 2
► n (where n is the argument)
►
There is no fixed maximum
Question
No: 11 ( Marks: 1 ) - Please choose one
Consider the following function:
Consider the following function:
void test_a(int n)
{
cout << n << " ";
if (n>0)
if (n>0)
test_a(n-2);
}
}
What is printed by the call test_a(4)?
►
4 2 0
► 0 2 4
► 0 2
► 2 4
► 0 2
► 2 4
Question
No: 12 ( Marks: 1 ) - Please choose one
Queue follows,
► Last in First out
► First in Last out
► First in Last out
► First in First out (Page 87)
► None of these
Question
No: 13 ( Marks: 1 ) - Please choose one
is a binary tree where every node has
a value, every node's left subtree contains only values less than or equal to
the node's value, and every node's right subtree contains only values that are
greater then or equal ?
►Strictly
Binary Tree
►Binary Search tree Click here for detail
►AVL tree
►All of these
►All of these
Question
No: 14 ( Marks: 1 ) - Please choose one
Four statements about trees are below. Three of them are correct. Which
one is INCORRECT?
►Trees
are recursively defined multi-dimensional data structures Click here for
detail
►The order of a tree indicates a maximum number of childen allowed at
each node of the tree ►A search tree is a special type of tree where all values
(i.e. keys) are ordered
►If Tree1's size is greater than Tree2's size, then the height of Tree1 must also be greater than
Tree2's height.
►If Tree1's size is greater than Tree2's size, then the height of Tree1 must also be greater than
Tree2's height.
Question
No: 15 ( Marks: 1 ) - Please choose one
Below is a binary search tree. If we
delete the value 50 using the algorithm we discussed, what value will be in the
root of
the remaining tree?
► 50
► 60
► 70
► 80
► 70
► 80
Question
No: 16 ( Marks: 1 ) - Please choose one
Is a data structure that can grow
easily dynamically at run time without having to copy existing elements? ► Array
►
List
► Both of these
► None of these
► None of these
MIDTERM
EXAMINATION
Spring 2009
Question No: 1 ( Marks: 1 ) - Please
choose one
Which
one of the following statement is NOT correct .
► In
linked list the elements are necessarily to be contiguous Click here for detail
► In linked list the elements may locate at far
positions in the memory
► In linked list each element also has the address of the
element next to it ► In
an array the elements are contiguous
Question No: 2 ( Marks: 1 ) - Please
choose one
In a program a reference variable, say x, can be
declared as
► int &x ;
► int &x ;
► int *x ;
► int x ;
►
None of the given options
Question No: 3 ( Marks: 1 ) - Please
choose one
Linked
lists are collections of data items "lined up in a row" , insertions
and deletions can be made only
at
the front and the back of a linked list.
►
True
► False
Question No: 4 ( Marks: 1 ) - Please
choose one
A Linear Data Structure is the data structure in which
data elements are arranged in a sequence or a linear list. Which of the following is Non Linear Data
Structure?
►
Arrays
►
LinkLists
► Binary Search Trees
►
None of these
Question No: 5 ( Marks: 1 ) - Please
choose one
A queue where the de-queue
operation depends not on FIFO, is called a priority queue
►False
►True (Page 101)
Question No: 6 ( Marks: 1 ) - Please
choose one
Which
one of the following statements is correct?
►Link
List size is fixed once it is created.
►Binary
Search Tree size isfixed once it is created
►AVL Tree size is fixed once it is created
►AVL Tree size is fixed once it is created
Question No: 7 ( Marks: 1 ) - Please
choose one
Which
one of the following is correct about pointers? ►They always point todifferent memory locations ►They
may point to a singlememory location
►The address of two pointer variables is same
►None of these
►The address of two pointer variables is same
►None of these
Question No: 8 ( Marks: 1 ) - Please
choose one
Which of the following abstract data types are NOT used
by Integer Abstract Data type group? ►short
►Int
Question No: 9 ( Marks: 1 ) - Please
choose one
The operation for adding an entry to a stack is
traditionally called : ►add
►append
►insert
►insert
►push (Page
53)
Question No: 10 ( Marks: 1 ) - Please
choose one
The
operation for removing an entry from a stack is traditionally called:
►delete
►peek
►pop (Page
53)
►remove
Question No: 11 ( Marks: 1 ) - Please
choose one
We
can add elements in QUEUE From _________
►Front
►Front
►Rear (Page 91)
►From
Both Rare and Front
►None of these
►None of these
Question No: 12 ( Marks: 1 ) - Please
choose one
The
difference between a binary tree and a binary search tree is that ,a binary
search tree has
►two
children per node whereas a binary tree can have none, one, or two children per
node Click here for
►in
binary search tree nodes are inserted based on the values they contain ►in binary tree nodes are inserted
based on the values they contain
►none of these
►none of these
Question No: 13 ( Marks: 1 ) - Please
choose one
Suppose n is the number of nodes in a complete Binary
Tree then maximum steps required for a search operation are,
►Log2 (n+1)
-1 (Page 139)
►Log2
(n+1)
►Log2 (n) - 1
►Log2 (n)
►Log2 (n) - 1
►Log2 (n)
Question No: 14 ( Marks: 1 ) - Please
choose one
The
following is a segment of a C program.
int pqr(BinaryNode t)
int pqr(BinaryNode t)
{ if
(t == null )
return
-1;
else
return
1+max(pqr(t.left),pqr(t.right)) }
Identify,
what the above program intend(s) to do?
►Compute the height of a binary tree using an in-order
traversal
►Compute the height of a binary tree using a pre-order traversal
►Compute the depth of a binary tree using a pre-order traversal
►Compute the depth of a binary tree using a post-order traversal
►Compute the height of a binary tree using a pre-order traversal
►Compute the depth of a binary tree using a pre-order traversal
►Compute the depth of a binary tree using a post-order traversal
Question No: 15 ( Marks: 1 ) - Please
choose one
Consider
the following infix expression:
3 + 5
* 6 - 7 * (8 + 5)
Which of the following is a correct equivalent
expression(s) for the above? ► 3 6 5 + *
7 5
8 + - *
► 3 6 5 7 5 8
+ * +
- *
► 3 5 6 + * 7 8 5 + - *
► 3 5 6 + * 7 8 5 + - *
► 3 5 6
* + 7
8 5 +
* -
Question No: 16 ( Marks: 1 ) - Please
choose one
An
array is a group of consecutive related memory locations.
►
True Click here for
detail
►
False
Question No: 17 (
Marks: 1 )
Is
this a correct statement? Give answer in Yes or No.
A node
cannot be deleted, when the node to be deleted has both left and right
subtrees.
False
---- No, it can be deleted.
Question No: 18 (
Marks: 1 )
Deleting
a leaf node in binary search tree involves setting ______ pointer/s of that
node’s parent as null.
1
2
3
4
3
4
No comments:
Post a Comment