473,413 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Data Structure problem

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.

Nov 15 '05 #1
2 1115
On 8 Aug 2005 01:11:54 -0700, Joy <pp*****@yahoo.com> wrote:
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.
Please give us the email address of the person who set the homework so
we can mail the result directly.
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.
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...)
left<---- ------>right
Example:-------------------------------------------------

Road (Joe)in the middle of the road.

--------------------------------------------------


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
Nov 15 '05 #2
>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.
Joe keeps going in one direction until he sees a pancake shop (or
starves or runs out of gas). This means he's now AT a different
pancake shop, so he drives around in small circles until he hits
it (even though he, for some odd reason, can't see it, probably due
to some darn fool executing fflush(stdin).) Then he can order
pancakes and pay for the damage.

Gordon L. Burditt

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.

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yee young han | last post by:
I need a fast data structure and algorithm like below condition. (1) this data structure contain only 10,000 data entry. (2) data structure's one entry is like below typedef struct _DataEntry_...
1
by: Da-Breegster | last post by:
Hi. I'm attempting to write a roguelike (think nethack, crawl, angband, tome, adom, and yes, I suppose even rogue) in Perl and I've ran into a problem regarding the data structure for the map and...
4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
11
by: theshowmecanuck | last post by:
As a matter of academic interest only, is there a way to programmatically list the 'c' data types? I am not looking for detail, just if it is possible, and what function could be used to...
10
by: Bart Goeman | last post by:
Hi, I have a question about how to put redundant information in data structures, initialized at compile time. This is often necessary for performance reasons and can't be done at run time (data...
5
by: Alfonso Morra | last post by:
Hi, I am writing a messaging library which will allow me to send a generic message structure with custom "payloads". In many cases, a message must store a non-linear data structure (i.e....
1
by: saleem | last post by:
Dear friends, I am working on the problem which deals with the data management of requests and how should we match the responses for the requests to compare the correct Response. my problem...
3
by: vinayak | last post by:
Hi I am displaying data in Datagrid in ASP.NET with Edit/Update functionality for each row. On the same page I have 2 Button controls which submits the request to server. These button controls...
29
by: zoltan | last post by:
Hi, The scenario is like this : struct ns_rr { const u_char* rdata; }; The rdata field contains some fields such as :
30
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.