Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Which of the following tree traversal uses a queue data structure?(A) Preorder(B) Inorder(C) Postorder(D) Level order

Answer»
2.

Which of the following cannot generate the full binary tree?(A) Inorder and Preorder(B) Inorder and Postorder(C) Preorder and Postorder(D) None of the above

Answer»
3.

Consider the following C program segmentstruct CellNode{struct CelINode *leftchild;int element;struct CelINode *rightChild;}int Dosomething(struct CelINode *ptr){int value = 0;if (ptr != NULL){if (ptr->leftChild != NULL)value = 1 + DoSomething(ptr->leftChild);if (ptr->rightChild != NULL)value = max(value, 1 + DoSomething(ptr->rightChild));}return (value);}The value returned by the function DoSomething when a pointer to the root of a non-empty tree is passed as argument is (GATE CS 2004)(A) The number of leaf nodes in the tree(B) The number of nodes in the tree(C) The number of internal nodes in the tree(D) The height of the tree

Answer»
4.

The array representation of a complete binary tree contains the data in sorted order. Which traversal of the tree will produce the data in sorted form?(A) Preorder(B) Inorder(C) Postorder(D) Level order

Answer»
5.

Let LASTPOST, LASTIN and LASTPRE denote the last vertex visited in a postorder, inorder and preorder traversal. Respectively, of a complete binary tree. Which of the following is always true? (GATE CS 2000)(A) LASTIN = LASTPOST(B) LASTIN = LASTPRE(C) LASTPRE = LASTPOST(D) None of the above

Answer» None
6.

What does the following function do for a given binary tree?int fun(struct node *root){if (root == NULL)return 0;if (root->left == NULL && root->right == NULL)return 0;return 1 + fun(root->left) + fun(root->right);}(A) Counts leaf nodes(B) Counts internal nodes(C) Returns height where height is defined as number of edges on the path from root to deepest node(D) Return diameter where diameter is number of edges on the longest path between any two nodes.

Answer» None