Question

Please help this. Q. When is the right subtree of a binary tree processed before the...

Please help this.

Q. When is the right subtree of a binary tree processed before the left?                

When using an inorder traversal algorithm.                         

When using a preorder traversal algorithm.                         

When using a postorder traversal algorithm.                       

Never. The left always goes before the right in the standard traversal algorithms.

Q. In a postorder tree traversal, each node is processed ____ its children.                             

instead of                           

after                     

before                 

relative to the ordinal values of

Q17. If you have an array of 4,000 sorted data items, about how many comparisons will it take for a binary search to discover that a certain value is not present?                       

64                          

4000                      

12          

It depends on where the value would fall in the array.

Q. Which of the following statements is true about this recursive function?

long f(int n)

{    return n * f(n - 1);

}

A) Invoking f(1) returns 1.                            

B) Invoking f(0) returns 0.                            

C) This function works perfectly for all n > 0.                        

D) The function runs infinitely and causes a crash.

Q. A binary tree whose left and right subtrees are similar in height is said to be ________.                            

inefficient                          

abstract               

fictitious                              

balanced

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1) Never. The left always goes before the right in the standard traversal algorithms.

Reason --->

Inorder traveral = (left, root, right)

Preorder traversal = (root, left, right)

Postorder traversal = (left, right, root)

none of the standard traversal algorithm process right before the left.

2) after

Reason ---> Postorder traversal = (left, right, root)

the children are processed before the root node.

3) It will take 12 comparisons to check if a certain value is not present.

Reason ---> In binary search, worst case is when you search for a value which is lower than first element or greater than last element because we compare the element we are searching with middle element of any range.

Approxiamte number of comparisons = log2(4000) = 12

4) D) The function runs infinitely and causes a crash.

Reason ---> there are no end condition to stop the recursion. To stop or to correct the function should be like :

long f(int n) {

if(n == 0) return 1;

else return n * f(n-1);

}

5) Balanced binary tree has left and right subtree of similar height.

Reason ---> By definition, Balanced binary tree has "minimum possible maximum height"  

i.e min(maximum height of tree containing x no. of nodes) is the one which is Balanced Binary Tree.

Add a comment
Know the answer?
Add Answer to:
Please help this. Q. When is the right subtree of a binary tree processed before the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT