Skip to content

About

This repository contains implementations of fundamental Data Structures in C++. It includes complete implementations of Linked Lists (Singly, Doubly, Circular Singly, and Circular Doubly), Stack, Queue, and Generic Programming using C++ Templates. The project is designed to strengthen problem-solving.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

📚 Generic Stack and Queue Library in C++

A reusable Generic Stack and Generic Queue implementation in C++ using Templates and Singly Linked Lists.

This project demonstrates how to build reusable data structures that work with multiple data types such as int, float, double, char, and string.


🚀 Features

  • ✅ Generic Programming using C++ Templates
  • ✅ Stack (LIFO) Implementation
  • ✅ Queue (FIFO) Implementation
  • ✅ Singly Linked List Based
  • ✅ Dynamic Memory Allocation
  • ✅ Easy to Reuse in Other Projects

📂 Project Structure

DataStructures/
│
├── DataStructures.h          # Master header file (includes all data structures)
├── Main.cpp                  # Example program to test the library
│
├── Stack.cpp                 # Generic Stack implementation
├── Queue.cpp                 # Generic Queue implementation
│
├── SinglyLinearGeneric.cpp   # Generic Singly Linear Linked List
├── SinglyCircularGeneric.cpp # Generic Singly Circular Linked List
├── DoublyLinearGeneric.cpp   # Generic Doubly Linear Linked List
└── DoublyCircularGeneric.cpp # Generic Doubly Circular Linked List

📖 Stack Operations

Function Description
push() Insert an element
pop() Remove and return the top element
peep() View the top element
Display() Display all elements
Count() Return total elements

📖 Queue Operations

Function Description
enqueue() Insert an element at the rear
dequeue() Remove and return the front element
Display() Display all elements
Count() Return total elements

💻 Usage

Include the header file

#include "DataStructures.h"

Stack Example

Stack<int> s;

s.push(10);
s.push(20);
s.push(30);

s.Display();

cout << "Top Element : " << s.peep() << endl;
cout << "Removed : " << s.pop() << endl;

Queue Example

Queue<int> q;

q.enqueue(100);
q.enqueue(200);
q.enqueue(300);

q.Display();

cout << "Removed : " << q.dequeue() << endl;

🧩 Supported Data Types

Stack<int>
Stack<float>
Stack<double>
Stack<char>
Stack<string>

Queue<int>
Queue<float>
Queue<double>
Queue<char>
Queue<string>

⚡ Time Complexity

Stack

Operation Complexity
Push O(1)
Pop O(1)
Peep O(1)
Display O(n)
Count O(1)

Queue

Operation Complexity
Enqueue O(1)
Dequeue O(1)
Display O(n)
Count O(1)

🛠️ Compilation

Compile using g++

g++ main.cpp -o app

Run

Windows

app.exe

Linux / macOS

./app

📸 Sample Output

Stack Elements:
| 30 |
| 20 |
| 10 |

Top Element : 30
Removed : 30

Queue Elements:
| 100 | - | 200 | - | 300 |

Removed : 100

🔮 Future Improvements

  • Add Destructor
  • Exception Handling
  • Copy Constructor
  • Move Constructor
  • Assignment Operator
  • Iterator Support
  • STL-style Interface

📚 Concepts Used

  • C++ Templates
  • Generic Programming
  • Singly Linked List
  • Dynamic Memory Allocation
  • Object-Oriented Programming (OOP)

👨‍💻 Author

Yogiraj Khaladkar

Engineering Student | C++ | Data Structures & Algorithms


⭐ If you found this project helpful, consider giving it a Star on GitHub!

About

This repository contains implementations of fundamental Data Structures in C++. It includes complete implementations of Linked Lists (Singly, Doubly, Circular Singly, and Circular Doubly), Stack, Queue, and Generic Programming using C++ Templates. The project is designed to strengthen problem-solving.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages