***Attached is base code to help you get started. You must use this base project/code and any functions outlined in this document***Introduction:You are a member of a team developing a mars rover. Your job is to develop the path-finding system and it is crucially important that you minimise energy consumption. Given a digital elevation map of the terrain, you must identify the path between two points of least energy cost. Specification: You will be given a digital elevation map (DEM) and an equation for calculating energy use in moving from one elevation to another adjacent elevation. To simplify the task you consider only the discrete positions and elevations represented by the DEM and will consider only moves in the four cardinal directions (NSEW). You will be provided with code that contains some code to get you started. int** make_dem(int size, int roughness); This code generates a 2D array of ints representing the heights of a square area of the terrain. The size should be one more than a power of 2 (e.g. 9, 17, 33, 65) and roughness values around 4xsize work well. You will also notice that the code sets a random seed this can be set to a fixed value for testing purposes (to ensure that you always get the same map). int cost_funcA(int diff); int cost_funcB(int diff); These are two different cost functions for calculating the energy use from moving between two adjacent points in the DEM with the given height difference. The first will be used for part A and will always produce a positive number. The second is used for part B and includes a term for regenerative breaking hence it can generate a negative value when going downhill. There are also two functions for printing DEMs and markers: void print_2D(int** array2D, int size); void print_2D_ascii(int** array2D, int size); These functions take a DEM where heights are expected to be in the range 0-99. Any negative value will be printed as a marker. You should use these functions to visualise your solution (setting the height of positions that are on your path to -1). You can use either print function. The first function gives more detail, but the second is a bit easier to interpret. (NOTE: these function print with the y axis going across the page and the x axis going down). Your first task is to use these functions to generate an adjacency list graph representation of the terrain. Start by generating a DEM, then use the cost functions to build the weighted graph. The vertex number of a given x,y position in the map should be calculated as x*size+y. So, for example, the following DEM: 49 51 51 56 57 46 47 50 52 54 45 47 48 50 49 46 46 47 47 47 45 45 45 45 47 Would result in an edge from vertex 0 to vertex 5 (in bold) with weight calculate using cost_funcA(46-49). You must use the following data structures to represent the graph as an adjacency list: typedef struct edge{ int to_vertex; int weight; } Edge; typedef struct edgeNode{ Edge edge; struct edgeNode *next; } *EdgeNodePtr; typedef struct edgeList{ EdgeNodePtr head; } EdgeList; typedef struct graph{ int V; EdgeList *edges; } Graph; ***To help you get started, follow these steps outlined below to help you progress in your assignment*** Part A: For part A you will use cost_funcA which always produces positive edge weights to generate the adjacency list. You should then implement Dijkstras algorithm based on the pseudocode on Wikipedia (https://en.wikipedia.org/wiki/Dijkstra%27s_algorit…). While a priority-queue implementation would be best for our scenario, you should instead use a simple search to find the nearest vertex. Your submission must contain a main function that: generates a DEM converts it to an adjacency list using const_funcA calculates the shortest paths from vertex 0 (top left in the DEM) reconstructs the path to the last vertex (bottom right in the DEM) creates a copy of the DEM with the heights changed to -1 for any vertex on the path prints the DEM to show the path Part B: For part B you will use cost_funcB, which may produce negative edge weights (but no negatively weighted cycles, to build a new adjacency list. You should then implement the Floyd-Warshall algorithm based on the pseudocode on Wikipedia (https://en.wikipedia.org/wiki/Floyd%E2%80%93Warsha…). Your solution must follow this pseudocode as closely as possible (note however, that in our graph specification the vertex labels start at 0). Your submission must contain a main function that: includes all of the code from part A calculates a new adjacency list using const_funcB calculates all shortest paths using Floyd-Warshall reconstructs the path from the first to last vertex (top-left to bottom-right) creates a copy of the DEM with the heights changed to -1 for any vertex on the path prints the DEM to show the path Part B does NOT have to be in a separate project. I have not specified file names and code structure. You should endeavour to make your code as general, and hence reusable, as possible. Code should be organised into functions and files that make reuse easy. Functions and data structures should be properly commented so that another programmer will know how to use them. The assessment steps for this task are: 1. Implement code to construct an adjacency list representation of a graph 2. Implement Dijkstras algorithm to find shortest paths 3. Implement Floyd-Warshall algorithm to find shortest paths

kit205assig2base.zip

Unformatted Attachment Preview

Don't use plagiarized sources. Get Your Custom Essay on

[C Programming] Implement code to construct an adjacency list representation of a graph

Just from $13/Page

…

Purchase answer to see full

attachment

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

Professional and Experienced Academic Writers

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

24/7 Customer Support

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

Essays

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.

Admissions

Admission Essays & Business Writing Help

An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.

Reviews

Editing Support

Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.

Reviews

Revision Support

If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.