Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Queue{
- BST * data;
- Queue * next;
- };
- int isEmpty(Queue * last)
- {
- if(last == NULL)
- return 1;
- else
- return 0;
- }
- Queue * enqueue(Queue * last, BST * value)
- {
- Queue * temp = (Queue*)(malloc(sizeof(Queue)));
- temp->data = value;
- if(isEmpty(last))
- {
- temp->next = temp;
- last = temp;
- }
- else
- {
- temp->next = last->next;
- last->next = temp;
- last = temp;
- }
- return last;
- }
- Queue * dequeue(Queue * last)
- {
- if((last == NULL) || (last->next == last))
- {
- return NULL;
- }
- last->next = last->next->next;
- return last;
- }
- BST * top(Queue * last)
- {
- if(isEmpty(last))
- return NULL;
- else
- return last->next->data;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement