pravocodes / Hacktoberfest2024

25 stars 227 forks source link

Implementation stack using array , dynamic array & Linked list #25

Closed kishan-25 closed 2 weeks ago

kishan-25 commented 2 weeks ago

Description:

This document outlines the implementation of a stack data structure using three different approaches: a static array, a dynamic array, and a linked list. Each implementation demonstrates the core principles of the stack, which follows the Last In, First Out (LIFO) paradigm.

Stack Using Array:

In this implementation, a fixed-size array is utilized to store stack elements. The size of the stack is predetermined, and operations such as push, pop, and peek are performed using index manipulation. This approach is efficient in terms of time complexity but limited by the static nature of arrays, which can lead to overflow when the maximum size is reached. Stack Using Dynamic Array:

This version extends the stack's capabilities by using a dynamic array (e.g., std::vector in C++ or ArrayList in Java). Unlike the static array, the dynamic array can resize itself when capacity is exceeded, allowing for more flexible memory usage. This implementation balances time complexity with increased flexibility, handling both push and pop operations efficiently while managing memory dynamically. Stack Using Linked List:

The linked list implementation offers a different approach to stack management. Each element (node) contains a value and a pointer to the next node. This structure allows for dynamic memory allocation, meaning the stack can grow and shrink without a predefined limit. The push and pop operations are efficient as they only involve pointer manipulation, making this implementation ideal for situations where memory requirements are unpredictable. In summary, the document will explore the benefits and limitations of each approach, highlighting how the choice of implementation can impact performance, memory usage, and overall efficiency. It will also include code examples and performance comparisons to provide a comprehensive understanding of stack implementations in different contexts.

kishan-25 commented 2 weeks ago

Sir accept my pull request under the label of Hacktoberfest2024. Thank you