## Hi5 Interview Questions

- 1of 1 vote

AnswersGiven a tree having N vertices and N-1 edges where each edges is having one of either red(r) or black(b) color. I need to find how many triplets(a,b,c) of vertices are there, such that on the path from vertex a to b, vertex b to c and vertex c to a there is atleast one edge having red color.

- praveend806 June 19, 2014 in India

It should be noted that (a,b,c), (b,a,c) and all such permutation will be considered as the same triplets.

EXAMPLE : Let N=5 and edges with colors are as follow :

1 2 b

2 3 r

3 4 r

4 5 b

Here answer will be 4.

EXPLANATION : (2,3,4) is one such triplet because on all paths i.e 2 to 3, 3 to 4 and 2 to 4 there is atleast one edge having read color. (2,3,5), (1,3,4) and (1,3,5) are such other triplets.| Report Duplicate | Flag | PURGE

Hi5 Student student Algorithm - 0of 0 votes

AnswerCreate a class Graph, which must represent the graph data structure in java. What will be the difference between directional and unidirectional Graph? How would you represent the weight of the edges?

- Lyubomir December 21, 2012 in United States| Report Duplicate | Flag | PURGE

Hi5 Java Developer - 0of 0 votes

AnswersCode quicksort

- Jon Horseman August 26, 2009| Report Duplicate | Flag | PURGE

Hi5 Accountant Algorithm - 0of 0 votes

AnswersLets say A is a friend of B and B is a friend of C then A and C are two degree friends. So we have to implement a function that takes two friends and return true if they are 2 degree friends. How will you implement this function efficiently.

- gauravk.18 May 04, 2008| Report Duplicate | Flag | PURGE

Hi5 Software Engineer / Developer Algorithm - 0of 0 votes

AnswersWhat is stack. How do you implement it. Now lets say we want to add a new function called min which return the min element on the stack along with push and pop. Like push and pop this min function should also be a constant time operation how will u do it.

- gauravk.18 May 04, 2008| Report Duplicate | Flag | PURGE

Hi5 Software Engineer / Developer Algorithm - 1of 0 votes

AnswersBackground:

- gauravk.18 May 04, 2008

For any perimeter of a rectangle, there may be multiple different dimensions that result in that specific

perimeter. When there are multiple dimensions for the same perimeter, there may also be multiple areas. In other words, any one perimeter can result in different areas depending on the possible combinations of dimensions that can make that perimeter.

Definition:

A dimension or instance of dimensions for a rectangle is a pair of length and width values. A dimension with length 5 and width 4 is considered the same as a dimension with length 4 and width 5. The area of a rectangle is the length multiplied by the width. The perimeter of a rectangle is equal to the sum of the lengths of all 4 sides or the sum of 2 multiplied by the width and 2 multiplied by the length.

Requirement:

A finite set of possible perimeters of a rectangle exist given a maximum perimeter, minimum length of any side, and the constraint that all sides are whole numbers; we will call this set U. Find the subset of perimeters in set U where all of the possible dimensions for a perimeter in the subset have areas common with the areas of one or more other perimeters in set U. Your program should take the minimum length of any side and the maximum perimeter, respectively, as command line arguments and output a comma separated list of the perimeters that meet the criteria explained above, sorted from lowest to highest. The program should be submitted in a single Java class with an implemented main function that provides the correct output given the two input arguments.

Example:

javac YourClass.java

java YourClass 1 64

10,14,18,20,22,26,30,34

Please make sure your program can be run with the exact syntax above. You can name the class anything you like, but the class name will be passed to a program that will compile it and then run a set of tests on the resulting program. It is important that your class will compile and run from within a local directory, not a package directory.| Report Duplicate | Flag | PURGE

Hi5 Software Engineer / Developer Coding Algorithm - 0of 0 votes

AnswerGiven n cities with their populations, suggest an algorithm to pick up one of the cities randomly such that more the population of city is more chance it stands to be picked. Assume you can use an inbuilt random generator function from the language library.

- gauravk.18 April 04, 2008| Report Duplicate | Flag | PURGE

Hi5 Software Engineer / Developer Algorithm

**CareerCup**is the world's biggest and best source for software engineering interview preparation. See all our resources.

Open Chat in New Window