What-heap?

Report a typo

The data structure for a tree is an array T, where the first element, T[1], is the element at the root, and the descendants of the element T[i] are T[2*i] and T[2*i+1] (but only when numbering elements of an array starting with 1). Then, using this rule, we can represent the following heap as the array that's below it:

Binary heap

[16, 11, 9, 10, 7, 3, 4, 6, 5]

Given a set of trees (1 in each row). It is necessary to determine for every one of them whether it is a max-heap or a min-heap. Otherwise, output "not-heap".

Sample Input 1:

13 15 24 19 20 25 26 36 23 35 31 26 36 48 44 47 43 34 30 41
3 7 4 18 11 34 8 26 19 19 23 37 37 15 23 44 38 30 30 23
1 10 9 22 30 29 30 36 26 41 31 37 33 42 36 49 40 48 36 46

Sample Output 1:

min-heap
min-heap
min-heap
Write code in your IDE to process the text file and display the results below
___

Create a free account to access the full topic