Ayu-hack / Hacktoberfest2024-1

This is repo to create some pull requests and completing hacktoberfest 2024 easily. All request will be accepted. Genuine Pull Request will promoted also. #hacktobefest #hacktobefest2024 #hacktobefest-accepted Resources
46 stars 467 forks source link

Implementation of Stack using Array , Dynamic Array & Linked List #101

Closed kishan-25 closed 1 month ago

kishan-25 commented 1 month ago

Description:

This includes the implementation of the Stack data structure in C++ using three different underlying structures: Static Array, Dynamic Array, and Linked List. Each implementation follows the LIFO (Last In, First Out) principle and showcases key stack operations.

1. Stack using Static Array: A fixed-size stack implementation using a static array. Operations implemented: Push: Adds an element to the top of the stack (fails if the stack is full). Pop: Removes the top element (fails if the stack is empty). Peek/Top: Returns the top element without removing it. isEmpty: Checks if the stack is empty. isFull: Checks if the stack is full (since the size is fixed). Constraints: Stack size must be predefined, and it cannot grow beyond the allocated memory. 2. Stack using Dynamic Array: A resizable stack implementation using a dynamic array that grows and shrinks as needed. Operations implemented: Push: Adds an element to the top of the stack. The array resizes dynamically when full (usually doubles in size). Pop: Removes the top element (fails if the stack is empty). Peek/Top: Returns the top element without removing it. Resize: Dynamically adjusts the size of the array based on the stack’s usage (increasing and decreasing memory when necessary). isEmpty: Checks if the stack is empty. Benefits: More flexible in terms of memory usage compared to a static array, but with a slight overhead for resizing. 3. Stack using Linked List: A dynamic memory implementation where each element is a node in a linked list. Operations implemented: Push: Adds a new node to the top of the stack (the head of the linked list). Pop: Removes the top node (fails if the stack is empty). Peek/Top: Returns the value of the top node without removing it. isEmpty: Checks if the stack is empty. Advantages: Efficient memory usage with no predefined size, ideal for cases where the number of elements is unknown or constantly changing. Purpose: The purpose of this pull request is to demonstrate the flexibility of stack implementations using different data structures and provide a comparative analysis of performance and memory management across:

Fixed-size (Static Array). Resizable (Dynamic Array). Dynamic memory allocation (Linked List). Testing: Each implementation has been tested for edge cases such as pushing into a full stack, popping from an empty stack, and handling dynamic resizing.

Ayu-hack commented 1 month ago

Please share the screenshot of working, to get it merged.

kishan-25 commented 1 month ago

On Sat, 5 Oct 2024 at 18:17, Balkishan Bajpay @.***> wrote:

On Sat, 5 Oct 2024 at 23:35, Ayush Tiwari @.***> wrote:

Please share the screenshot of working, to get it merged.

— Reply to this email directly, view it on GitHub https://github.com/Ayu-hack/Hacktoberfest2024/pull/101#issuecomment-2395135672, or unsubscribe https://github.com/notifications/unsubscribe-auth/A6FS3LZP64JIFF37IREVAVDZ2AS5FAVCNFSM6AAAAABPNRH4FKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGEZTKNRXGI . You are receiving this because you were assigned.Message ID: @.***>

kishan-25 commented 1 month ago

Images added & plz review once and let me know if you need further changes . Thank you accepting my pull request .

Ayu-hack commented 1 month ago

Please the share the screenshot.

kishan-25 commented 1 month ago

array Dynamicarray Linkedlist

Also added up in the STACK folder and shared on your gmail .

kishan-25 commented 1 month ago

@Ayu-hack Sir can you plz specify me the location to upload the screenshot.

Ayu-hack commented 1 month ago

Here only in comments section like you have shared above.

Ayu-hack commented 1 month ago

Great ! Merged. More repos are available for pull requests, and they’re part of Hacktoberfest 2024. Feel free to tag me in your Hacktoberfest certificate or badges LinkedIn post! 😄

👉 Follow my GitHub and connect with me on LinkedIn! ⭐ Star these repos to stay updated for next year’s Hacktoberfest!