Question: please implement findMinEnergyPath and findMinTurnsPath given Wall.h , Queue.h and PQ . h #ifndef WALL _ H #define WALL _ H typedef struct wall *

please implement findMinEnergyPath and findMinTurnsPath given Wall.h
,
Queue.h and PQ
.
h
#ifndef WALL
_
H
#define WALL
_
H
typedef struct wall
*
Wall;
/
/
Rock colours
#define NUM
_
COLOURS
4
/
/
enums are used to create groups of related constants. It is like
/
/
creating multiple #defines, except you can also provide a type name.
typedef enum
{
NONE
=
-
1
,
GREEN
=
0
,
TEAL
=
1
,
PINK
=
2
,
RED
=
3
,
}
Colour;
/
/
Terminal output colours
#define GRN
"
\
x
1
B
[
3
2
m
"
#define CYN
"
\
x
1
B
[
9
6
m
"
#define MAG
"
\
x
1
B
[
9
5
m
"
#define RD
"
\
x
1
B
[
9
1
m
"
#define RESET
"
\
x
1
B
[
0
m
"
struct rock
{
int row;
int col;
Colour colour;
}
;
/
*
*
*
Creates a new blank wall with the given dimensions
*
/
Wall WallNew
(
int height, int width
)
;
/
*
*
*
Frees all memory allocated to the wall
*
/
void WallFree
(
Wall w
)
;
/
*
*
*
Returns the height of the wall
*
/
int WallHeight
(
Wall w
)
;
/
*
*
*
Returns the width of the wall
*
/
int WallWidth
(
Wall w
)
;
/
*
*
*
Adds a rock to the wall
*
If there is already a rock at the given coordinates, replaces it
*
/
void WallAddRock
(
Wall w
,
struct rock rock
)
;
/
*
*
*
Returns the number of rocks on the wall
*
/
int WallNumRocks
(
Wall w
)
;
/
*
*
*
Returns the colour of the rock at the given coordinates, or NONE if
*
there is no rock at those coordinates.
*
/
Colour WallGetRockColour
(
Wall w
,
int row, int col
)
;
/
*
*
*
Stores all rocks on the wall in the given
`
rocks
`
array and returns
*
the number of rocks stored. Assumes that the array is at least as
*
large as the number of rocks on the wall.
*
/
int WallGetAllRocks
(
Wall w
,
struct rock rocks
[
]
)
;
/
*
*
*
Stores all rocks that are within a distance of
`
dist
`
from the given
*
coordinates in the given
`
rocks
`
array and returns the number of rocks
*
stored. Assumes that the array is at least as large as the number of
*
rocks on the wall.
*
/
int WallGetRocksInRange
(
Wall w
,
int row, int col, int dist,
struct rock rocks
[
]
)
;
/
*
*
*
Stores all rocks with the colour
`
colour
`
that are within a distance
*
of
`
dist
`
from the given coordinates in the given
`
rocks
`
array and
*
returns the number of rocks stored. Assumes that the array is at
*
least as large as the number of rocks on the wall.
*
/
int WallGetColouredRocksInRange
(
Wall w
,
int row, int col, int dist,
Colour colour, struct rock rocks
[
]
)
;
/
*
*
*
Prints the wall out in a nice format
*
/
void WallPrint
(
Wall w
)
;
#endif
#ifndef QUEUE
_
H
#define QUEUE
_
H
#include
#include
#include "Wall.h
"
typedef struct rock Item;
typedef struct queue
*
Queue;
/
*
*
*
Creates a new empty queue
*
Complexity: O
(
1
)
*
/
Queue QueueNew
(
void
)
;
/
*
*
*
Frees all resources associated with the given queue
*
Complexity: O
(
n
)
*
/
void QueueFree
(
Queue q
)
;
/
*
*
*
Adds an item to the end of the queue
*
Complexity: O
(
1
)
*
/
void QueueEnqueue
(
Queue q
,
Item it
)
;
/
*
*
*
Removes an item from the front of the queue and returns it
*
Assumes that the queue is not empty
*
Complexity: O
(
1
)
*
/
Item QueueDequeue
(
Queue q
)
;
/
*
*
*
Returns true if the queue is empty, and false otherwise
*
Complexity: O
(
1
)
*
/
bool QueueIsEmpty
(
Queue q
)
;
#en
/
/
Priority queue of edges
/
/
Edges with smaller weight have higher priority
/
/
!
!
!
DO NOT MODIFY THIS FILE
!
!
!
#ifndef PQ
_
H
#define PQ
_
H
#include
#include "Wall.h
"
typedef struct PQRep
*
PQ;
typedef struct rock
*
V;
typedef struct Edge
{
int row;
int col;
int weight;
Colour colour;
}
Edge;
/
*
*
*
Creates a new priority queue
*
Complexity: O
(
1
)
*
/
PQ PQNew
(
void
)
;
/
*
*
*
Frees all memory associated with the given priority queue
*
Complexity: O
(
1
)
*
/
void PQFree
(
PQ pq
)
;
/
*
*
*
Adds an edge to the priority queue
*
Amortised complexity: O
(

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!