Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Name: Nguyễn Duy Khanh

StudentID: 518H0519

Mini Test 2
Discrete Structure
Question 1:
Min number of comparisons is 8 because in this case, the Binary Heap was
sorted from large to small.
Max number of comparisons is 8 * log8 = 24, in this worst case, the Binary
Heap was sorted from small to large.

Question 2:
How???
Question 3:
Proof:
1. For all element were child of left child of root, they are always less than
their parent.
2. For all element were child of right child of root, they are always less than
their parent.
3. So, we have 2 case:
If right child less than left child of the root, so left child larger than all
the children of right child and it will be the second largest element of
the Max Heap.
If left child less than right child of the root, so right child larger than
all the children of left child and it will be the second largest element
of the Max Heap.

You might also like