Linked list implementation of any circular queue, Data Structure & Algorithms

Assignment Help:

Link list representation of a circular queue is more efficient as it employs space more competently, of course with the added cost of storing the pointers. Program 7 gives the linked list representation of any circular queue.

Program: Linked list implementation of any Circular queue

#include "stdio.h"

struct cq

{     int value;

int *next;

};

typedef struct cq *cqptr cqptr p, *front, *rear;

main()

{

int choice,x;            /* Initialise the circular queue */

cqptr = front = rear = NULL;

printf ("for insertion  enter # and for  deletion  enter $ from the queue")

printf("Enter your choice")

scanf("%d",&choice);

switch (choice)

{

case 1 :

printf ("Enter element for insertion in linked list :");

scanf("%d",&x);

add(&q,x);

break;

case 2 :

delete();

break;

}

}

//* Insertion of element *//

add(int value)

{

struct cq *new;

new = (struct cq*)malloc(sizeof(queue));

new->value = value new->next = NULL;

if (front == NULL)

{

cqptr = new;

front = rear = queueptr;

}

else

{

rear->next = new;

rear=new;

}

}

/*deletion of element */

delete()

{

int delvalue = 0;

if (front == NULL)

{

printf("Queue get empty");

delvalue = front->value;

if (front->next==NULL)

{

free(front);

queueptr = front = rear = NULL;

}

else

{

front=front->next;

 free(queueptr);

queueptr = front;

}

}

}


Related Discussions:- Linked list implementation of any circular queue

C++ function, Write c++ function to traverse the threaded binary tree in in...

Write c++ function to traverse the threaded binary tree in inorder traversal

Linked list implementation of any circular queue, Link list representation ...

Link list representation of a circular queue is more efficient as it employs space more competently, of course with the added cost of storing the pointers. Program 7 gives the link

Applications, Arrays are simple, however reliable to employ in more conditi...

Arrays are simple, however reliable to employ in more condition than you can count. Arrays are utilized in those problems while the number of items to be solved out is fixed. They

Data structures, #quCreate a flowchart to show the process that will allow ...

#quCreate a flowchart to show the process that will allow the implementation of Queue, Enqueue, and Dequeue operations.estion..

The space - time trade off, The best algorithm to solve a given problem is ...

The best algorithm to solve a given problem is one that requires less space in memory and takes less time to complete its execution. But in practice it is not always possible to

Rotations in binary tree, H o w can you r ot a t e a B i n a r y...

H o w can you r ot a t e a B i n a r y Tr e e? E x pl a i n r i g h t a n d l eft r ot a tion s by taking an e x a mpl e.   If after

Representation of data structure in memory, Representation of data structur...

Representation of data structure in memory is known as: Abstract data type

Link list, algorithm for multiplication of two sparse matrices using link l...

algorithm for multiplication of two sparse matrices using link list

Red black tree, red black tree construction for 4,5,6,7,8,9

red black tree construction for 4,5,6,7,8,9

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd