Skip to main content

Tree 2



((MARKS)) (1/2/3...)
2
((QUESTION))
Find Postfix Expression of following Infix Expression
A-B+C*D
((OPTION_A))
A-BC*D+
((OPTION_B))
AB-CD*+
((OPTION_C))
AB-+CD*
((OPTION_D))
NONE
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Binary tree is implemented non-recursively. Complete following pseudo-code
for non-recursive in-order traversal
((OPTION_A))
a: s.Push(currentNode);
b: s.Pop( );
((OPTION_B))
a: s.Push(currentNode -> leftChild);
b: s.Pop(currentNode);
((OPTION_C))
a: s.Push(currentNode -> rightChild);
b: s.Pop( );
((OPTION_D))
a: s.Push();
b: s.Pop(currentNode );
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
If the post order traversal gives a b - c d * + then the label of the nodes 1, 2, 3 …
will be
((OPTION_A))
+, -, *, a, b, c, d
((OPTION_B))
a, -, b, +, c, *, d
((OPTION_C))
a, b, c, d, -, *, +
((OPTION_D))
-, a, b, +, *, c, d
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Complete following pseudo code of level order traversal of binary tree
((OPTION_A))
a: q.Push(current->leftChild);
b: q.Push(current->rightChild);
c: q.IsFull( )
((OPTION_B))
a: q.Push(current->leftChild);
b: q.Push(current->rightChild);
c: q.IsEmpty( )
((OPTION_C))
a: q.Push(current->rightChild);
b: q.Push(current->leftChild);
c: q.IsEmpty( )
((OPTION_D))
a: q.Push(current->rightChild);
b: q.Push(current->leftChild);
c: q.IsEmpty( )
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)







((MARKS)) (1/2/3...)
2
((QUESTION))
It is necessary for Huffman encoding tree to be,

((OPTION_A))
AVL Tree

((OPTION_B))
Binary Tree

((OPTION_C))
Complete Binary Tree

((OPTION_D))
Binary Search Tree

((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)

















((MARKS)) (1/2/3...)
2
((QUESTION))
Algorithm doSomething(tree1, tree2)
{
if(tree1=NULL and tree2=NULL)
ans=true;
else if{
(tree1->data == tree2->data)
{ans=doSomething(lchild(tree1),lchild(tree2))
If(ans)
Ans= doSomething(Rchild(tree1),Rchild(tree2))
}
return ans;
}
((OPTION_A))
Checking leaf nodes
((OPTION_B))
Checking if two trees are equal
((OPTION_C))
Find left child
((OPTION_D))
Find right child
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)

















((MARKS)) (1/2/3...)
2
((QUESTION))
Int DoSomething(BstNode* root)
{if(root->left == NULL)
Return root->data;
Else
Return DoSomething(root->left)


}
What does the above code do?
((OPTION_A))
Returns any left child value
((OPTION_B))
Returns smallest value
((OPTION_C))
Returns intermediate value
((OPTION_D))
Returns root value
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
DoSomething(BstNode* root)
{if(root!=NULL)
cout<<root->data
DoSomething(root->left)
DoSomething(root->right)
}
What does it do?
((OPTION_A))
Returns level wise node values
((OPTION_B))
Returns root value
((OPTION_C))
Returns depth first searched values
((OPTION_D))
None
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
The min. number of nodes in a binary tree of depth d (root at level 0) is
((OPTION_A))
2d – 1
((OPTION_B))
2d + 1 – 1
((OPTION_C))
d + 1
((OPTION_D))
D
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





















((MARKS)) (1/2/3...)
2
((QUESTION))
The post order traversal of a binary tree is DEBFCA. Find out the preorder traversal
((OPTION_A))
ABFCDE
((OPTION_B))
ADBFEC
((OPTION_C))
ABDECF
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
The height of a BST is given as h. Consider the height of the tree as the no.
of edges in the longest path from root to the leaf. The maximum no. of
nodes possible in the tree is?
((OPTION_A))
2h-1 -1
((OPTION_B))
2h+1 -1
((OPTION_C))
2h +1
((OPTION_D))
2h-1 +1
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
Suppose a binary tree is constructed with n nodes, such that each node has
exactly either zero or two children. The maximum height of the tree will be?
((OPTION_A))
(n+1)/2
((OPTION_B))
(n-1)/2
((OPTION_C))
n/2 -1
((OPTION_D))
(n+1)/2 -1
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
Suppose we have numbers between 1 and 1000 in a binary search tree and
want to search for the number 363. Which of the following sequence
could not be the sequence of the node examined?
((OPTION_A))
2, 252, 401, 398, 330, 344, 397, 363
((OPTION_B))
924, 220, 911, 244, 898, 258, 362, 363
((OPTION_C))
925, 202, 911, 240, 912, 245, 258, 363
((OPTION_D))
2, 399, 387, 219, 266, 382, 381, 278, 363
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
A binary search tree is formed from the sequence 6, 9, 1, 2, 7, 14, 12, 3, 8,
18. The minimum number of nodes required to be added in to this tree to form an extended binary tree is?
((OPTION_A))
3
((OPTION_B))
6
((OPTION_C))
8
((OPTION_D))
11
((CORRECT_CHOICE)) (A/B/C/D)
D
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
while (cur != NULL)
    {
        cout<< cur->data;

        // If this node is a thread node, then go to
        // inorder successor
        if (cur->rightThread)
            cur = cur->right;
        else            cur = leftmost(cur->right);
    }
What does above code snippet do?

((OPTION_A))
Inorder traversal in threaded binary tree
((OPTION_B))
BFS in threaded binary tree
((OPTION_C))
Insertion of a node in threaded binary tree
((OPTION_D))
Deletion of a node in threaded binary tree
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
if (root == NULL)
       return true;

    bool l = (root->left) ?  getCountUtil(root->left, low, high, count) : true;
    bool r = (root->right) ? getCountUtil(root->right, low, high, count) : true;
     if (l && r && inRange(root, low, high))
    {
       ++*count;
       return true;
    }

    return false;
What does above code snippetdo?

((OPTION_A))
Count leaf nodes given range
((OPTION_B))
Count internal nodes given range
((OPTION_C))
Count subtreesin given range
((OPTION_D))
Count branches given range
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
if (node == NULL) return;

    
    DoSomething(node->left);
    DoSomething (node->right);
    
    Cout<<"\n Deleting node:”<<node->data;
    free(node);
What does above code snippet do?
((OPTION_A))
Delete a node
((OPTION_B))
Delete entire tree
((OPTION_C))
Delete left subtree
((OPTION_D))
Delete only right subtree
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)







((MARKS)) (1/2/3...)
2
((QUESTION))
if(node == NULL)      
    return 0;
  if(node->left == NULL && node->right==NULL)     
    return 1;           
  else
    return ABC(node->left)+
           ABC(node->right); 
What does the function ABC do?

((OPTION_A))
Count leaf nodes
((OPTION_B))
Count right subtree nodes only
((OPTION_C))
Count left subtree nodes only
((OPTION_D))
None of these
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
pCrawl = root
set initial stack element as NULL (sentinal)
while(pCrawl is valid )
stack.push(pCrawl)
pCrawl = pCrawl.left
while( pCrawl = stack.pop() is valid )
stop if sufficient number of elements are popped.
if( pCrawl.right is valid )
pCrawl = pCrawl.right
while( pCrawl is valid )
stack.push(pCrawl)
pCrawl = pCrawl.left
What does above algorihtm snippet do?

((OPTION_A))
Finds kth smallest element in binary tree
((OPTION_B))
Traverses a tree
((OPTION_C))
BFS in tree
((OPTION_D))
DFS in tree
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
int Tree(struct node* node)
{
if (node == NULL)
return(true);
if (node->left!=NULL && maxValue(node->left) > node->data)
return(false);
if (node->right!=NULL && minValue(node->right) < node->data)
return(false);
if (!isBST(node->left) || !isBST(node->right))
return(false);
return(true);
}
What does Tree() do?
((OPTION_A))
Checks whether tree has left subtree or not
((OPTION_B))
Checks whether tree has right subtree or not
((OPTION_C))
Checks whether tree is BST or not
((OPTION_D))
None of these
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)













((MARKS)) (1/2/3...)
2
((QUESTION))
void print (struct node* root)
{
    int h = height(root);
    int i;
    for (i=1; i<=h; i++)
        print1 (root, i);
}
 void print1(struct node* root, int level)
{
    if (root == NULL)
        return;
    if (level == 1)
        printf("%d ", root->data);
    else if (level > 1)
    {
        print1(root->left, level-1);
        print1(root->right, level-1);
    }
}
What does print () do?
((OPTION_A))
Inorder traversal using stack
((OPTION_B))
Traverses a tree level wise
((OPTION_C))
Generally traverses a treein random way
((OPTION_D))
None
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)













((MARKS)) (1/2/3...)
2
((QUESTION))
int find( node* a, node* b)

{
    if (a==NULL && b==NULL)
        return 1;
    if (a!=NULL && b!=NULL)
    {
        return
        (
            a->data == b->data &&
            find(a->left, b->left) &&
            find(a->right, b->right)
        );}    return 0;
} What does above code snippet do?

((OPTION_A))
Finds if two trees are identical
((OPTION_B))
Finds if a tree and its mirror are identical
((OPTION_C))
Finds the existence of left and right subtrees
((OPTION_D))
None of these
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Void func(node* node1)
{
if (node1==NULL)
return;
else
{
node* temp;
func(node1->left);
func(node1->right);

temp = node1->left;
node1->left = node1->right;
node1->right = temp;
}

((OPTION_A))
Mirror a tree
((OPTION_B))
Find duplicate of a tree
((OPTION_C))
Finds right subtree
((OPTION_D))
Finds left subtree
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)







((MARKS)) (1/2/3...)
2
((QUESTION))
int func(struct node* node)
{
   if (node==NULL)
       return 0;
   else
   {
       /* compute the depth of each subtree */
       int l = func(node->left);
       int r = func(node->right);

       /* use the larger one */
       if (l > r)
           return(l+1);
       else return(r+1);
   }
}
What does func() do?

((OPTION_A))
Finds height of a tree
((OPTION_B))
Finds levels in a tree
((OPTION_C))
Finds number of nodes in a tree
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
int func(node* node)
{
  
   node* current = node;

  /* loop down to find the leftmost leaf */
  while (current->left != NULL) {
    current = current->left;
  }
  return(current->data);
}
What does func() do?

((OPTION_A))
Finds minimum element in a tree
((OPTION_B))
Finds left leaves in a tree
((OPTION_C))
Finds number of nodes in a tree
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)

((MARKS)) (1/2/3...)
2
((QUESTION))
node *abc(node* root, int n1, int n2)
{
    if (root == NULL) return NULL;

    // If both n1 and n2 are smaller than root, then LCA lies in left
    if (root->data > n1 && root->data > n2)
        return abc(root->left, n1, n2);

    // If both n1 and n2 are greater than root, then LCA lies in right
    if (root->data < n1 && root->data < n2)
        return abc(root->right, n1, n2);

    return root;
}
What does abc() do?
((OPTION_A))
Finds minimum element in a tree
((OPTION_B))
Finds left leaves in a tree
((OPTION_C))
Finds lowest common ancestor
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





















((MARKS)) (1/2/3...)
2
((QUESTION))
bool func(int pre[], int size)
{
    int nextDiff, lastDiff;

    for (int i=0; i<size-1; i++)
    {
        nextDiff = pre[i] - pre[i+1];
        lastDiff = pre[i] - pre[size-1];
        if (nextDiff*lastDiff < 0)
            return false;;
    }
    return true;
}
What does func() do?

((OPTION_A))
Finds minimum element in a tree
((OPTION_B))
Finds left leaves in a tree
((OPTION_C))
Finds number of nodes in a tree with 1 child
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
{
if( n->right != NULL )
return minValue(n->right);
struct node *p = n->parent;
while(p != NULL && n == p->right)
{
n = p;
p = p->parent;
}
return p;
}
What does above do?

((OPTION_A))
Finds minimum element in a tree
((OPTION_B))
Finds inorder successor of a node
((OPTION_C))
Finds number of nodes in a tree with 1 child
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
{if (root == NULL)  return ;

if (root->key == key)
    {
        if (root->left != NULL)
        {
            Node* tmp = root->left;
            while (tmp->right)
                tmp = tmp->right;
            pre = tmp ;
        }

       
        if (root->right != NULL)
        {
            Node* tmp = root->right ;
            while (tmp->left)
                tmp = tmp->left ;
            suc = tmp ;
        }
        return ;
    return true;
}
What does above code do?

((OPTION_A))
Finds minimum and maximum element in a tree
((OPTION_B))
Finds predecessor and successor of a node in a tree
((OPTION_C))
Finds number of nodes in a tree with 1 child
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
{if (root == NULL)  return ;

if (root->key == key)
    {
        if (root->left != NULL)
        {
            Node* tmp = root->left;
            while (tmp->right)
                tmp = tmp->right;
            pre = tmp ;
        }

       
        if (root->right != NULL)
        {
            Node* tmp = root->right ;
            while (tmp->left)
                tmp = tmp->left ;
            suc = tmp ;
        }
        return ;
    return true;
}
What does above code do?

((OPTION_A))
Finds minimum and maximum element in a tree
((OPTION_B))
Finds predecessor and successor of a node in a tree
((OPTION_C))
Finds number of nodes in a tree with 1 child
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
int abc(struct node *root)
{
   if (isBST(root))
     return size(root);
   else
    return max(abc (root->left), abc (root->right));
}
What does abc() do?
((OPTION_A))
Finds minimum subtree in a tree
((OPTION_B))
Finds largest BST subtree
((OPTION_C))
Finds left and right subtrees
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
void abc(Node *root, int &c)
{
    // Base cases, the second condition is important to
    // avoid unnecessary recursive calls
    if (root == NULL || c >= 2)
        return;

    // Follow reverse inorder traversal so that the
    // largest element is visited first
    abc (root->right, c);

    // Increment count of visited nodes
    c++;

    // If c becomes k now, then this is the 2nd largest
    if (c == 2)
    {
        cout << "2nd largest element is "
             << root->key << endl;
        return;
    }

    // Recur for left subtree
    abc (root->left, c);
}
What does abc() do?
((OPTION_A))
Finds minimum subtree in a tree
((OPTION_B))
Finds largest element
((OPTION_C))
Finds 2nd largest element
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
void abc (struct node *root)
{
    // base case: tree is empty
    if(root == NULL)
       return;
    int n = countNodes (root);    int *arr = new int[n];
    int i = 0;
    storeInorder (root, arr, &i);
    qsort (arr, n, sizeof(arr[0]), compare);
    i = 0;
    arrayToBST (arr, root, &i);
    delete [] arr;
}
What does abc() do?
((OPTION_A))
Converts a binary tree to BST
((OPTION_B))
Finds largest BST subtree
((OPTION_C))
Finds left and right subtrees
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
class Node
{
    int data;
    Node *left, *right;
    bool t; 
}
Which data structure does the above class define?
((OPTION_A))
Threaded binary tree
((OPTION_B))
Single threaded binary tree
((OPTION_C))
Double threaded binary tree
((OPTION_D))
BST
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
In k ary tree what is relation between leaf nodes and internal nodes?
(L= leaf nodes and I =internal nodes)
((OPTION_A))
L = (k - 1)*I + 1

((OPTION_B))
L=K*I+1
((OPTION_C))
L=K-I
((OPTION_D))
L=K+1*I
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
int abc(node* node)
{
if (node==NULL)
return 0;
else
return(abc(node->left) + 1 + abc(node->right));
}

((OPTION_A))
Finds number of nodes in tree

((OPTION_B))
Finds number of nodes in left sub tree
((OPTION_C))
Finds number of nodes in right sub tree
((OPTION_D))
None of the above
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
In a binary tree with n nodes, every node has an odd number of descendants. Every node is considered to be its own descendant. What is the number of nodes in the tree that have exactly one child?
((OPTION_A))
0
((OPTION_B))
1
((OPTION_C))
(n-1)/2
((OPTION_D))
n-1
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Consider a binary tree T that has 200 leaf nodes. Then, the number of nodes in T that have exactly two children are _________.
((OPTION_A))
199
((OPTION_B))
200
((OPTION_C))
Any number between 0 and 199
((OPTION_D))
Any number between 100 and 200
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
A binary tree T has 20 leaves. The number of nodes in T having two children is
((OPTION_A))
18
((OPTION_B))
19
((OPTION_C))
17
((OPTION_D))
Any number between 10 and 20
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
In a complete k-ary tree, every internal node has exactly k children. The number of leaves in such a tree with n internal nodes is

((OPTION_A))
Nk
((OPTION_B))
(n – 1)k + 1

((OPTION_C))
n(k – 1) + 1

((OPTION_D))
n(k – 1)
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
A complete n-ary tree is a tree in which each node has n children or no children. Let I be the number of internal nodes and L be the number of leaves in a complete n-ary tree. If L = 41, and I = 10, what is the value of n?
((OPTION_A))
3
((OPTION_B))
4
((OPTION_C))
5
((OPTION_D))
6
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





















((MARKS)) (1/2/3...)
2
((QUESTION))
The hight of a tree is defined as the number of edges on the longest path in
the tree.The function shown in the pseudocode below is invoked as
height(root) to compute the height of a binary tree rooted at the tree
pointer root.
int height
{ if (n= =NULL) return -1;
If(n-> left= =NULL)
If(n-> right= =NULL) ) return 0;h1 = height (n -> left);
Else return B1;
Else { h1 = height (n -> left);
If (n -> right = NULL) return (1 + h1);
Else { h2 = height (n ~ right);
Return B2;
}
}
}
The appropriate expression for the two boxes B1 and B2 are____.

((OPTION_A))
B1:(1 + height(n-> right)) ,B2: (1 + max (h1,h2))
((OPTION_B))
B1:(1 + height(n-> right)) ,B2: (1 + max (h1,h2))
((OPTION_C))
B1:( height(n-> right)) ,B2: ( max (h1,h2))
((OPTION_D))
B1:(1 + height(n-> right)) ,B2: ( max (h1,h2))
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
Find Huffman Code for node E. If Weights of nodes are as follows: A=10, B=3,C=4,D=15,E=2.
((OPTION_A))
0001
((OPTION_B))
1010
((OPTION_C))
1000
((OPTION_D))
1000
((CORRECT_CHOICE)) (A/B/C/D)
C
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Post fix expression of an expression tree is ab+cd-*. Find inorder traversal of it
((OPTION_A))
a+b-c*d
((OPTION_B))
ab+c*d-
((OPTION_C))
a-cd+*
((OPTION_D))
None
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
DFS of a tree is 10,4,8,6,5,7,9,12,11.Find BFS.
((OPTION_A))
10 4 12 3 8 11 6 9 5 7
((OPTION_B))
10 12 8 11 6 5 9 7 4 3
((OPTION_C))
10 8 12 11 5 9 6 7 3 4
((OPTION_D))
None
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)



((MARKS)) (1/2/3...)
2
((QUESTION))
DFS of a tree is : 10 5 12 4 7 6 9 8. If 7 is to be deleted it will be replaced by which node?
((OPTION_A))
10
((OPTION_B))
4
((OPTION_C))
5
((OPTION_D))
8
((CORRECT_CHOICE)) (A/B/C/D)
D
((EXPLANATION)) (OPTIONAL)











((MARKS)) (1/2/3...)
2
((QUESTION))
DFS of a tree is : 10 5 12 4 7 6 9 8. If 10 is to be deleted it will be replaced by which node?
((OPTION_A))
7
((OPTION_B))
12
((OPTION_C))
5
((OPTION_D))
8
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
DFS of a tree is : 10 5 12 4 7 6 9 8. If 4 is to be deleted it will be replaced by which node?
((OPTION_A))
7
((OPTION_B))
12
((OPTION_C))
5
((OPTION_D))
8
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)







((MARKS)) (1/2/3...)
2
((QUESTION))
Inorder traversal of a tree is: 40 20 30 10 70 50 60 80 90. When 20 is deleted with which node is it replaced?
((OPTION_A))
30
((OPTION_B))
40
((OPTION_C))
10
((OPTION_D))
50
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
Tree has 7 nodes? How many orders of traversals are possible?
((OPTION_A))
256
((OPTION_B))
128
((OPTION_C))
7
((OPTION_D))
70
((CORRECT_CHOICE)) (A/B/C/D)
B
((EXPLANATION)) (OPTIONAL)









((MARKS)) (1/2/3...)
2
((QUESTION))
Following nodes are inserted in BST:10 8 15 12 13 7 9. What is height of the tree?
((OPTION_A))
4
((OPTION_B))
5
((OPTION_C))
3
((OPTION_D))
2
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)





((MARKS)) (1/2/3...)
2
((QUESTION))
How many nodes a complete binary tree of level 4 has?
((OPTION_A))
15
((OPTION_B))
13
((OPTION_C))
11
((OPTION_D))
9
((CORRECT_CHOICE)) (A/B/C/D)
A
((EXPLANATION)) (OPTIONAL)







Comments

Post a Comment

Popular posts from this blog

PPL 1

NEW Unit III STRUCTURING OF PROGRAM MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of ‘Data Abstraction’? (a) Reduce Complexity (b) Binds together code and data (c) Parallelism (d) None of the mentioned Answer : a Explanation : An essential element of Object Oriented Programming is ‘Data Abstraction’ which means hiding things. Complexity is managed through abstraction. 2. Which of the following mechanisms is/are provided by Object Oriented Language to implement Object Oriented Model? (a) Encapsulation (b) Inheritance (c) Polymorphism (d) All of the mentioned Answer : d Explanation : None. 3. Which of these is the functionality of ‘Encapsulation’? (a) Binds together code and data (b) Using single interface for general class of actions. (c) Reduce Complexity (d) All of the mentioned Answer : a Explanation : ‘Encapsulation’ acts as protective wrapper that prevents code and data from being accessed by other code defined outside the...

replacing strings without using inbuild functions

 Q:replacing strings without using inbuild functions. We are using gcc compiler and terminal to compile the code and ubuntu OS. PROGRAM: #include<stdio.h> int strln1(char s1[]); int strln2(char s2[]); void strcpy1(char s1[],char s2[]); int main() {     char s1[30],s2[30];     int result1,result2;     printf("Enter the string s1");     scanf("%s",s1);     printf("Enter the string s2");     scanf("%s",s2);     printf("Your string s1 is %s",s1);     printf("\nYour string s2 is %s",s2);     result1=strln1(s1);     result2=strln2(s2);     printf("\nlength of string s1 is %d\n",result1);     printf("\nlength of string s2 is %d\n",result2);     strcpy1(s1,s2); } int strln1(char s1[]) {     int i,ln;   ...

create a program to print directory strucure like C:\cygwin\home\administrator.

Q: Create a program that uses escape sequence \\ to print the following directory structure C:\cygwin\home\administrator. We are using gcc compiler and terminal to compile the code and ubuntu OS.   PROGRAM: #include<stdio.h> void main()  {   printf("C:\\cygwin\\home\\administrator.\n");  }  OUTPUTE: