Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

A circular queue can be implemented through arrays or linked lists. Program 6 gives the array implementation of any circular queue.

Program 6: Array implementation of any Circular queue

include "stdio.h"

void add(int);

void deleteelement(void);

int max=10;         /*the maximum limit for queue has been set*/

static int queue[10];

int front=0, rear=-1; /*queue is initially empty*/

void main()

{

int choice,x;

printf ("Enter # for insertion & $ for removal of front the queue and * for exit");

printf("Enter your choice");

 scanf("%d",&choice);

switch (choice)

{

case 1 :

printf ("Enter element for insertion in queue:");

scanf("%d",&x);

add(x);

break;

case 2 :

deleteelement();

break;

}

}

void add(int y)

{

if(rear == max-1)

rear = 0;

else

rear = rear + 1;

if( front == rear && queue[front] != NULL)

printf("Queue Overflow");

else

queue[rear] = y;

}

void deleteelement()

{

int deleted_front = 0;

if (front == NULL)

printf("Error - Queue empty");

else

{

deleted_front = queue[front];

queue[front] = NULL;

if (front == max-1)

front = 0;

else

front = front + 1;

}

}

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

Question suppose that in responding to interrupts from an

Question : Suppose that in responding to interrupts from an I/O device the processor consumes 1000 cycles in performing the context switch required to transfer control to the interrupt handler. Servicing the device reque ...

Mccann co has identified an investment project with the

McCann Co. has identified an investment project with the following cash flows. Year Cash Flow  1     $800   2    1,090   3    1,350   4    1,475  a. If the discount rate is 7 percent, what is the present value of these c ...

Suppose you are given an undirected graph g with weighted

Suppose you are given an undirected graph G with weighted edges and a minimum spanning tree T of G. • Design an algorithm to update the minimum spanning tree when the weight of a single edge e is increased. • Design an a ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose that you need to create two-table database to

Suppose that you need to create two-table database to record information for a DVD rental kiosk. The following information needs to be recorded. For all movies: Movie number, title, category, rental rate, and whether or ...

Requirementsdesign and implement an application with a

Requirements Design and implement an application with a graphical user interface to manage a library of songs. A song is uniquely identified by name and artist (case insensitive). Your application should have a SINGLE WI ...

1 the economy is in a recession with high unemployment and

1) The economy is in a recession with high unemployment and low output (i.e. the output currently is lower than the natural level of output) a) Draw a graph of aggregate demand and aggregate supply to illustrate the curr ...

Question you are responsible for managing multiple exchange

Question : You are responsible for managing multiple Exchange organizations, and you need to apply identical configurations to servers in all organizations. Since you are just starting out with Exchange Server 2013, and ...

Question specify design implement im c a class for a card

Question : Specify, design implement im c++ a class for a card in a deck of playing cards. The object should contain methods for setting and retrieving the suit and rank of the card. Make sure to separate your work on s ...

What is the role of arp and how does it cause a security

What is the role of ARP and how does it cause a security concern? What is the different between global and private IP addresses? How does using NAT change a private IP address into a global IP address, and why is this so ...

  • 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