| re: Data Structure problem
On 8 Aug 2005 01:11:54 -0700, Joy <pp_5555@yahoo.com> wrote:
[color=blue]
> 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.[/color]
Please give us the email address of the person who set the homework so
we can mail the result directly.
[color=blue]
> 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.[/color]
Simple. Joe gets off the bike and wanders around in the road until he
is run over by a car. End of problem. Driving or riding a bike while
unable to see as far as the side of the road is an offence in most
civilised countries so if he's lucky he might get arrested first.
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
int main(void)
{
srand((int)time(NULL));
if (rand() & 1)
printf("Joe is dead\n");
else
printf("Joe is in prison\n");
return 0;
}
(Using time(NULL) to initialise srand() is not totally portable in C,
although it is on POSIX systems, but there is no other portable way of
getting anything close to a random seed either...)
[color=blue]
> left<---- ------>right
> Example:-------------------------------------------------
>
> Road (Joe)in the middle of the road.
>
> --------------------------------------------------[/color]
Example:
_____
_/o |
|_______|
O-/-< o o
--------------------------------------------------
Joe having been knocked over by a car (you can't see the bike, it's
hidden behind Joe's body). Actually it looks more like a van than a
car, because I'm not a very good artist, but you should get the idea.
For homework you should adapt the program I gave above to print out a
better picture, and also pictures of Joe in hospital, Joe's funeral, Joe
getting arrested, Joe in court, Joe in prison, etc. according to the
random number.
(Or, to put it another way, your question is off topic and you knew it,
and you should do your own homework. However, I couldn't resist the
story of poor hungry Joe...)
Chris C |