C Programming Examples on Stacks & Queues

This section covers C programming examples on Stacks & Queues. Every example program includes the description of the program, C code as well as output of the program. All examples are compiled and tested on a Linux system. These examples can be simple C programs or advanced C programs. So, they are suitable for any user (dummies, beginners or advanced users).

Here is the listing of C programming examples on Stacks & Queues.

1. C Examples on Stack Implementation

A Stack is a data structure which is used to store data in a particular order. Two operations that can be performed on a Stack are: Push operation which inserts an element into the stack. Pop operation which removes the last element that was added into the stack. It follows Last In First Out(LIFO) Order. The C programs in this section dealing with Stack. The section deals with various implementations of Stacks, to reverse a Stack using recursion and without using recursion, to implement two Stacks using a single array and check for Overflow and Underflow conditions and implementing a Stack using linked list. A stack overflow is an undesirable condition in which the program tries to use more memory space than the call stack has available. If a Stack is empty and yet a Pop operation is attempted, then it results in Stack Underflow condition.

2. C Examples on Queue Implementation

A Queue is a linear data structure which basically stores the data sequentially. It follows First In First Out(FIFO) order. The C programs in this section deals with various implementations of Queue. It contains programs to implement Queue using an array, linked list and to implement a priority queue to add and delete elements. In a priority queue, values come out in order by priority.

3. C Examples on String Implementation

The C programs in this section illustrates the use of data structures like Stacks and Queues for string implementations. It contains programs which checks if a given string is palindrome using stack and without using stack and a program to check if the given expression is correctly parenthesized.

4. C Examples on Queue Implementation using Other Data Structures

The C programs in this section demonstrates the implementation of Queue using other data structures. It contains programs to implement queue functions using Dynamic Memory Allocation, using arrays and macros and implementation of queue using stack. Dynamic Memory Allocation enables us to create data types and structures of any size and length to suit our program’s need within the program.

5. C Examples on Other Stack Implementations

The C programs in this section demonstrates other implementations of Stack. It contains programs to illustrate stack operations using MACROS and to implement operations of a stack using Dynamic Memory Allocation.