Skip to content

spencernemy/stacks-queues-c

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

📚 C Stack and Queue Implementation

A C-based data structures project implementing stack and queue abstract data types using linked lists, dynamic memory allocation, structs, and pointer manipulation.
The implementation supports inserting, removing, accessing, and managing elements while safely handling memory and error states.


Project Overview

C Stack and Queue Implementation demonstrates how fundamental data structures work internally using low-level programming concepts.

Both the stack (LIFO) and queue (FIFO) are implemented using a shared node structure with void pointers, allowing the structures to store any data type.

Operations manipulate the data structures through pointer traversal and dynamic memory allocation using malloc and free. Each structure also tracks its size and maintains an error code to signal invalid operations.

The project emphasizes:

  • Dynamic memory management
  • Pointer traversal and manipulation
  • Implementation of Stack (LIFO) and Queue (FIFO) behaviors
  • Generic data storage using void*
  • Modular program structure with header and implementation files
  • Safe handling of edge cases (empty structures and allocation failures)

Features

Queue Operations

  • Initialize a queue structure
  • Enqueue elements to the rear of the queue
  • Dequeue elements from the front of the queue
  • Peek at the front element
  • Peek at the rear element
  • Check if the queue is empty
  • Retrieve the current queue size
  • Clear all elements from the queue
  • Free all allocated queue memory
  • Error code tracking for invalid operations

Stack Operations

  • Initialize a stack structure
  • Push elements onto the top of the stack
  • Pop elements from the top of the stack
  • Peek at the top element
  • Check if the stack is empty
  • Retrieve the current stack size
  • Free all allocated stack memory
  • Error code tracking for invalid operations

Compilation & Execution

gcc main.c stacks-queues.c -o stacksqueues
./stacksqueues

About

C implementation of stack and queue data structures using linked lists, dynamic memory allocation, and generic void* storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages