Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 Written Question 2 (25 marks) A binary tree is ideally weight balanced if, for every node x in the tree, the number of nodes

image text in transcribed

2 Written Question 2 (25 marks) A binary tree is ideally weight balanced if, for every node x in the tree, the number of nodes in its two subtrees differs by at most 1. 1. (10 marks) Give an algorithm with worst case running time in O(n) that, given a sorted array of n elements, constructs an ideally weight balanced binary search tree. Briefly justify the correctness of your algorithm and why it runs in O(n) time in the worst case. 2. (10 marks) Give an algorithm which has a worst case running time in O(n) that, given an n node binary search tree, transforms it into an ideally weight balanced binary search tree for the same elements. Briefly justify the correctness of your algorithm and why it runs in O(n) time in the worst case. 3. (5 marks) Prove that there is no O(n) time comparison based algorithm that, given an unsorted array of n elements, constructs an ideally balanced binary search tree

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

Step: 3

blur-text-image

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

Oracle 11G SQL

Authors: Joan Casteel

2nd Edition

1133947360, 978-1133947363

More Books

Students also viewed these Databases questions