Given a sequence of integers, there are a few sequences
which result in balanced
binary search trees i.e., AVL trees. Write a program that
takes a sequence of integers
as input and outputs the number of such sequences that
result in the balanced binary
search trees.
Input Format:
Single line contains sequence of integers terminated by -1.
Output format:
Print the number of AVL tree possible from that input sequence.
Sample Input:
1 2 3 -1
Sample Output:
2


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More Puzzles Interview Questions

What is the minimum number of races required to pick the best three horses from 25 horses if each race has maximum of 5 horses?

35 Answers   Infosys, MAIT, PDF, State Bank Of India SBI, Wipro, ZoomInfo,


how would u find d exact number of white maruti cars in mumbai???

15 Answers   Bhel, Infosys, RR, TCS,


ek cricket match chal raha he jitne ke liye 7 ball me 3 runs lag rahe he. dono batsman ke runs he 94and 94. 3 balls me se koi bhi whide,extra, noball nahi gira.fir bhi dono batsman ne centuri puri ki.aur teem match jeet gayi. to dono batsman ne apni centuri puri ki kese?

13 Answers  


All of the tickets for 2 music concerts, X and Y, were either purchased or given away, and the ratio of X tickets to Y was 2 to 1. Of the total number of X tickets and Y tickets, what percentage was purchased? 1) The total number of X tickets and Y tickets, is 240. 2) Of the X tickets, exactly 60% were purchased, and of the Y tickets, exactly 80% were purchased. a) if statement (1) ALONE is sufficient, but statement (2) alone is not sufficient to answer the question. b) if statement (2) ALONE is sufficient, but statement (1) alone is not sufficient to answer the question. c) if BOTH statements (1) and (2) TOGETHER are sufficient to answer the question asked, but NEITHER statement ALONE is sufficient. d) if EACH statement ALONE is sufficient to answer the question asked. e) if statements (1) and (2) TOGETHER are NOT sufficient to answer the question asked, and additional data specific to the problem are needed.

4 Answers   Microsoft,


IDear sir, I have had a data containing of 4 numbers on daily basis for which I would like to know what is the next comming 4 numbers. Based on that data I would like to find out the next comming numbers. Support needed. regards chandramohan gudivada 09849974512 cm116_99@yahoo.com Example : 4513, 4132, 1465, 2941, 1762, 1432, 3412, 5283, 7261, 2643, 4751, 2581, 6513 .... and what is the next number in the sequence?

0 Answers  






there are 6 balls all of same weight except one ball. u r given a weighing balance. in how many trys can u find the ball tat has different weight? (the ball can b heavier or lighter than the rest)

10 Answers   Exilant,


Arrange these words into a romantic word D P G E O D S?

5 Answers   Google,


Montu, Bantu, Chantu and Pintu have pets. Montu says, "If Pintu and I each have a dog, then exactly one of Bantu and Chantu has a dog." Bantu says, "If Chantu and I each have a cat, then exactly one of Montu and Pintu has a dog." Chantu says, "If Montu and I each have a dog, then exactly one of Bantu and Pintu has a cat." Pintu says, "If Bantu and I each have a cat, then exactly one of Bantu and I has a dog." Only one of the four is telling the truth. Who is telling the truth?

2 Answers  


A number of 9 digits has the following properties: ? The number comprising the leftmost two digits is divisible by 2, that comprising the leftmost three digits is divisible by 3, the leftmost four by 4, the leftmost five by 5, and so on for the nine digits of the number i.e. the number formed from the first n digits is divisible by n, 2<=n<=9. ? Each digit in the number is different i.e. no digits are repeated. ? The digit 0 does not occur in the number i.e. it is comprised only of the digits 1-9 in some order. Find the number.

1 Answers  


X is a five letter word.X is a talent in u.if u remove 1st letter X is dead. if u remove 1st 2 letters x is sick.what is X?

11 Answers  


greatest achievement in life

3 Answers  


Three friends divided some bullets equally. After all of them shot 4 bullets the total number of bullets remaining is equal to the bullets each had after division. Find the original number divided.

16 Answers   Directi, Infosys, L&T, Shreyas, TCS, Turing Software,


Categories