Re: analytical Skill for Java Development




"steve" <steve@xxxxxxx> wrote in message
news:dsgh1m07ll@xxxxxxxxxxxxxxxxxxxx
On Wed, 8 Feb 2006 16:42:07 +0800, Adam Maass wrote
(in article <NeednZ7aGsJBM3TenZ2dnUVZ_tWdnZ2d@xxxxxxxxxxx>):


"im" wrote:

1) You have two identical glass balls; when dropped from a certain
height,
they will break. If they do not break, they are re-usable. Your task is
to
find which floor of a 100-storey building the balls will break on.
Describe
in words the algorithm you would use. We are interested in the time
complexity of the algorithm; you should spend the majority of your time
on
this question attempting to optimize the algorithm.

Hint: you can always do a linear search with one of the balls, though
this a
profoundly suboptimal solution to the problem.


2) You have many piles of rocks. The rocks in each pile are identical.
There
are an infinite number of rocks in each pile. You know that the rocks in
one
of the piles are slightly heavier than the rocks in all the other piles.
(Say 1.1 kg instead of 1 kg.) You have a scale that you may use exactly
once. Describe an algorithm to determine which pile contains the heavier
rocks.




well the first one is the same as a simple binary sort. ,took just under
20
seconds to solve that one.

it's the same as having a sorted list , then finding a "break floor"
directly
above a "non break floor"

the second one can be done by just taking a few rocks (same number form
each
pile) adding them together then , looking at the total weight of each
group
of rocks, which ever group is heavier, is the winner.

the infinite part is just shoved in there to mess you up.

that one took longer, the "infinite " threw me.

Amazing.

Forget programming, you're obviously a much better fit for management!

- Oliver


.



Relevant Pages

  • Re: analytical Skill for Java Development
    ... You have two identical glass balls; when dropped from a certain height, ... in words the algorithm you would use. ... are an infinite number of rocks in each pile. ... Describe an algorithm to determine which pile contains the heavier ...
    (comp.lang.java.programmer)
  • Re: analytical Skill for Java Development
    ... You have two identical glass balls; when dropped from a certain height, ... Describe in words the algorithm you would use. ... There are an infinite number of rocks in each pile. ...
    (comp.lang.java.programmer)
  • Re: analytical Skill for Java Development
    ... At each interview, 75% of the alloted ... We are interested in the time complexity of the algorithm; you should spend the majority of your time on this question attempting to optimize the algorithm. ... The rocks in each pile are identical. ... There are an infinite number of rocks in each pile. ...
    (comp.lang.java.programmer)
  • Re: analytical Skill for Java Development
    ... At each interview, 75% of the alloted ... Describe in words the algorithm you would use. ... The rocks in each pile are identical. ... There are an infinite number of rocks in each pile. ...
    (comp.lang.java.programmer)
  • Re: analytical Skill for Java Development
    ... At each interview, 75% of the alloted ... in words the algorithm you would use. ... The rocks in each pile are identical. ...
    (comp.lang.java.programmer)