you have a sequence where each number is a multiple of 2 or 5 (so: 2^i * 5^j). Given the beginning of the sequence as 1,2,4,5,8,10,16... and find a algorithm to calculate the next number in the sequence?
this is generally a combination of three series series 1 :powers of 2(1,2,4,8....) series 2: powers of 5(1,5,25,125....) series 3 All product derived from series 1 and 2 such that they are arranged in increasing order and you can you can exclude the your product with 1 to avoid redundancy i.e. (10,20,40,50,....) And now finally you can derived the series in such a way by selecting the minimum number.
Given a Binary Tree, find vertical sum of the nodes that are in same vertical line. Print all sums through different vertical lines. Examples: 1 / \ 2 3 / \ / \ 4 5 6 7 The tree has 5 vertical lines Vertical-Line-1 has only one node 4 => vertical sum is 4 Vertical-Line-2: has only one node 2=> vertical sum is 2 Vertical-Line-3: has three nodes: 1,5,6 => vertical sum is 1+5+6 = 12 Vertical-Line-4: has only one node 3 => vertical sum is 3 Vertical-Line-5: has only one node 7 => vertical sum is 7 So expected output is 4, 2, 12, 3 and 7
this is generally a combination of three series
ReplyDeleteseries 1 :powers of 2(1,2,4,8....)
series 2: powers of 5(1,5,25,125....)
series 3 All product derived from series 1 and 2 such that they are arranged in increasing order and you can you can exclude the your product with 1 to avoid redundancy i.e. (10,20,40,50,....)
And now finally you can derived the series in such a way by selecting the minimum number.
@Muffadal yeah right...and the working code for this i will post very soon..:)
ReplyDelete