Skip to content

feat: stack with linked list #110

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

Merged
merged 4 commits into from
Mar 12, 2023
Merged

feat: stack with linked list #110

merged 4 commits into from
Mar 12, 2023

Conversation

zFlxw
Copy link
Contributor

@zFlxw zFlxw commented Mar 7, 2023

This is an implementation of a singly linked list and a stack based on a singly linked list.

Additional note: I had some trouble with the tests of the stack implementation. All tests passed when running them individually, but however they failed when running them "all at once" (testing the whole file). The issues that came seemed weird, as for example there was a "Stack overflow" error when popping the element from the stack. I think and hope this is a local issue with my machine. If it is one with the tests I wrote, feel free to correct me.

And, just to clarify it here, I adjusted the test cases of the linked list from the doubly linked list (and verified their functionality), because the operations are basically the same and I think the test cases fulfilled everything. So credits to @zFl4wless for writing these tests.

appgurueu
appgurueu previously approved these changes Mar 7, 2023
Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

Looks good. I wonder whether you could reasonably deduplicate the tests by applying the singly linked list tests to the doubly linked list as well?

@zFlxw
Copy link
Contributor Author

zFlxw commented Mar 7, 2023

Looks good. I wonder whether you could reasonably deduplicate the tests by applying the singly linked list tests to the doubly linked list as well?

Do you mean I should merge them in one single file and execute the tests for both lists there?

@appgurueu
Copy link
Contributor

If the singly linked list has the same interface as the doubly linked one (where of course some operations will be linear rather than constant time): Yes, you can use one file and a test parameterized in terms of the constructor to use. You might as well use three files though: One for the parameterized tests and two (trivial) files which just import the parameterized test and execute it for a given implementation. For an example of this, see the queue tests consolidated in 124890c: Both the ArrayQueue and the LinkedQueue use the same tests.

However, if you want to support only a subset of the doubly linked list operations, you should still keep the "doubly linked list"-only tests for the doubly linked list; the common tests should however be deduplicated using the parameterization described above.

@zFlxw
Copy link
Contributor Author

zFlxw commented Mar 7, 2023

Alright, the linked lists now have an interface with their shared methods and a combined test case. The additional reverse() function of the doubly linked list has also an own test case it its test file.

@zFlxw zFlxw requested review from appgurueu and removed request for raklaptudirm March 7, 2023 20:31
appgurueu
appgurueu previously approved these changes Mar 8, 2023
Copy link
Contributor

@appgurueu appgurueu left a comment

Choose a reason for hiding this comment

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

Excellent work

Copy link
Member

@raklaptudirm raklaptudirm left a comment

Choose a reason for hiding this comment

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

Tests are failing.

@appgurueu
Copy link
Contributor

Odd. The tests are failing due to something that hasn't even been touched. Perhaps you need to rebase?

@raklaptudirm
Copy link
Member

The master branch workflows have passed, so it seems to be an issue from here.

@zFlxw
Copy link
Contributor Author

zFlxw commented Mar 9, 2023

Alright, I check this out

@zFlxw
Copy link
Contributor Author

zFlxw commented Mar 9, 2023

Well yeah, seems logical that after the first test, a stack overflow occurred, when pushing three new elements before each test run.

@zFlxw zFlxw requested review from appgurueu and raklaptudirm and removed request for appgurueu March 9, 2023 19:27
@raklaptudirm raklaptudirm merged commit 4c5469f into TheAlgorithms:master Mar 12, 2023
@zFlxw zFlxw deleted the feat/stack-with-linked-list branch March 12, 2023 11:04
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.

3 participants