I have spent hours on this problem and cannot get it, any help would be
appreciated:
A binary search tree using n distinct integers 1, 2, ..., n. There
are n! possible initial orderings of the n numbers. How many of the n!
permutations will result in a perfectly balanced binary search tree?
Assume that n =2^k -1 for some positive integer k.
I was given a hint: 1 node = 1 permutation, 3 nodes = 2 permutations,
7 nodes = 80 permuations.
Thanks,
Jason 3 2527 ja************@gmail.com wrote: I have spent hours on this problem and cannot get it, any help would be appreciated:
A binary search tree using n distinct integers 1, 2, ..., n. There are n! possible initial orderings of the n numbers. How many of the n! permutations will result in a perfectly balanced binary search tree? Assume that n =2^k -1 for some positive integer k.
I was given a hint: 1 node = 1 permutation, 3 nodes = 2 permutations, 7 nodes = 80 permuations.
Thanks,
Jason
Off-topic
( http://www.parashift.com/c++-faq-lit....html#faq-5.9). Try
comp.programming or similar.
Cheers! --M
Sorry...and thanks!
Jason ja************@gmail.com wrote: I have spent hours on this problem and cannot get it, any help would be appreciated:
A binary search tree using n distinct integers 1, 2, ..., n. There are n! possible initial orderings of the n numbers. How many of the n! permutations will result in a perfectly balanced binary search tree? Assume that n =2^k -1 for some positive integer k.
I was given a hint: 1 node = 1 permutation, 3 nodes = 2 permutations, 7 nodes = 80 permuations.
Thanks,
Jason
What does this mean? How do you map a permutation of the integers onto
a BST? There is only one balanced binary search tree for these n numbers. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Steve Goldman |
last post by:
Hi,
I am trying to come up with a way to develop all n-length permutations of a
given list of values. The short function below seems to work, but I can't
help thinking there's a better way. ...
|
by: John Trunek |
last post by:
I have a set of X items, but want permutations of length Y (X > Y). I
am aware of the permutation functions in <algorithm>, but I don't
believe this will do what I want. Is there a way, either...
|
by: Alex Vinokur |
last post by:
Does STL contain algorithms which generate (enable to generate) exponents, permutations, arrangements, and combinations for any
numbers and words?
--
Alex Vinokur
mailto:alexvn@connect.to...
|
by: Girish Sahani |
last post by:
Hi guys,
I want to generate all permutations of a string. I've managed to
generate all cyclic permutations. Please help :)
def permute(string):
l=
l.append(string)
string1 = ''
for i in...
|
by: anurag |
last post by:
hey can anyone help me in writing a code in c (function) that prints
all permutations of a string.please help
|
by: Christian Meesters |
last post by:
Hi,
I'd like to hack a function which returns all possible permutations as lists
(or tuples) of two from a given list. So far, I came up with this solution,
but it turned out to be too slow for...
|
by: JosAH |
last post by:
Greetings,
last week we talked a bit about generating permutations and I told you that
this week will be about combinations. Not true; there's a bit more to tell
about permutations and that's...
|
by: Shraddha |
last post by:
Suppose we are having 3 variables...a,b,c
And we want to print the permutations of these variables...Such
as...abc,acb,bca...all 6 of them...
But we are not supposed to do it mannually...
I...
|
by: Assimalyst |
last post by:
Hi
I have a Dictionary<string, List<string>>, which i have successfully
filled. My problem is I need to create a filter expression using all
possible permutations of its contents.
i.e. the...
|
by: Bill Cunningham |
last post by:
I don't know if I'll need pointers for this or not. I wants numbers
10^16. Like a credit card 16 digits of possible 10 numbers, so I guess that
would be 10^16. So I have
int num ;
These are of...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |