Welcome to the Trees MCQs Page
Dive deep into the fascinating world of Trees with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Trees, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Trees, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.
Check out the MCQs below to embark on an enriching journey through Trees. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.
Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Trees. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!
Trees MCQs | Page 18 of 32
Explore more Topics under Data Structures and Algorithms
i) from root search for the node to be deleted
ii)
iii) delete the node at
what must be statement ii) and fill up statement iii)
checkSum(struct bin-treenode *root , int sum) :
if(root==null)
return sum as 0
else :
leftover_sum=sum-root_node-->value
//missing
void print(tree *root,tree *node)
{
if(root ==null) return 0
if(root-->left==node || root-->right==node || print(root->left,node)||printf(root->right,node)
{
print(root->data)
}
}
a)
public void preorder(Tree root)
{
System.out.println(root.data);
preorder(root.left);
preorder(root.right);
}
b)
public void preorder(Tree root)
{
preorder(root.left);
System.out.println(root.data);
preorder(root.right);
}
c)
public void preorder(Tree root)
{
System.out.println(root.data);
preorder(root.right);
preorder(root.left);
}
d) None of the mentioned
a)
public void postorder(Tree root)
{
System.out.println(root.data);
postorder(root.left);
postorder(root.right);
}
b)
public void postorder(Tree root)
{
postorder(root.left);
postorder(root.right);
System.out.println(root.data);
}
c)
public void postorder(Tree root)
{
System.out.println(root.data);
postorder(root.right);
postorder(root.left);
}
d) None of the mentioned
a)
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.left != null) stk.push(node.left);
if (node.right != null) stk.push(node.right);
}
}
b)
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}
c)
public void preOrder(Tree root)
{
if (root == null) return;
Stack<Tree> stk = new Stack<Tree>();
st.add(root);
while (!stk.empty())
{
Tree node = stk.pop();
System.out.print(node.data + " ");
if (node.right != null) stk.push(node.right);
if (node.left != null) stk.push(node.left);
}
}
d) None of the mentioned
Suggested Topics
Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!