Python week 6 quiz assignment nptel

Problem 1
                     98
                    /  \
                   /    \
                 67      89
                / \     /  \
               /   \   /    \
             38   42  54    89
            / \
           /   \
          17   25
i want to insert 97 into max heap [98,67,89,38,42,54,89,17,25] (represented in list).
As per me, resulting heap is [98,97,89,38,67,54,89,17,25,42]
                     98
                    /  \
                   /    \
                 97      89
                / \     /  \
               /   \   /    \
             38    67  54    89
            / \     |
           /   \    |
          17   25   42
Problem 2
i want to apply delete_max() twice to the heap [100,97,93,38,67,54,93,17,25,42].
                    100
                    /  \
                   /    \
                 97      93
                / \     /  \
               /   \   /    \
             38    67  54    93
            / \     |
           /   \    |
          17   25   42
As per me heap after two deletemax operations,resulting heap is [93,67,93,38,42,54,25,17]
                     93
                    /  \
                   /    \
                 67      93
                / \     /  \
               /   \   /    \
             38    42  54    25
            /     
           /      
          17      
Share on Google Plus

About Abhishek

0 comments:

Post a Comment