Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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;

}

}

}

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9619076

Have any Question?


Related Questions in Computer Engineering

Explain the difference between penetration tests and

Explain the difference between penetration tests and security tests. Emphasize that this book will explain things from a security testing perspective.

A report claims that for the investment portfolios with a

A report claims that for the investment portfolios with a single stock had a standard deviation of 0.57, while the returns for portfolios with 31 stocks have a standard deviation of 0.325. Explain how the standard deviat ...

Software quality is a difficult term to define it means

Software quality is a difficult term to define. It means many things to many different people. Consider the following What do you think software quality is composed of? Why is quality so difficult to define? Do different ...

Why is a secure random number different than a

Why is a secure random number different than a statistically random number in security and if it weren't securely random everything that it could impact. For example, think of everywhere that we rely on them being secure ...

Question you are shopping for a new computer you will be

Question: You are shopping for a new computer. You will be using the computer for everything you do, such as school, socializing, gaming, and communicating. Your total budget before tax is $1,000.00. Considerations: • Bu ...

Total cholesterol in children 10 to 15 years of age is

Total cholesterol in children 10 to 15 years of age is assumed to follow a normal distribution of 191 and a standard deviation 22.4. What proportion of children 10 to 15 years of age has total cholesterol between 180 and ...

Solve the following one 1 self-check problems on paper and

Solve the following one (1) Self-Check problems on paper and bring your sheet of paper to your section on Thursday: Write a function called grades that takes a list of tuples as a parameter. Each tuple in this list conta ...

Can someone help please i had help but its not working

Can someone help please. I had help but it's not working. PLEASE DO BOTH PARTS! Please make sure to read the entire problem and do both parts PLEASE DO NOT write it out I have a hard time reading people's hand writing pl ...

Question using an organization of your choicedevelop a

Question: Using an organization of your choice: Develop a Complete Disaster Recovery Plan to be submitted to the executive board of your company. Please note that this is a formal writing, all references (peer-reviewed) ...

Question suppose a large array is maintained with the

Question : Suppose a large array is maintained with the following policy. The array is initially sorted. When new elements are added, they are inserted at the end of the array and counted. Whenever the number of new elem ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As