Skip to content

schrodingercats-sudo/Data-structure-stack-operation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Data Structure Operations in C

This project implements core data structure operations using array-based implementations in C, including:

  • Stack Operations
  • Circular Queue Operations

Each operation is designed to help understand fundamental data structures through practical, menu-driven C programs.


Table of Contents


Introduction

🧱 Stack (LIFO)

A stack is a linear data structure that follows the LIFO (Last In, First Out) principle. This project demonstrates:

  • Push: Add an element to the top.
  • Pop: Remove the top element.
  • Display: Show stack contents.

🔁 Circular Queue (FIFO)

A circular queue uses a fixed-size array and wraps around when reaching the end. It operates on the FIFO (First In, First Out) principle. This project includes:

  • Insert: Add an element to the rear.
  • Delete: Remove an element from the front.
  • Display: Show all elements in queue order.

These are console-based interactive programs ideal for learning and demonstration.


Features

✅ Stack:

  • Push elements to the stack.
  • Pop elements from the top.
  • Display stack from top to bottom.
  • Overflow and underflow handling.

✅ Circular Queue:

  • Insert elements at the rear.
  • Delete elements from the front.
  • Circular behavior with wrapping.
  • Handles overflow and underflow conditions.

Installation

Requirements

  • A C compiler (e.g., GCC, Clang)
  • Terminal or IDE (e.g., Code::Blocks, VS Code)

Steps

  1. Clone the repository:

    git clone https://github.com/schrodingercats-sudo/data-structure-operations.git
    cd data-structure-operations
  2. Compile the code:

    • For stack:

      gcc stack_operations.c -o stack
    • For circular queue:

      gcc circular_queue.c -o circular_queue
  3. Run the programs:

    • Stack:

      ./stack
    • Circular Queue:

      ./circular_queue

Usage

🔷 Stack

Enter the size of STACK[MAX=100]:
5

        STACK OPERATIONS USING ARRAY
        -------
        1.PUSH
        2.POP
        3.DISPLAY
        4.EXIT
Enter the Choice: 1
Enter a value to be pushed: 10

🔷 Circular Queue

1.Insert
2.Delete
3.Display
4.Quit
Enter your choice: 1
Input the element for insertion in queue: 25

Functions

Stack Functions

  • push() – Adds an element to the top of the stack.
  • pop() – Removes the top element from the stack.
  • display() – Shows the stack elements from top to bottom.

Circular Queue Functions

  • insert() – Adds an item to the queue. Handles wrap-around logic.
  • deletion() – Deletes the front item. Updates front and rear correctly.
  • display() – Shows the queue in correct order, including wrap-around.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages