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
Find the smallest number such that if its rightmost digit is placed at its left end, the new number so formed is precisely 50% larger than the original number.
what is Next number in the series is 1 , 2 , 4 , 13 , 31 , 112 , ?
a circle is drawn...roughly in paper...the interviewer asked me to find centre point of circle?the radius,circumference is not known?how to find it?
19 Answers Accenture, HCL, Infosys, Manhattan,
There are four groups of Mangoes, Apples and Bananas as follows: Group I : 1 Mango, 1 Apples and 1 Banana Group II : 1 Mango, 5 Apples and 7 Bananas Group III : 1 Mango, 7 Apples and 10 Bananas Group IV : 9 Mango, 23 Apples and 30 Bananas Group II costs Rs 300 and Group III costs Rs 390. Can you tell how much does Group I and Group IV cost?
An orange colored glass has Orange juice and white colored glass has Apple juice both of equal volumes. 50ml of the orange juice is taken and poured into the white glass. After that similarly, 50ml from the white glass is poured into the orange glass. Of the two quantities, the amount of apple juice in the orange glass and the amount of orange juice in the white glass, which one is greater and by how much?
A farmer needs 8 gallons of water. He has only three unmared buckets, two 6 gallon and one 11 gallon bucket. How can he collect 8 gallons of water using three unmarked buckets? Provide solution with minimal water wastage.
A soldier looses his way in a thick jungle. At random he walks from his camp but mathematically in an interesting fashion. First he walks one mile East then half mile to North. Then 1/4 mile to West, then 1/8 mile to South and so on making a loop. Finally how far he is from his camp and in which direction?
Outside a room there are three light switches. Each switch is connected to a different light bulb inside the room. Each of the three switches can be either 'ON' or 'OFF'. You are allowed to set each switch the way you want it, once, and then enter the room. Your task is to then determine which switch controls which bulb. How can you do it?
At University of Probability, there are 375 freshmen, 293 sophomores, 187 juniors, & 126 seniors. One student will randomly be chosen to receive an award. What percent chance is there that it will be a junior? Round to the nearest whole percent
SkyFi city is served by 6 subway lines - A, E, I, O, U and Z. ? When it snows, morning service on line E is delayed. ? When it rains or snows, service on the lines A, U and Z is delayed both morning and afternoon. ? When the temperature drops below 20 C, afternoon service is cancelled on either line A or line O, but not both. ? When the temperature rises above 40 C, afternoon service is cancelled on either line I or line Z, but not both. ? When service on line A is delayed or cancelled, service on line I is also delayed. ? When service on line Z is delayed or cancelled, service on line E is also delayed. On February 10, it snows all day with the temperature at 18C. On how many lines service will be delayed or cancelled, including both morning and afternoon?
Major Jasbir is forming five-person Special Task Group. The group must contain one leader, two bomb-experts and two soldiers. P, Q and R are possible bomb-experts. R, S and T are possible leaders. U, V and W are possible soldiers. Also, P and R prefers to work with each other in the same team. T prefers to work only if V works. How many different possible Groups, Major Jasbir can make?
In rail road there are some stations. Each station should have tickets to all other stations.If they add some new stations they need 46 more tickets.How many stations are there before and after adding the stations?