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

  • SEARCH
  • Home
  • 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 8188105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:47:40+00:00 2026-06-07T02:47:40+00:00

Doesn’t bottom up heap construction completely depend on the fact that (n+1) is a

  • 0

Doesn’t bottom up heap construction completely depend on the fact that (n+1) is a power of 2? (where n is the number of nodes).

For example consider the case n = 21. (n +1) is NOT a power of 2- how would this work?

You would create first insert (n+1)/2 nodes or in other words 11 nodes. You would then insert (n+1)/4 nodes to be the parents of the previously inserted nodes or in other words 5.5 nodes. But how can “half a node” be inserted? Whenever n is not a power of 2, you always arrive at a decimal amount of node insertions at some level – how do you deal with this?

I considered removing a certain amount of nodes such that the remaining nodes are a power of two, building a tree out of the remaining nodes and then bubbling the removed nodes into the tree after it has been completed. But with large amounts of nodes this becomes unfeasible: i.e. number of nodes = 1600. The closest power of 2 is 1024, meaning you would have to bubble 576 nodes, which is relatively time consuming.

  • 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-06-07T02:47:45+00:00Added an answer on June 7, 2026 at 2:47 am

    No, there is no requirement that this happens. Remember that a binary heap may have nodes missing from its final layer. This means that in the first step, you combine the nodes in a way where you end up with a collection of heaps such that those heaps will form the last two layers of the heap. Not all of those heaps have to be complete heaps; some of them will have missing children.

    If you choose the number of children to omit in a way that the remaining number of nodes is one less than a perfect power of two, you can then proceed with the bottom-up construction as usual. The result will be a complete binary heap.

    Hope this helps!

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

Sidebar

Related Questions

This doesn't work: int number = 1; String numberstring = IntToString(number); I get The
Why doesn't this test case work? <?php // cards with cyrillic inidices and suits
There doesn't seem to be a question for this, and it seems strange that
Python doesn't support complicated anonymous functions. What's a good alternative? For example: class Calculation:
It doesn't appear that the Source property for the XAML WebView control is updating
Why doesn't the following doesn't handle the exception that was rethrown? I tried all
Why doesn't Ctrl + C work to break a Python program that uses PyQt?
Why doesn't JSON.parse behave as expected? In this example, the alert doesn't fire: <html
Why doesn't the first example output a warning? #!/usr/bin/env perl use warnings; use 5.012;
Doesn't work with other modules, but to give an example. I installed Text::CSV_XS with

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.