Question

java problem!

Show step! and explain!

Question 5 [10 marks] 3.2.24 Prove that no compare-based algorithm can build a BST using fewer than lg(N N lg N compares.

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

Assume that the comparison based algorithm is represented as A.

  • The number of comparisons in the algorithm A on the input of the array of size n in the worst case is represented as CA(n).
  • The worst-case complexity of the comparison based algorithm is Ω(nIgn) .

Proof of the complexity is explained below:

  • The proof of the algorithm uses the sorting model of decision tree.
  • For each of the input n, CA(n) represent the height of the decision tree.
  • On at-least one leaf of the decision tree, each permutation of the input n occurs.
  • The number of leaves, as the size of the input is n, having at-least n! number of leaves.
  • The decision tree which is a simplified decision tree, then it said to be a binary tree.
  • The number of leaves of the binary tree with the height, have at-most 2h number of leaves.

By combining all the information together, the following is obtained:

n! <= Count of the leaves of the decision tree

    <= 2height of the decision tree

    <= 2CA(n)

Therefore,

CA(n) >= lg(n!) = Ω(nIgn)

Use the following, to obtain the inequality:

nn/2 <= n! <= nn

The above implies the following:

lg n! >= lg(nn/2)

        = (n/2) lg n

        = Ω(nIgn)

Hence, the complexity of the comparison based algorithm is no longer than Ω(nIgn) .

Add a comment
Know the answer?
Add Answer to:
java problem! Show step! and explain! Prove that no compare-based algorithm can build a BST using...
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