Skip to content

Conversation

praphull-verma
Copy link

@praphull-verma praphull-verma commented Oct 9, 2025

Description

The current /stacks directory in the repository includes various stack algorithms and implementations
(e.g., using two queues, min stacks, postfix/prefix evaluation, etc.), but it lacks an implementation
of a Stack data structure using a Linked List.

Proposed Solution

Implemented a StackUsingLinkedList.java class under /stacks package that supports the following
standard stack operations:

  • push(T data) – insert an element onto the stack
  • pop() – remove and return the top element
  • peek() – view the top element without removing it
  • isEmpty() – check if the stack is empty
  • size() – return the number of elements in the stack

Implementation Details

  • Uses a singly linked list (with an inner Node class) to store elements.

  • Ensures O(1) time complexity for push and pop operations.

  • Includes proper exception handling and documentation comments.

  • Added a simple main() method for demonstration and testing.

  • I have read CONTRIBUTING.md.

  • This pull request is all my own work -- I have not plagiarized it.

  • All filenames are in PascalCase.

  • All functions and variable names follow Java naming conventions.

  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.

  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2025

Codecov Report

❌ Patch coverage is 0% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.32%. Comparing base (b1aa896) to head (72c1467).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
...com/thealgorithms/stacks/StackUsingLinkedList.java 0.00% 34 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6717      +/-   ##
============================================
- Coverage     76.45%   76.32%   -0.14%     
- Complexity     5985     5986       +1     
============================================
  Files           716      717       +1     
  Lines         20265    20299      +34     
  Branches       3929     3930       +1     
============================================
- Hits          15494    15493       -1     
- Misses         4180     4215      +35     
  Partials        591      591              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@praphull-verma praphull-verma marked this pull request as draft October 9, 2025 13:37
@praphull-verma praphull-verma reopened this Oct 9, 2025
@praphull-verma praphull-verma marked this pull request as ready for review October 9, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants