Following function is supposed to calculate the maximum depth or height of a Binar tree -- the number of nodes along the longest path from the root node down to the farthest leaf node.
Following function is supposed to calculate the maximum depth or height of a Binar tree -- the number of nodes along the longest path from the root node down to the farthest leaf node.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
![1. Following function is supposed to calculate the maximum depth or height of a Binary
tree -- the number of nodes along the longest path from the root node down to the
farthest leaf node.
int maxDepth (struct node* node)
{
if (node--NULL)
return 0;
else
(
/* compute the depth of each subtree */
int 1Depth
maxDepth (node->left);
int rDepth
maxDepth (node->right);
/* use the larger one /
if (1Depth> rDepth)
return x;
else return Y;
What should be the values of X and Y so that the function works correctly?
a. X- IDepth, Y=rDepth
b. X- IDepth + 1, Y =rDepth + 1
c. X-1Depth -1, Y=rDepth -1
d. None of the above
2. What is common in three different types of traversals (Inorder, Preorder and
Postorder)?
a. Root is visited before right subtree
b. Left subtree is always visited before right subtree
c. Root is visited after left subtree
d. All of the above
e. None of the above
3. The inorder and preorder traversal of a binary tree are d be a feg and abdecfg,
respectively. The postorder traversal of the binary tree is:
a. debfgea
b. edbg fea
c. edbfgea
d. defgbea
4. Which of the following pairs of traversals is not sufficient to build a binary tree from
the given traversals?
a. Preorder and Inorder
b. Preorder and Postorder
c. Inorder and Postorder
d. None of the Above
5. Which of the following tree traversal uses a queue data structure?
a. Preorder
b. Inorder
c. Postorder
d. Level order](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa76b7345-c77a-40ec-b55a-72fd1dc9bd02%2F893bd19f-d8d3-4604-802b-6e485b1d078c%2Fd8gnf1b_processed.png&w=3840&q=75)
Transcribed Image Text:1. Following function is supposed to calculate the maximum depth or height of a Binary
tree -- the number of nodes along the longest path from the root node down to the
farthest leaf node.
int maxDepth (struct node* node)
{
if (node--NULL)
return 0;
else
(
/* compute the depth of each subtree */
int 1Depth
maxDepth (node->left);
int rDepth
maxDepth (node->right);
/* use the larger one /
if (1Depth> rDepth)
return x;
else return Y;
What should be the values of X and Y so that the function works correctly?
a. X- IDepth, Y=rDepth
b. X- IDepth + 1, Y =rDepth + 1
c. X-1Depth -1, Y=rDepth -1
d. None of the above
2. What is common in three different types of traversals (Inorder, Preorder and
Postorder)?
a. Root is visited before right subtree
b. Left subtree is always visited before right subtree
c. Root is visited after left subtree
d. All of the above
e. None of the above
3. The inorder and preorder traversal of a binary tree are d be a feg and abdecfg,
respectively. The postorder traversal of the binary tree is:
a. debfgea
b. edbg fea
c. edbfgea
d. defgbea
4. Which of the following pairs of traversals is not sufficient to build a binary tree from
the given traversals?
a. Preorder and Inorder
b. Preorder and Postorder
c. Inorder and Postorder
d. None of the Above
5. Which of the following tree traversal uses a queue data structure?
a. Preorder
b. Inorder
c. Postorder
d. Level order
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY