Question 1 Question 1 Question 2 50 30 80 25 40 55 98 48 52 58 85 110 45 70 90 6
ID: 3552053 • Letter: Q
Question
Question 1
Question 1
Question 2
50
30 80
25 40 55 98
48 52 58 85 110
45 70 90
65 79
75
Question 3
50
50,30
50,30,25
...
Complete the remaining steps manually. What is the maximum # of elements stored in the stack during the process?
Question 4
preo rder
in order
post order
All orders use the stack equally
Question 5
Question 6
Question 7
Question 8
Question 9
50
30 80
25 40 55
48
Question 10
Question 11
A
B F
C E G
D
Question 12
Question 13
preo rder
in order
post order
All orders use the stack equally
Question 5
- What is the level of node 65 in Figure 11-35 in Page 679?
Question 6
- Consider a binary tree with pre-order sequence M-K-L-P-A-N-D, and in-order sequence L-K-M-A-P-N-D. Which item is in the right child of the root node?
Question 7
- Consider a binary tree with post-order sequence m-k-s-p-q-v-a, and in-order sequence k-m-a-p-s-v-q. Which item is in the left child of the root node?
Question 8
- How many unique binary trees are there that generate M-K-L as the pre-order sequence and K-L-M as the post-order sequence?
Question 9
- Write the pre-order sequence for the binary tree given in Figure 11-37 in page 680. Simply use comma with no spaces to write the list.
50
30 80
25 40 55
48
Question 10
- Write the post-order sequence for the binary tree given in Figure 11-37 in page 680. Simply use comma with no spaces to write the list.
Explanation / Answer
<<1>> - #include<iostream>
- using namespace std;
- struct tree
- {
- int data;
- tree *left, *right;
- };
- int main()
- {
- cout<<5*sizeof(tree); // since, 5 nodes are being stored
- return 0;
- }
stdin :
empty
stdout :
60 Hence storage space = 60 bytes (Ans). -------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<2>>
50,80,55,58,70,65
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<3>>
50 50,30 50,30,25 50,30,25 50,30 50 50,40 50 50,48 50,48,45 50,48 50 80 80,55 80,55,52 80,55 80 80,58 80 80,70 80,70,65 80,70 80 80,79 80,79,75 80,79 80 98 98,85 98 110 110,90 110 (empty) // traversed whole tree. As, we can see number of elements in stack doenot exceed 3. Hence maximum no. of elements in stack = 3 . -------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<4>>
Postorder
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<5>>
Ans=5.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<6>>
P
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<7>>
K
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<8>>
5
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<9>>
50,30,25,40,48,80,55
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<10>>
25,48,40,30,55,80,50
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<11>>
D,C,B,E,A,F,G
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<12>>
85
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<13>>
48
----------------------------------------------------------------------Done Cheers :)------------------------------------------------------------------------ 50 50,30 50,30,25 50,30,25 50,30 50 50,40 50 50,48 50,48,45 50,48 50 80 80,55 80,55,52 80,55 80 80,58 80 80,70 80,70,65 80,70 80 80,79 80,79,75 80,79 80 98 98,85 98 110 110,90 110 (empty) // traversed whole tree. As, we can see number of elements in stack doenot exceed 3. Hence maximum no. of elements in stack = 3 . -------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<4>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<4>>
Postorder Postorder
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<5>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<5>>
Ans=5.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<6>>
P
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<7>>
K Ans=5.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<6>>
P
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<7>>
K
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<8>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<8>>
5
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<9>>
50,30,25,40,48,80,55
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<10>>
25,48,40,30,55,80,50
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<11>>
D,C,B,E,A,F,G
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<12>>
85
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<13>>
48
----------------------------------------------------------------------Done Cheers :)------------------------------------------------------------------------ 5
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<9>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<9>>
50,30,25,40,48,80,55 50,30,25,40,48,80,55
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<10>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<10>>
25,48,40,30,55,80,50 25,48,40,30,55,80,50
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<11>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<11>>
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<11>>
D,C,B,E,A,F,G
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<12>>
85
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<13>>
48
----------------------------------------------------------------------Done Cheers :)------------------------------------------------------------------------ D,C,B,E,A,F,G
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<12>>
85
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<13>>
48
----------------------------------------------------------------------Done Cheers :)------------------------------------------------------------------------ D,C,B,E,A,F,G
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<12>>
85
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
<<13>>
48
----------------------------------------------------------------------Done Cheers :)------------------------------------------------------------------------
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.