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 8746989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:16:58+00:00 2026-06-13T12:16:58+00:00

I have been doing some research on Binary trees, and the array list representation.

  • 0

I have been doing some research on Binary trees, and the array list representation. I am struggling to understand that the worst case space complexity is O(2^n). Specifically, the book states, the space usage is O(N) (N = array size), which is O(2^n) in the worst case . I would have thought it would have been 2n in the worst case as each node has two children (indexes) not O(2^n), where n = no. of elements.

an example, if I had a binary tree with 7 nodes, then the space would be 2n = 14 not 2^n = 128.
enter image description here

  • 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-13T12:17:00+00:00Added an answer on June 13, 2026 at 12:17 pm

    This is Heap implementation on an array. Where

    A[1..n]
    left_child(i) = A[2*i]
    right_child(i) = A[2*i+1]
    parent(i) = A[floor(i/2)]
    

    Now, come to space. Think intuitively,

    when you insert first element n=1, location=A[1], similarly,

    n=2 @A[2] left_child(1)
    n=3 @A[3] right_child(1)
    n=4 @A[4] left_child(2)
    n=5 @A[5] right_child(2)
    

    You see, nth element will go into A[n]. So space complexity is O(n).

    When you code you just plug-in the element to be inserted in the end say at A[n+1], and say that it’s a child of floor((n+1)/2).

    Refer: http://en.wikipedia.org/wiki/Binary_heap#Heap_implementation


    Heap is a nearly complete tree, so total number of elements in the tree would be 2h-1 < n <= 2h+1-1 and this is what the length of array you will need. Refer: this

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

Sidebar

Related Questions

I love my GUID. However, lately I have been doing some research to understand
I have been doing some research and I have found some algorithms that have
This is a homework problem that I have. I have been doing some research
Now that i've been doing some research I understand that I need to be
I have been doing some research on payment providers for in-app billing that support
I have been doing some research on test driven development and find it pretty
I have been doing some research for using MSMQ. Following 2 gave me fundamental
So I have been doing some research into getting my UTF8 to print correctly.
I have been doing some research on mobile websites, and thus far it seems
I have been doing some research lately about best approaches to authenticating web services

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.