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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:30:41+00:00 2026-05-27T14:30:41+00:00

The question is, how many ways are there to build a perfectly balanced binary

  • 0

The question is, how many ways are there to build a perfectly balanced binary tree with 15 elements?

One possibility would bei 8-4-12-2-6-10-14-1-3-5-7-9-11-13-15..

My idea was to write some code that generates every possible permutation (which would be like.. 15!) and then remove the ones that are incorrect.

Correct ones have the 8 as the first element, 4 always comes before 2 and 6, 2 always comes before 1 and 3, 6 always comes before 5 and 7 and so on.

But something like perms2 = list(itertools.permutations([1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])) causes a memory error.

Is there a way to generate permutations with the rules as above?

Or is there even a more simple way to solve my problem?

Btw..

  • if the amount of elements is 1, there is 1 way
  • with 3 elements there are 2 ways (2-1-3 or 2-3-1)
  • with 7 elements there are 80 ways (according to my code and doing it manually)

but that didn’t help me to get some kind of formula..

Edit: this is the tree i am talking about: http://666kb.com/i/bz9znnpdj7etw0fo9.gif

  • 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-27T14:30:41+00:00Added an answer on May 27, 2026 at 2:30 pm

    The correct number is 21964800. This is the appropriate integer sequence:

    http://oeis.org/A076615

    Basically you recursively multiply the possibilities:
    On the lowest level you can choose between two possibilities, e.g: 2-1-3 and 2-3-1. On the level above that you can entangle the chosen order of both lower layers in (6 over 3)
    ways and so on.

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

Sidebar

Related Questions

This question has been asked in many different ways out there, but I have
Firstly I know that there are many question and solutions to correct thread marshalling
Basic question : How to I create a bidirectional one-to-many map in Fluent NHibernate?
Sorry if this question seems trivial to many here. In a C++ code there
So there are many ways of structuring objects (I'm talking of OOP here). For
How many ways are there to let the code output itself? For example, write
I know this must be a trivial question, but I've tried many different ways,
There are many ways to do this but I feel like I've missed a
I see this question have been asked in many different ways, but I don't
This is a question with many answers - I am interested in knowing what

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.