Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6061563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:57:06+00:00 2026-05-23T08:57:06+00:00

Suppose I have a Heap Like the following: 77 / \ / \ 50

  • 0

Suppose I have a Heap Like the following:

     77
    /  \
   /    \
  50    60
 / \    / \
22 30  44 55

Now, I want to insert another item 55 into this Heap.

How to do this?

Option 1.

         77
        /  \
       /    \
      55    60
     / \    / \
    50 30  44 55
   /
  22

Option 2.

     77
    /  \
   /    \
  55    60
 / \    / \
22 50  44 55
     \
     30

Option 3.

     77
    /  \
   /    \
  50    60
 / \    / \
22 30  55 55
      /
     44

Which is the correct step? And Why? Please explain.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T08:57:06+00:00Added an answer on May 23, 2026 at 8:57 am

    Option 1 is right..
    Because we start adding child from the most left node and if the parent is lower than the newly added child than we replace them. And like so will go on until the child got the parent having value greater than it.

    Your initial tree is

         77
        /  \
       /    \
      50    60
     / \    / \
    22 30  44 55
    

    Now adding 55 according to the rule on most left side.

         77
        /  \
       /    \
      50    60
     / \    / \
    22 30  44 55
    /
    55
    

    But you see 22 is lower than 55 so replaced it.

           77
          /  \
         /    \
        50    60
       / \    / \
      55 30  44 55
     /
    22 
    

    Now 55 has become the child of 50 which is still lower than 55 so replace them too.

           77
          /  \
         /    \
        55    60
       / \    / \
      50 30  44 55
     /
    22
    

    Now it cant be sorted more because 77 is greater than 55 …
    SO your option 1 is right.

    here you can see heap sort example in detail..
    This link states
    a heap is a specialized tree-based data structure that satisfies the heap property: if B is a child node of A, then key(A) ≥ key(B). This implies that an element with the greatest key is always in the root node, and so such a heap is sometimes called a max-heap. (Alternatively, if the comparison is reversed, the smallest element is always in the root node, which results in a min-heap.) There is no restriction as to how many children each node has in a heap, although in practice each node has at most two.

    Good Luck

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have the following HTML snippet: <input type=text id=myinput /> Now I want
Suppose we have a min heap with some elements which satisfy the heap property.
Suppose I have, Heap Sort method which its complexity time is O(nlogn). When I
Suppose i have a cookie set in first.com say user. Now i want to
Suppose I have some simple struct like this: public struct WeightedInt { public int
Suppose we have a binary heap of n elements and wish to insert n
Suppose we have the following table data: ID parent stage submitted 1 1 1
Suppose I have an IEnumerable such as a List(TValue) and I want to keep
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input
Suppose I have a list, in which no new nodes are added or deleted.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.