Sunday, October 26, 2025
HomeData Modelling & AIData Structures | Heap | Question 4

Data Structures | Heap | Question 4

Suppose the elements 7, 2, 10 and 4 are inserted, in that order, into the valid 3- ary max heap found in the above question, Which one of the following is the sequence of items in the array representing the resultant heap?

(A)

10, 7, 9, 8, 3, 1, 5, 2, 6, 4

(B)

10, 9, 8, 7, 6, 5, 4, 3, 2, 1

(C)

10, 9, 4, 5, 7, 6, 8, 2, 1, 3

(D)

10, 8, 6, 9, 7, 2, 3, 4, 1, 5

Answer: (A)
Explanation:

After insertion of 7

                                          9
                                      /   |   \\
                                    /     |     \\
                                  7       6       8
                               / | \\
                             /   |  \\
                            3    1    5    

After insertion of 2

                                           9
                                      /    |   \\
                                    /      |     \\
                                  7        6       8
                               / | \\       /
                             /   |  \\     /
                            3    1    5  2

After insertion of 10

                                 10
                             /    |   \\
                           /      |     \\
                        7         9       8
                    / | \\       / |
                  /   |  \\     /  |
                3    1    5  2    6

After insertion of 4

                                 10
                             /   |   \\
                           /     |     \\
                         7        9       8
                      / | \\      / | \\
                    /   |  \\    /  |   \\
                  3    1    5  2   6    4

Hence Option(A) is the correct answer.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Feeling lost in the world of random DSA topics, wasting time without progress? It’s time for a change! Join our DSA course, where we’ll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS