Professional Documents
Culture Documents
Q1. Implementation of fixed size STACK data structure in C using array. The stack
should have push, pop, create, isempty, isfull functions.
#include <stdio.h>
#include <stdlib.h>
#define SIZE 15
struct Stack {
int items[SIZE];
int top;
};
int main() {
struct Stack* stack = createStack();
push(stack, 1);
push(stack, 2);
push(stack, 3);
push(stack, 4);
push(stack, 5);
push(stack, 6);
push(stack, 7);
push(stack, 8);
return 0;
}
Q2. Implementation of dynamic size STACK data structure in C using linked list. The
stack should have push, pop, create, isempty, isfull functions.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
struct Stack {
struct Node* top;
};
return 0;
int main() {
struct Stack* stack = createStack();
push(stack, 1);
push(stack, 2);
push(stack, 3);
push(stack, 4);
push(stack, 5);
push(stack, 6);
push(stack, 7);
return 0;
}
Q3. Implementation of QUEUE data structure in C using linked list. It should have
enqueue, dequeue, isempty and size functions.
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
struct Queue {
struct Node* front;
struct Node* back;
int size;
};
enqueue(queue, 1);
enqueue(queue, 2);
enqueue(queue, 3);
enqueue(queue, 4);
enqueue(queue, 5);
enqueue(queue, 6);
enqueue(queue, 7);
return 0;
}