The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
189 views

How to solve such a problem?

asked in DS by Junior (507 points)
edited by | 189 views
+2
bulid max heap

                                    89

                    19                                 40

             17         12                   10                 2

        5       7     11      6          9        70       90   

(2,90) and (10,70) not support max heap properties interchange it

                                 89

               19                                 40

    17                 12                  70          90

5      7              11  6            9     10       2

after that (40,90) and (90,89) also we have to interchange to get max heap so 4 swap required

                               90

               19                                 89

    17                 12                  70          40

5      7              11  6            9     10       2
0
Thanks a lot!

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
48,756 questions
52,850 answers
183,548 comments
68,744 users