We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents bf8387e + 7231786 commit 77e1f25Copy full SHA for 77e1f25
2 files changed
src/_DataStructures_/DoublyLinkedList/index.js
@@ -53,14 +53,14 @@ class DoublyLinkedList {
53
return this.size;
54
}
55
56
- display() {
+ traverse() {
57
let address = this.head.next;
58
- let addresses = []
+ const elements = [];
59
while (address !== this.tail) {
60
- addresses.push(address.data)
+ elements.push(address.data);
61
address = address.next;
62
63
- return addresses
+ return elements;
64
65
66
src/_DataStructures_/LinkedList/index.js
@@ -156,6 +156,16 @@ class LinkedList {
156
this.tail = this.head;
157
this.size = 0;
158
159
+
160
+ traverseList() {
161
+ const arr = [];
162
+ let node = this.head;
163
+ while (node !== null) {
164
+ arr.push(node.data);
165
+ node = node.next;
166
+ }
167
+ return arr;
168
169
170
171
module.exports = { LinkedList, Node };
0 commit comments