Question

1 Introduction Consider a perfectly square, infinite grid. Define the driving distance between two points with integer coordi
3. There are no one-way streets in our grid. You can travel in either direction along any gridline. 4. Consider coming up w

you have to show both algorithm and flowchart

you can just do the flow chart
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Since the street is not one – way, we can easily find the distance.

Algorithm :

inputs : integer variables, p{11,41} and q{<2,42}.

begin :

di = distance between (21,71) and (12, y1); i.e, di = sqrt((:21 – 22))

da = distance between 12, y2) and (22, yı); i.e,dı = sqrt((y2 – yı))

d = di + d2:

return d:

\textbf{end}

Flowcharti

START inputs: P(X1,Y1) and q(X2,72) d1 = sqrt((x1-x2)2) d2 = sqrt((71-72)2) d = d1 + d2 return d END

Algorithm Explanation :

At first, we take two inputs P(x1,y1) and Q(x2,y2) which are the coordinates of the two points which is to be travelled by the car. As the gridlines are square shaped and these are the only way to drive, therefore the shortest distance between P and Q along the gridlines will the sum of distances from (x1,y1) and (x2,y1) AND (x2,y2) and (x2,y1).

Add a comment
Know the answer?
Add Answer to:
you have to show both algorithm and flowchart you can just do the flow chart 1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The straight-line distance of two points (x1, y1) and (x2, y2) in a Cartesian plane can be calculated by the formula: Distance of two points Your task is to create an algorithm using flowchart to solve this problem

    The straight-line distance of two points (x1, y1) and (x2, y2) in a Cartesian plane can be calculated by the formula:Your task is to create an algorithm using flowchart to solve this problem. in your algorithm, you need to prompt user to enter the value of x1, x2. y1 and y2.

  • Please help me with this answer. Performance Comparison for Dijkstra Algorithm and Bellman-Ford Algorithm Problem Description...

    Please help me with this answer. Performance Comparison for Dijkstra Algorithm and Bellman-Ford Algorithm Problem Description The shortest path problem is one of most important problems in graph theory and computer science in general. Shortest path problem is one of typical optimization problems. Given a graph G = (V,E), the goal is to nd a minimum cost path from s → t, s,t ∈ V . This variant is called one-to-one shortest path problem. Other variants are one-to-all (compute shortest...

  • Can I get some help with this problem? Can someone show how do this in C?...

    Can I get some help with this problem? Can someone show how do this in C? Thank you for your help. Write a C object-oriented program that reads the coordinates of two points in the plane and shows the distance between them. In order to do that implement the class Point.    Point{       float x;       float y;       Point(): void       set (float x, float y): void       getX( ): float (optional implementation)       getY( ): float (optional...

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    Can you send the code and the screenshot of it running? 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...

  • 1 Cat and Mouse [5 marks] You and a friend both purchase dune buggies. These off-road vehicles ar...

    Can anyone pls help, a,b,c (i,ii,iii)? Thank You 1 Cat and Mouse [5 marks] You and a friend both purchase dune buggies. These off-road vehicles are excellent for driving on sand. To test out your new rides, you decide to play a game of cat and mouse in a desert with sand dunes Both of you start in the same location. You give your friend a head start, then attempt to catch up to them. To give you a chance,...

  • You and a friend both purchase dune buggies. These off-road vehicles are excellent for driving on...

    You and a friend both purchase dune buggies. These off-road vehicles are excellent for driving on sand. To test out your new rides, you decide to play a game of cat and mouse in a desert with sand dunes. Both of you start in the same location. You give your friend a head start, then attempt to catch up teo them. To give you a chance, they radio you their coordinates several times You may assume that both dune buggies...

  • just the 3 boxes I got wrong, and just the answer.   You do have to show...

    just the 3 boxes I got wrong, and just the answer.   You do have to show your work MY NOTES 1.5/3.5 POINTS PREVIOUS ANSWERS LARCALC9 2.6.025. A ladder 25 feet long is leaning against the wall of a house. The base of the ladder is pulled away from the wall at a rate of 2 feet per second. (a) What is the velocity of the top of the ladder when the base is given below? 15 feet away from the...

  • Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task spe...

    Task 1 Draw a flowchart that presents the steps of the algorithm required to perform the task specified. You can draw the flowcharts with a pen/pencil on a piece of paper and scan it for submission. Please ensure that the scanned file and your handwriting are clear and legible. However, it is preferable to draw flowcharts using a drawing software. Here are links to some free drawing tools https://www.draw.io/ www.lucidchart.com http://dia-installer.de/ https://pencil.evolus.vn/ ---------------------------------DON'T NEED THE PYTHON CODE... JUST THE ALGORITHM...

  • Consider the situation shown below in which you have two plates of radius R = 1.25 cm which have ...

    Consider the situation shown below in which you have two plates of radius R = 1.25 cm which have between them an electric field given by一4t V/m. The electric field is 0 everywhere except between those plates. You are interested in calculating the magnetic field a distance r 9.5 cm away from the midpoint between the plates We'll walk through the various pieces of Ampere's Law through the course of the problem. a. What is the enclosed current within the...

  • Please help me do both problems if you can, this is due tonight and this is...

    Please help me do both problems if you can, this is due tonight and this is my last question for this subscription period. (Thank you) Euler's method for a first order IVP y = f(x,y), y(x) = yo is the the following algorithm. From (20, yo) we define a sequence of approximations to the solution of the differential equation so that at the nth stage, we have In = {n-1 +h, Yn = Yn-1 +h. f(xn-1, Yn-1). In this exercise...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT