0% found this document useful (0 votes)
12 views5 pages

232ICS202Assignment3 202157210

Uploaded by

jt89xgmzxd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views5 pages

232ICS202Assignment3 202157210

Uploaded by

jt89xgmzxd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

ICS 202 – Data Structures and Algorithms

Spring Semester 2023/2024 (232)


Assignment #3

Question I. (25 points) (Binary Heaps) Consider a perfect binary tree of height ℎ ≥ 0.
a. (5 points) How many nodes does the tree have (in terms of ℎ).
b. (20 points) Show that applying the bottom-up algorithm for building a heap on a perfect binary tree
costs Θ(𝑛) element comparisons, where 𝑛 is the number of nodes in the perfect binary tree.

When building a heap bottom up we start from the bottom then we


percolate down and this means that in each level there is 2^h nodes
and each node will compare twice the left child and right child so it
will do 2^h+1 and it will do it until it reaches the root so it will do it:

Page 1 of 5
Question II. (25 points) (Binary Heaps)
Sort the following array using heap sort algorithm. [77, 45, 38, 28, 12, 17, 9]

Page 2 of 5
Question III. (30 points) (B-Trees)
Insert 12, 29, 23, 39, 43, 26, 48, 27, 20, 60, 57, 50 in a B tree of order M=3

Page 3 of 5
Question IV. (20 points) (B Trees)
a. (10 points) Delete the key 91 in the following B-tree of order 5

Page 4 of 5
b. (10 points) Delete the key 40 in the following B-tree of order 3

Page 5 of 5

You might also like