subject
Engineering, 06.05.2020 04:44 maddielr17

For this problem, using C, you will implement the Deque ADT with a Circularly-Doubly-Linked List with a Sentinel. As you know, the sentinel is a special link, does not contain a meaningful value, and should not be removed. Using a sentinel makes some linked list operations easier and cleaner in implementation. This list is circular, meaning the end points back to the beginning, thus one sentinel suffices. Implement all functions with the // FIXME... comments in circularList. c .

circularList. h

#ifndef CIRCULAR_LIST_H
#define CIRCULAR_LIST_H

#ifndef TYPE
#define TYPE double
#endif

#ifndef LT
#define LT(A, B) ((A) < (B))
#endif

#ifndef EQ
#define EQ(A, B) ((A) == (B))
#endif

struct CircularList;

struct CircularList* circularListCreate();
void circularListDestroy(struct CircularList* list);
void circularListPrint(struct CircularList* list);
void circularListReverse(struct CircularList* list);

// Deque interface

void circularListAddFront(struct CircularList* list, TYPE value);
void circularListAddBack(struct CircularList* list, TYPE value);
TYPE circularListFront(struct CircularList* list);
TYPE circularListBack(struct CircularList* list);
void circularListRemoveFront(struct CircularList* list);
void circularListRemoveBack(struct CircularList* list);
int circularListIsEmpty(struct CircularList* list);

#endif

circularListMain. c

#include "circularList. h"
#include

int main()
{
struct CircularList* deque = circularListCreate();
circularListAddBack(deque, (TYPE)1);
circularListAddBack(deque, (TYPE)2);
circularListAddBack(deque, (TYPE)3);
circularListAddFront(deque, (TYPE)4);
circularListAddFront(deque, (TYPE)5);
circularListAddFront(deque, (TYPE)6);
circularListPrint(deque);
printf("%g\n", circularListFront(deque));
printf("%g\n", circularListBack(deque));

circularListRemoveFront(deque);
circularListRemoveBack(deque);
circularListPrint(deque);

circularListReverse(deque);
circularListPrint(deque);

circularListDestroy(deque);

return 0;
}

circularList. c

#include
#include
#include
#include "circularList. h"

// Double link
struct Link
{
TYPE value;
struct Link * next;
struct Link * prev;
};

struct CircularList
{
int size;
struct Link* sentinel;
};

/**
* Allocates the list's sentinel and sets the size to 0.
* The sentinel's next and prev should point to the sentinel itself.
*/
static void init(struct CircularList* list)
{
// FIXME: you must write this
}

/**
* Creates a link with the given value and NULL next and prev pointers.
*/
static struct Link* createLink(TYPE value)
{
// FIXME: you must write this
return NULL;
}

/**
* Adds a new link with the given value after the given link and
* increments the list's size.
*/
static void addLinkAfter(struct CircularList* list, struct Link* link, TYPE value)
{
// FIXME: you must write this
}

/**
* Removes the given link from the list and
* decrements the list's size.
*/
static void removeLink(struct CircularList* list, struct Link* link)
{
// FIXME: you must write this
}

/**
* Allocates and initializes a list.
*/
struct CircularList* circularListCreate()
{
struct CircularList* list = malloc(sizeof(struct CircularList));
init(list);
return list;
}

/**
* Deallocates every link in the list and frees the list pointer.
*/
void circularListDestroy(struct CircularList* list)
{
// FIXME: you must write this
}

/**
* Adds a new link with the given value to the front of the deque.
*/
void circularListAddFront(struct CircularList* list, TYPE value)
{
// FIXME: you must write this
}

/**
* Adds a new link with the given value to the back of the deque.
*/
void circularListAddBack(struct CircularList* list, TYPE value)
{
// FIXME: you must write this
}

/**
* Returns the value of the link at the front of the deque.
*/
TYPE circularListFront(struct CircularList* list)
{
// FIXME: you must write this
return 0;
}

/**
* Returns the value of the link at the back of the deque.
*/
TYPE circularListBack(struct CircularList* list)
{
// FIXME: you must write this
return 0;
}

/**
* Removes the link at the front of the deque.
*/
void circularListRemoveFront(struct CircularList* list)
{
// FIXME: you must write this
}

/**
* Removes the link at the back of the deque.
*/
void circularListRemoveBack(struct CircularList* list)
{
// FIXME: you must write this
}

/**
* Returns 1 if the deque is empty and 0 otherwise.
*/
int circularListIsEmpty(struct CircularList* list)
{
// FIXME: you must write this
return 0;
}

/**
* Prints the values of the links in the deque from front to back.
*/
void circularListPrint(struct CircularList* list)
{
// FIXME: you must write this
}

/**
* Reverses the deque.
*/
void circularListReverse(struct CircularList* list)
{
// FIXME: you must write this
}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 03.07.2019 14:10
Amass of m 1.5 kg of steam is contained in a closed rigid container. initially the pressure and temperature of the steam are: p 1.5 mpa and t 240°c (superheated state), respectively. then the temperature drops to t2= 100°c as the result of heat transfer to the surroundings. determine: a) quality of the steam at the end of the process, b) heat transfer with the surroundings. for: p1.5 mpa and t 240°c: enthalpy of superheated vapour is 2900 kj/kg, specific volume of superheated vapour is 0. 1483 m/kg, while for t 100°c: enthalpy of saturated liquid water is 419kj/kg, specific volume of saturated liquid water is 0.001043m/kg, enthalpy of saturated vapour is 2676 kj/kg, specific volume of saturated vapour is 1.672 m/kg and pressure is 0.1 mpa.
Answers: 3
question
Engineering, 03.07.2019 14:10
If the thermal strain developed in polyimide film during deposition is given as 0.0044. assume room temperature is kept at 17.3 c, and thermal coefficient of expansion for the film and the substrate are 54 x 10^-6c^-1 and 3.3 x 10^-6c^-1respectively. calculate the deposition temperature.
Answers: 3
question
Engineering, 04.07.2019 18:10
Burgers vector is generally parallel to the dislocation line. a)-true b)-false
Answers: 2
question
Engineering, 04.07.2019 18:10
An ideal otto cycle with air as the working fluid has a compression ratio of 8. the minimum and maximum temperatures in the cycle are 300 k and 1340 k. use constant specific heats at room temperature to determine (a) the amount of heat transferred to the air during the heat- addition kj/kg, (b) the thermal efficiency, and (c) the thermal efficiency of a carnot cycle ope limits. process, in rating between the same temperature
Answers: 2
You know the right answer?
For this problem, using C, you will implement the Deque ADT with a Circularly-Doubly-Linked List wit...
Questions
question
Mathematics, 18.10.2019 23:30
question
Mathematics, 18.10.2019 23:30
question
History, 18.10.2019 23:30
Questions on the website: 13722360