void ReverseQueuequeueADT queue program so that a user can r

 void ReverseQueue(queueADT queue);

program so that a user can reverse the existing queue by calling the above function

make one using an array with the follwoing struct

struct queueCDT { queueElementT elements[QueueArraySize]; int head; int tail; };

and one with a link list 

typedef struct cellT { queueElementT value; struct cellT *link; } cellT; struct queueCDT { cellT *head; cellT *tail; }

you do not need to allocate memory or free them.  just use the function to reverse the queue

Solution

Here we can do with the given question and please do let me know if any errors occurs

typedef struct cellT

{

queueElementT value;

struct cellT *link;

}

cellT;

struct queueCDT

{

cellT *head;

cellT *tail;

};

void ReverseQueue(queueADT queue)

{

int i, x, length;

length = QueueLength(queue);

cellT *beg, *end;

queueElementT temp;

beg = queue->head;

for(i = 0; i < (length/2); i++)

{

end = beg;

for(x = 0; x < (length-i) && end->link != NULL; x++)

end = end->link;

temp = beg->value;

beg->value = end->value;

end->value = temp;

}

}

 void ReverseQueue(queueADT queue); program so that a user can reverse the existing queue by calling the above function make one using an array with the follwoi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site