Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please write the codes for the alogrithms . The following hybrid method of repre

ID: 3703655 • Letter: P

Question

please write the codes for the alogrithms .

The following hybrid method of representing a queue has, to a certain extent, the advantages of both the linked and sequential representations. The queue is represented using a linked list of nodes with two pointers, Fand R, to the first and last nodes of the list respectively. The nodes have two fields, ITEM and LINK. LINK is a pointer to the next node in the list and ITEM is an array of M queue entries, where M is some fixed constant. For example, with M-5, suppose that the 12 values a, b, c, £, g, h, k, m, p, q,t,x were inserted into an empty queue in that order and then two values were deleted from the queue. The resulting queue would be represented by the following list The front of the queue is accessed using the pointer F and an index FIRST indicating the position in the array FT ITEM of the first element in the queue. The rear of the queue is accessed using the pointer R and an index LAST indicating the position in the array R ITEM of the last element in the queue. In the above example the value of FIRST would be 3 and the value of LAST would be 2. Notes: () It is assumed here that array elements are indexed starting from 1 (i) An empty queue is represented by Fnil. Give algorithms for the QUEUE and UNQUEUE operations.

Explanation / Answer

ALOGRITHM:1

Create a new_Node with given value and set 'newNode ? next' to NULL.

verify queue is Empty (rear == NULL)

If it is Empty then, set front = new_Node and rear = new_Node.

If it is Not Empty then, set rear ? next = new_Node and rear = new_Node.

ALOGRITHM:2

Vverify queue is Empty (front == NULL).

If it is Empty, then display "NIL!!! " and terminate from the function

If it is Not Empty then, define a Node pointer 'del' and set it to 'front'.

Then set 'front = front ? next' and delete 'del' (free(del)).