TP - Stacks and Queues
TP - Stacks and Queues
Exercise 1:
Implement a stack data structure using an array and provide the following operations:
Write a program to implement the stack data structure using an array. Test your
implementation by performing the following operations:
Exercise 2:
Write a program to implement the queue data structure using a linked list. Test your
implementation by performing the following operations:
1. Create an empty queue.
2. Enqueue the elements "apple", "banana", and "cherry" into the queue.
3. Print the size of the queue.
4. Check if the queue is empty and print the result.
5. Dequeue an element from the queue and print it.
6. Peek at the front element of the queue and print it.
7. Enqueue the element "date" into the queue.
8. Print the size of the queue again.