Tag Archives: arraylist-vector

Boundary Traversal of Binary Tree : GeeksforGeeks

Problem link: http://www.geeksforgeeks.org/boundary-traversal-of-binary-tree/

Problem Statement:
Given a binary tree, print boundary nodes of the binary tree Anti-Clockwise starting from the root.
Continue reading

Advertisements

Little Elephant and Lemonade : CodeChef Problem LELEMON

Problem link: http://www.codechef.com/AUG13/problems/LELEMON

Problem Statement:
Little Elephant likes lemonade.

When Little Elephant visits any room, he finds the bottle of the lemonade in that room that contains the greatest number of litres of lemonade and drinks it all.

There are n rooms (numbered from 0 to n-1), each contains C_i bottles. Each bottle has a volume (in litres). The first room visited by Little Elephant was P_0th, the second P_1th, …, the m-th P_{m-1}th room. Note that Little Elephant may visit a room more than once.

Find for Little Elephant the total volume of lemonade he has drunk.
Continue reading

Even Fibonacci numbers: Project Euler Problem 2

Problem link: http://projecteuler.net/problem=2

Problem Statement:
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

1, 2, 3, 5, 8, 13, 21, 34, 55, 89, …

By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
Continue reading