Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please add comments in code to understand use C language 1. Introduction This assignment, which introduces the use of loops, solves the following problem: given

Please add comments in code to understand use C language image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
1. Introduction This assignment, which introduces the use of loops, solves the following problem: given a starting location in a city, how long does it take a "drunken sailor who randomly chooses his direction at each intersection to reach the city's border? You will read input values to set up the problem parameters, run several trials to determine an average number of steps for the sailor to reach the border, and output the results. This problem is an example of a "random walk," a succession of random steps that carn model real world problems like stock price fluctuation or molecules traveling through liquid. The approach is a simple approximation of a Monte Carlo experiment, in which repeated random samples are run to find a numerical result. 2. Deliverables Submit your source file by uploading it directly to your Dropbox folder. Ensure your source file name is prog4 sailor.c. You should submit only the .c file. Failure to meet this specification will reduce your grade, as described in the grading guidelines. 3. Specifications Problem description: The city is organized as a set of M x N blocks. The sailor's position, which must always be an intersection or a point on the border, can be represented as a pair of coordinates (X, Y), where 0sXSM, and 0 sY SN. The example below shows a 4 x 3 city, with the sailor at position (3, 2): Y coord North 2 West Direction East South X coord 4 At each step of a given trial, the sailor will randomly choose a direction and walk until he reaches the next intersection. A trial ends when the sailor reaches one of the city borders. Note that each new trial always uses the same starting point

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Solve part a and b ( for part b make the graph in matlab )

Answered: 1 week ago