Unregistered

26-12-2012, 01:38 AM

Find the logic for following conversion and find conversion

1234->11110

3216->9678

5486->24662

9832->?

1234->11110

3216->9678

5486->24662

9832->?

View Full Version : help

Unregistered

26-12-2012, 01:38 AM

Find the logic for following conversion and find conversion

1234->11110

3216->9678

5486->24662

9832->?

1234->11110

3216->9678

5486->24662

9832->?

anup

26-12-2012, 09:42 AM

This open forum is for discussions related to programming questions only.

Thanks,

Anup

Thanks,

Anup

Unregistered

26-12-2012, 02:58 PM

Suppose there is a bicycle race and the distance of 200 Km to covered in order to complete a race. There are 3 check posts at every 50 Km named as chkp1, chkp2, chkp3 respectively. There is normal plane road from Start to chkp1, incline road from chkp1 to chkp2, decline road from chkp2 to chkp3 and normal road from chkp3 to Finish line.

Suppose Rider has 5000 Kcal with him during the start of a race. If the rider rides bicycle on normal plane road at 50 Km/hr he loses 5000 Kcal and at 40 Km/hr – 3000 Kcal and at 30 Km/hr – 2000 Kcal respectively. So on incline road he loses 10 % more energy and on decline road he saves 20 % energy for above speeds. Whenever rider reaches at every checkpost he receives maximum 3000 Kcal of energy from the energizer.

The rider has to keep in mind he must have at least 500 Kcal energy while reaching at every check post otherwise he will get faint. So find out in how much minimum time he will need to win the race so that he have at least 2000 Kcal of energy after completing the race, if so write a program or an algorithm for the same. And what should be the average speed of the bicycle for reaching at every check post and to the finishing line.

Suppose Rider has 5000 Kcal with him during the start of a race. If the rider rides bicycle on normal plane road at 50 Km/hr he loses 5000 Kcal and at 40 Km/hr – 3000 Kcal and at 30 Km/hr – 2000 Kcal respectively. So on incline road he loses 10 % more energy and on decline road he saves 20 % energy for above speeds. Whenever rider reaches at every checkpost he receives maximum 3000 Kcal of energy from the energizer.

The rider has to keep in mind he must have at least 500 Kcal energy while reaching at every check post otherwise he will get faint. So find out in how much minimum time he will need to win the race so that he have at least 2000 Kcal of energy after completing the race, if so write a program or an algorithm for the same. And what should be the average speed of the bicycle for reaching at every check post and to the finishing line.

anup

26-12-2012, 03:17 PM

Guest,

This question does not require an algorithm, it is simple mathematics. This question is vague too and lacks detail:

You have specified speed and total energy lost, it has to be energy rate i.e. Kcal per hour traveling at a speed of X Km/hr.

If 50, 40 and 30 are the only speeds and the question asks for one common average speed, you can simulate at all of these speeds in order and get your answer.

I would again re-iterate that this question is not related to programming, rather mathematics! Please only post programming related question here.

Thanks,

Anup

This question does not require an algorithm, it is simple mathematics. This question is vague too and lacks detail:

You have specified speed and total energy lost, it has to be energy rate i.e. Kcal per hour traveling at a speed of X Km/hr.

If 50, 40 and 30 are the only speeds and the question asks for one common average speed, you can simulate at all of these speeds in order and get your answer.

I would again re-iterate that this question is not related to programming, rather mathematics! Please only post programming related question here.

Thanks,

Anup

Unregistered

26-12-2012, 11:49 PM

Suppose you have given a tree with N nodes and weights associated with each node and edges are given(present in the tree).You have to remove two edges such that the sum of weights of three trees created is maximum.

anup

27-12-2012, 09:31 AM

Guest,

Please post questions with proper headers and footers (at least sign off with your name) otherwise we may delete questions. For a n-ary or generic tree a simple (naive) solution is to sum up edge weights leading up to each of the nodes with leaf-nodes as zero weight. You can now carry out an exhaustive search starting from the root node and working your way downward toward the leaves. Each time you remove two edges you will subtract from the root node the two node weights + two removed edge weights to arrive at the weight of the tree rooted at 'root'. The remaining two tree weights are the weights of the node roots. Since you have already precomputed node weights you will not have to recurse each time in the tree, avoiding exponential complexity over edges. This will lead to a O(E^2) complexity where 'E' is the number of edges. There may be other more efficient solutions, however, I will need to think through it.

I will encourage you to post a more efficient solution on this forum.

Thanks,

Anup

Please post questions with proper headers and footers (at least sign off with your name) otherwise we may delete questions. For a n-ary or generic tree a simple (naive) solution is to sum up edge weights leading up to each of the nodes with leaf-nodes as zero weight. You can now carry out an exhaustive search starting from the root node and working your way downward toward the leaves. Each time you remove two edges you will subtract from the root node the two node weights + two removed edge weights to arrive at the weight of the tree rooted at 'root'. The remaining two tree weights are the weights of the node roots. Since you have already precomputed node weights you will not have to recurse each time in the tree, avoiding exponential complexity over edges. This will lead to a O(E^2) complexity where 'E' is the number of edges. There may be other more efficient solutions, however, I will need to think through it.

I will encourage you to post a more efficient solution on this forum.

Thanks,

Anup