Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that p points to a node in a complete linked binary tree. It is not a binary search tree! Each node p has a


Suppose thatppoints to a node in a complete linked binary tree. It is not a binary search tree! Each nodephas a keyp.key, a pointer to its left subtreep.left, and a pointer to its right subtreep.right. An empty subtree is written as NIL. The procedure IN-TREE returns TRUE if the tree whose root isphas a node with the keykin it. IN-TREE returns FALSE otherwise.

IN-TREE(p,k) ifp== NIL returnFALSE elseifp.key== KEY returnTRUE else returnIN-TREE(p.left,k)orIN-TREE(p.right,k)

Can the master theorem be used to determine the run time of IN-TREE? There are three possible answers.

  1. The master theorem canneverbe used. Briefly explain why.
  2. The master theorem cansometimesbe used. Briefly explain why. Use the master theorem to determine IN-TREEs run time.
  3. The master theorem canalwaysbe used. Briefly explain why. Use the master theorem to determine IN-TREEs run time.

Write your answer in one of these three ways. Hint: ifE is TRUE, thenEorE will not executeE.

3.(10 points.) Suppose thatAis an array whose elements are integers. If you sortAs elements into nonincreasing order, will that turnAinto a max-heap? Prove that it will, or that it will not.





Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Programming questions

Question

Be prepared to discuss your career plans.

Answered: 1 week ago