forked fromTheAlgorithms/Java
- Notifications
You must be signed in to change notification settings - Fork0
Commitd60f836
authored
Updated StackOfLinkedList.java
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.1 parentdda712c commitd60f836
1 file changed
+21
-16
lines changedLines changed: 21 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
25 | 25 |
| |
26 | 26 |
| |
27 | 27 |
| |
28 |
| - | |
29 | 28 |
| |
30 |
| - | |
31 | 29 |
| |
32 | 30 |
| |
33 | 31 |
| |
| |||
51 | 49 |
| |
52 | 50 |
| |
53 | 51 |
| |
54 |
| - | |
55 | 52 |
| |
56 | 53 |
| |
57 | 54 |
| |
58 |
| - | |
| 55 | + | |
59 | 56 |
| |
60 | 57 |
| |
61 | 58 |
| |
62 | 59 |
| |
63 | 60 |
| |
64 | 61 |
| |
65 | 62 |
| |
66 |
| - | |
67 | 63 |
| |
68 | 64 |
| |
69 | 65 |
| |
70 |
| - | |
| 66 | + | |
71 | 67 |
| |
72 | 68 |
| |
73 | 69 |
| |
74 | 70 |
| |
75 | 71 |
| |
76 |
| - | |
77 |
| - | |
78 | 72 |
| |
79 | 73 |
| |
80 | 74 |
| |
81 | 75 |
| |
82 |
| - | |
| 76 | + | |
83 | 77 |
| |
84 | 78 |
| |
85 |
| - | |
86 | 79 |
| |
87 | 80 |
| |
88 | 81 |
| |
89 | 82 |
| |
90 |
| - | |
91 | 83 |
| |
92 | 84 |
| |
93 | 85 |
| |
94 |
| - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
95 | 92 |
| |
96 | 93 |
| |
97 | 94 |
| |
98 |
| - | |
99 | 95 |
| |
100 | 96 |
| |
101 | 97 |
| |
102 |
| - | |
| 98 | + | |
103 | 99 |
| |
104 | 100 |
| |
105 | 101 |
| |
106 |
| - | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 |
| |
108 |
| - | |
109 | 114 |
|
0 commit comments
Comments
(0)