Insertion sort ...... Selection sort...... Bubble sort...... Recursive...... Doubly linked list...... Sort more then to Least By Linked List...... Average By Linked list...... Singly Linked List...... Circular Queue...... Perfectly Queue...... Evaluate by Stack...... postfix to infix...... infix To postfix...... stack And queue

Oracle and Java Blog

Mobile Embedded Features

java.net Forums: Message List - Java Web Services and XML

java.net's Javapedia web

Wednesday, May 9, 2007

Circular Queue

#include

#define MAXQUEUE 5

typedef struct {
char data[MAXQUEUE];
int rear;
int front;
int counter;
}QUEUE;

void initial(QUEUE *q);
int enqueue(QUEUE *q,char item);
int dequeue(QUEUE *q,char *ret);

void initial(QUEUE *q){

q->front=-1;
q->rear=-1;
q->counter=0;

}

int enqueue(QUEUE *q,char item)
{
if (q->counter == MAXQUEUE){
printf("FULL QUEUE !!! \n");
return 0;
}
else
{
q->counter++;
q->rear=(q->rear+1)%MAXQUEUE;
q->data[q->rear] = item;
printf("\t enqueue <- %c \n",q->data[q->rear]);

}
return 1;
}

No comments: