MCPcopy Create free account
hub / github.com/apna-college/Alpha / add

Method add

12_LinkedList.java/LL.java:45–64  ·  view source on GitHub ↗
(int idx, int data)

Source from the content-addressed store, hash-verified

43 }
44
45 public void add(int idx, int data) {
46 if(idx == 0) {
47 addFirst(data);
48 return;
49 }
50 size++;
51 Node temp = head;
52 int i = 0;
53 while(temp != null) {
54 if(i == idx-1) {//add here
55 Node newNode = new Node(data);
56 //insertion at middle
57 newNode.next = temp.next;
58 temp.next = newNode;
59 return;
60 }
61 temp = temp.next;
62 i++;
63 }
64 }
65
66 public int removeFirst() {
67 if(size == 0) {

Callers 15

printRoot2LeafMethod · 0.45
getInorderMethod · 0.45
getInorderMethod · 0.45
mergeBSTsMethod · 0.45
printRoot2LeafMethod · 0.45
getInorderMethod · 0.45
mergeMethod · 0.45
pushMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45
mainMethod · 0.45

Calls 1

addFirstMethod · 0.95

Tested by

no test coverage detected