Data Structure Problem

J

Joy

Hi,
I have a problem in data structures which most of the people find a
homework but that it is and I am sorry for that.
I am stuck in this one .Please try to help me , just provide me the
outline how to analyse this problem.


Question : A man Joe has a habbit of eating pancakes & driving
bikes.Once he went for outside by his bike,now he is EXACTLY IN THE
MIDDLE OF A ROAD his stomach is crying for pancakes and also his
contact lenses are full of dirt.Now HE CANNOT SEE A PANCAKE SHOP UNTILL



HE REACH THE PANCAKE SHOP EXACTLY BEFIRE IT.
Now please provide me the algorithm for finding the pancake shop which
is nearer to JOE & also tell me how can I calculate time and space
complexity.


Note: Information given as if he goes to the right side it is
considered as 1unit,2unit....and son on and if he chooses left then
-1unit,-2unit...and so on.


II)Second part of the problem says that if Joe wants to flip a coin for



,in which direction(left or right) he has to move.
Then what happens to the code/algorithm.


left<---- ------>right
Example:----------------------­­---------------------------


Road (Joe)in the middle of the road.


------------------------------­­--------------------


Thanks
Paul.
 
U

ulrich

Question : A man Joe has a habbit of eating pancakes & driving
bikes.Once he went for outside by his bike,now he is EXACTLY IN THE
MIDDLE OF A ROAD his stomach is crying for pancakes and also his
contact lenses are full of dirt.Now HE CANNOT SEE A PANCAKE SHOP UNTILL
HE REACH THE PANCAKE SHOP EXACTLY BEFIRE IT.
Now please provide me the algorithm for finding the pancake shop which
is nearer to JOE & also tell me how can I calculate time and space
complexity.

assuming that BEFIRE means BEFORE, this is an idio*** example, sorry. if
joe cannot see the shop until he has reached it, he cannot decide in which
direction to go, because he simply can not know where the nearer shop is.

time and space complexity???

for flipping a coin, use a random number generator: rand() in <cstdlib>,
iirc.
 
M

Magnus Jonneryd

Joy said:
Question : A man Joe has a habbit of eating pancakes & driving
bikes.Once he went for outside by his bike,now he is EXACTLY IN THE
MIDDLE OF A ROAD his stomach is crying for pancakes and also his
contact lenses are full of dirt.Now HE CANNOT SEE A PANCAKE SHOP UNTILL

HE REACH THE PANCAKE SHOP EXACTLY BEFIRE IT.
Now please provide me the algorithm for finding the pancake shop which
is nearer to JOE & also tell me how can I calculate time and space
complexity.


Thanks
Paul.

What do you mean? If he can't see the shop he'll just have to try going in
one direction until he reaches the shop or not (if he doesn't reach it
he'll have to turn back). Is this really all the information you were
given? My guess would be that you need to re-read the assignment.

Just as an afterthought, should you really be riding around on bikes if your
vision is so impaired?

Good luck.
 
J

Joy

Magnus said:
What do you mean? If he can't see the shop he'll just have to try going in
one direction until he reaches the shop or not (if he doesn't reach it
he'll have to turn back). Is this really all the information you were
given? My guess would be that you need to re-read the assignment.

Just as an afterthought, should you really be riding around on bikes if your
vision is so impaired?

Good luck.
Thanks Magnus,
For your kind reply.
Yes this is all I have given in my placement exam for TRILOGY .
Regards
Paul.
 
M

Magnus Jonneryd

Joy said:
Thanks Magnus,
For your kind reply.
Yes this is all I have given in my placement exam for TRILOGY .
Regards
Paul.

If that's all the information you were given you'll have to start to make
some assumptions about your search space. For one there has to some
limitation on the search area, if not, Joe can run around for ever looking
for the closest shop (there's a lot of algorithms on graph traversal you
can take a look at). Oh, and another thing, did you mean that he can either
cross the road to the left or to the right, not go back or forward? If that
is so then the problem of finding the closest shop should be quite
straightforward, if there's a store then voilá, it has to be the closest
one since he started from exactly the middle of the road, if not, go back.

Perhaps you should ask your professor for some clarification?

Have fun.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,208
Latest member
RandallLay

Latest Threads

Top