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

Method findMidNode

12_LinkedList.java/LL.java:176–187  ·  view source on GitHub ↗
(Node head)

Source from the content-addressed store, hash-verified

174 }
175
176 private Node findMidNode(Node head) {
177 Node slow = head;
178 Node fast = head.next;
179 //important because we want final mid to be end of 1st half in even case,
180 //not start of 2nd half. Because mid.next is start of 2nd half.
181
182 while(fast!= null && fast.next!=null) {
183 slow = slow.next;
184 fast = fast.next.next;
185 }
186 return slow;
187 }
188
189 public boolean checkPalindrome() {
190 if(head == null || head.next == null) {

Callers 2

checkPalindromeMethod · 0.95
mergeSortHelperMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected