//implement priority queue.
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define maxsize 10
void insert();
void delet();
void traverse();
int queue[maxsize];
int item,smallest,loc,i;
int front=0;
int rear=-1;
void main()
{
int choice;
char ch;
do
{
printf("\n 1. insert");
printf("\n 2.delete");
printf("\n 3. traverse");
printf("enter ur choice");
scanf("%d",&choice);
switch(choice)
{
case 1:
insert();
break;
case 2:
delet();
break;
case 3:
traverse();
break;
case 4: exit(1);
default:printf("\n entered wrong choice");
}
printf("\n do u wish to continue(y/n)");
fflush(stdin);
scanf("%c",&ch);
}
while(ch =='Y' ch == 'y');
getch();
}
void insert()
{
if (rear==maxsize)
{
printf("\n overflow");
exit(0);
}
else
{
printf("enter the element");
scanf("%d",&item);
rear=rear + 1;
queue[rear]=item;
}
}
void delet()
{
if(front<0)
{
printf("underflow");
getch();
exit(0);
}
else
{
item=queue[front];
for(i=1;i<=rear;i++)
if(item>queue[i])
{
loc=i;
item=queue[i];
//front=front+1;
for(loc=i;loc<=rear;loc++)
queue[loc]=queue[loc+1];
front=front+1;
rear=rear-1;
printf("deleted item=%d",item);
}
}
}
void traverse()
{
int i;
for(i=front;i<=rear;i++)
{
printf("%d",queue[i]);
}
}
algorithm on multiple queues in a single dimensional array
A queue can use a dynamic array, or a linked list, but if using static memory, the queue becomes a circular queue because the underlaying data structure is a static circular array. This means the ends of the array are attached.
stack abstract datatype
Yes it is possible to implement stack and queue using linked list
You don't. Queues are a first in, first out structure, specifically used to process incoming data in the same order it arrives. If you want to sort a data sequence then use an array or a list.
implement the queue ADT using an array
It depends on the type of data, but generally you would just implement a data array and have a static pointer to the "next" element of the array and a static pointer to the "last" element of the array. New data would be added to the location of the "last" pointer. Data would be processed from the "next" pointer. Pointers would be incremented to the appropriate element whenever reading or writing and special attention given to any time you come to the end of the array.
Separated queue for every possible priority value.
Knowledge and experience.
To efficiently implement a circular array in Python, you can use the collections.deque data structure. Deque allows for efficient insertion and deletion at both ends of the array, making it suitable for circular arrays. You can use the rotate() method to shift elements in the array, effectively creating a circular structure.
AND array is used for developing digital circuit it is used in PLA programmable logic array and PAL programmable array of logic to implement the function. the number of and array will depend on how long you has function to be implemented.These are Digital circuits.
cod a program student degree array in c language