Skip to content

Commit 77e1f25

Browse files
authored
Merge pull request knaxus#102 from knaxus/ll
Changes in Linked Lists
2 parents bf8387e + 7231786 commit 77e1f25

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/_DataStructures_/DoublyLinkedList/index.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ class DoublyLinkedList {
5353
return this.size;
5454
}
5555

56-
display() {
56+
traverse() {
5757
let address = this.head.next;
58-
let addresses = []
58+
const elements = [];
5959
while (address !== this.tail) {
60-
addresses.push(address.data)
60+
elements.push(address.data);
6161
address = address.next;
6262
}
63-
return addresses
63+
return elements;
6464
}
6565
}
6666

src/_DataStructures_/LinkedList/index.js

+10
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,16 @@ class LinkedList {
156156
this.tail = this.head;
157157
this.size = 0;
158158
}
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+
}
159169
}
160170

161171
module.exports = { LinkedList, Node };

0 commit comments

Comments
 (0)