Skip to content

Updated StackOfLinkedList.java - #711

Merged
yanglbme merged 2 commits into
TheAlgorithms:masterfrom
ojasiiitd:patch-1
Mar 5, 2019
Merged

Updated StackOfLinkedList.java#711
yanglbme merged 2 commits into
TheAlgorithms:masterfrom
ojasiiitd:patch-1

Conversation

@ojasiiitd

Copy link
Copy Markdown
Contributor

I made the code shorter and less prone to mistakes by removing the "size" variable altogether from the LinkedList class. I found that after each push/pop operation, changing the value of size did make the code more efficient, but made it more prone to mistakes. So, for empty stack, a simple "head == null" was enough, which has been incorporated.

ojasiiitd and others added 2 commits March 4, 2019 15:05
I made the code shorter and less prone to mistakes by removing the "size" variable altogether from the LinkedList class. I found that after each push/pop operation, changing the value of size did make the code more efficient, but made it more prone to mistakes. So, for empty stack, a simple "head == null" was enough, which has been incorporated.
@yanglbme
yanglbme merged commit 1d02cd4 into TheAlgorithms:master Mar 5, 2019
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