Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Heaps Give an O(1) algorithm for finding the third-smallest element in a min-heap. Give your answer using pseudocode or clear English with a diagram.

1. Heaps Give an O(1) algorithm for finding the third-smallest element in a min-heap. Give your answer using pseudocode or clear English with a diagram. Prove your running time bound.

2. Trees Prove that red-black trees are approximately balanced. (Hint: use the trees properties to show that it cant get too unbalanced.)

3. Quicksort What is the running time of Quicksort when all elements of the input array have the same value?

4. Trees The pseudocode to find the number of nodes in a tree is as follows:image text in transcribed

What is the worst-case runtime for a call to size(root) in a tree with n nodes? What is the best-case runtime?

Algorithm 1 size(x) 1: if x= nil then 2: return 0 3: return 1 + size(x.left) + SIzE(x.right)

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

Informix Database Administrators Survival Guide

Authors: Joe Lumbley

1st Edition

0131243144, 978-0131243149

More Books

Students also viewed these Databases questions