MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / add

Method add

DSA Javascript/linked_list.js:17–41  ·  view source on GitHub ↗
(element)

Source from the content-addressed store, hash-verified

15 // adds an element at the end
16 // of list
17 add(element) {
18 // creates a new node
19 var node = new Node(element);
20
21 // to store current node
22 var current;
23
24 // if list is Empty add the
25 // element and make it head
26 if (this.head == null)
27 this.head = node;
28 else {
29 current = this.head;
30
31 // iterate to the end of the
32 // list
33 while (current.next) {
34 current = current.next;
35 }
36
37 // add node
38 current.next = node;
39 }
40 this.size++;
41 }
42
43 // insert element at the position index
44 // of the list

Callers 4

buildFailureLinksMethod · 0.95
mergeMethod · 0.95
checkForCycleMethod · 0.95
linked_list.jsFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected