Skip to content

Stack using a fixed size array #5487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed

Conversation

dylanbuchi
Copy link
Contributor

Describe your change:

New implementation of the stack data structure

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added the awaiting reviews This PR is ready to be reviewed label Oct 20, 2021
Copy link
Member

@poyea poyea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dylanbuchi
Copy link
Contributor Author

https://github.com/TheAlgorithms/Python/blob/master/data_structures/stacks/stack.py uses the Python list, I only use the Python list to simulate a fixed-sized array like the one in Java because Python doesn't have a built-in static array. It's a different implementation. I use the pointers to manage the list and resize it manually when it's full. Please have a look again, it's not a duplicate!!
@poyea

@dylanbuchi dylanbuchi changed the title Stack using a fixed size list Stack using a fixed size array Oct 22, 2021
@poyea
Copy link
Member

poyea commented Oct 22, 2021

@dylanbuchi But master/data_structures/stacks/stack.py:push contains technically your __resize, right? What I suggest is the two stack implementations use the same type - list - to simulate the operations.

@dylanbuchi
Copy link
Contributor Author

@poyea Yes! I just don't use the built-in list methods or the resizing under the hood. So basically I'm simulating a static array using the list and the other one uses the list as-is: a dynamic array. I think it's helpful to also show this implementation.

Copy link
Member

@poyea poyea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data_structures/stacks/stack_fixed_size_array.py

@poyea
Copy link
Member

poyea commented Oct 26, 2021

What I was thinking is you may add this resize function to data_structures/stacks/stack.py because from my perspective these 2 implementations are similar. Then, you can also keep all the test cases.

@stale
Copy link

stale bot commented Apr 28, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Apr 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reviews This PR is ready to be reviewed stale Used to mark an issue or pull request stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants