Create a queue, Basic Computer Science

Assignment Help:

QUESTION

(a) Give the representation of a queue as an abstract data type.

(b) What is a priority queue? Give two types of priority queues.

(c) The following program does the following:

1. Create a queue, q, consisting of 1 (front), 2, 3, 4 and 5 (rear).

2. Display the contents of q.

3. Remove an item from q and display the content of q.

#include

#include

#define MAXQUEUE 6

#define TRUE 1

#define FALSE 0

struct queue

{

int items[MAXQUEUE];

int front, rear;

};

void initialize();

int empty();

void insert();

int rem();

void output();

int n;

void main()

{

struct queue q;

int i,E;

initialize(&q);

printf("Enter the number of elements: ");

scanf("%d",&n);

If (n

{

for(i=0;i

{

printf("Enter an element: ");

scanf("%d",&E);

insert(&q,E);

}

}

else

{

printf("Number of elements must be less than MAXQUEUE.\n");

return;

}

printf("\nContent of the Queue from Front to Rear: ");

output(&q);

rem(&q);

printf("\nContent of the Queue from Front to Rear: ");

output(&q);

}

Write the functions initialize, empty, insert and rem in C.

 


Related Discussions:- Create a queue

Microprocessors, what is the role of microprocessors in IT? how they are us...

what is the role of microprocessors in IT? how they are used in medical field? how they are used in our real lifes? how they are used in latest technology?

Operating system problems, 1. In discussing software algorithms for mutual ...

1. In discussing software algorithms for mutual exclusion, we noted that optimizing compilers and out-of-order execution by processors could invalidate most of these algorithms bec

Explain the types of memory and explain how each work, Problem: a) ...

Problem: a) Explain the basic functions of a computer: inputting, processing, storing and outputting. b) List four types of memory and explain how each wor

Discuss the advantages and disadvantages of printed indexes, QUESTION 1 ...

QUESTION 1 Discuss the advantages and disadvantages of printed indexes. QUESTION 2 (i) The Library of Congress Subject Headings List and the Sears Subject Headings List

What is Decode or execution cycle?, just the once the instruction has bee...

just the once the instruction has been fetched and is accumulated, the next step is to decode the instruction so as to work out what actions should be performed to execute it. This

How should an ideal hospital software be? , How Should an Ideal Software be...

How Should an Ideal Software be?  It should be easy to operate, with minimal training of nursing personnel.   Should be reliable, and thoroughly tested in various nur

Languages used in artificial intelligence, R e presentations/Languages Us...

R e presentations/Languages Used: Many people are taught Artificial Intelligence with the opening line: "The three most essential things in Artificial Intelligence are repres

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