| 1 | package com.mylinkedlist.app; | |
| 2 | import java.util.*; | |
| 3 | ||
| 4 | class Node | |
| 5 | { | |
| 6 | int data; | |
| 7 | Node next; | |
| 8 | ||
| 9 | Node(int data) | |
| 10 | { | |
| 11 | this.data=data; | |
| 12 | next=null; | |
| 13 | } | |
| 14 | Node(){} | |
| 15 | } | |
| 16 | ||
| 17 | public class App | |
| 18 | { | |
| 19 | Node head=null; | |
| 20 | Node last=null; | |
| 21 | int count=0; //total nodes in the list | |
| 22 | ||
| 23 | /* | |
| 24 | * Size | |
| 25 | */ | |
| 26 | ||
| 27 | int size() | |
| 28 | { | |
| 29 | int x=size(head); | |
| 30 |
1
1. size : replaced int return with 0 for com/mylinkedlist/app/App::size → KILLED |
return x; |
| 31 | } | |
| 32 | | |
| 33 | int size(Node n) | |
| 34 | { | |
| 35 |
1
1. size : negated conditional → KILLED |
if(n==null) |
| 36 | return 0; | |
| 37 |
2
1. size : Replaced integer addition with subtraction → KILLED 2. size : replaced int return with 0 for com/mylinkedlist/app/App::size → KILLED |
else return(1+ size(n.next)); |
| 38 | } | |
| 39 | ||
| 40 | /* | |
| 41 | * Getter | |
| 42 | */ | |
| 43 | ||
| 44 | int get(int index) //get the data from the given index node | |
| 45 | { | |
| 46 | Node target=head; | |
| 47 |
3
1. get : changed conditional boundary → KILLED 2. get : Changed increment from 1 to -1 → KILLED 3. get : negated conditional → KILLED |
for(int i=0;i<index;i++) |
| 48 | { | |
| 49 | target=target.next; | |
| 50 | } | |
| 51 |
1
1. get : replaced int return with 0 for com/mylinkedlist/app/App::get → KILLED |
return target.data; |
| 52 | } | |
| 53 | ||
| 54 | /* | |
| 55 | * Setter | |
| 56 | */ | |
| 57 | ||
| 58 | void set(int index,int d) | |
| 59 | { | |
| 60 | Node current=head; | |
| 61 |
3
1. set : changed conditional boundary → KILLED 2. set : Changed increment from 1 to -1 → KILLED 3. set : negated conditional → KILLED |
for(int i=0;i<index;i++) |
| 62 | { | |
| 63 | current=current.next; | |
| 64 | } | |
| 65 | current.data=d; | |
| 66 | } | |
| 67 | ||
| 68 | /* | |
| 69 | * Add | |
| 70 | */ | |
| 71 | ||
| 72 | void add(int d) //add at the end of the list | |
| 73 | { | |
| 74 | Node n=new Node(d); | |
| 75 |
1
1. add : negated conditional → KILLED |
if(head!=null) |
| 76 | { | |
| 77 | last.next=n; | |
| 78 | last=n; | |
| 79 |
1
1. add : Replaced integer addition with subtraction → KILLED |
count++; |
| 80 | } | |
| 81 | else | |
| 82 | { | |
| 83 | head=n; | |
| 84 | last=n; | |
| 85 |
1
1. add : Replaced integer addition with subtraction → KILLED |
count++; |
| 86 | } | |
| 87 | } | |
| 88 | ||
| 89 | String add(int index,int d)// add at given index | |
| 90 | { | |
| 91 | int count_=size(); | |
| 92 |
5
1. add : changed conditional boundary → SURVIVED 2. add : changed conditional boundary → KILLED 3. add : negated conditional → KILLED 4. add : negated conditional → KILLED 5. add : negated conditional → KILLED |
if(index>0 && (index<count_ || index==count_)) |
| 93 | { | |
| 94 |
2
1. add : changed conditional boundary → SURVIVED 2. add : negated conditional → KILLED |
if(index<count_) |
| 95 | { | |
| 96 | Node before=head; | |
| 97 | Node n=new Node(d); | |
| 98 |
4
1. add : changed conditional boundary → KILLED 2. add : Changed increment from 1 to -1 → KILLED 3. add : Replaced integer subtraction with addition → KILLED 4. add : negated conditional → KILLED |
for(int i=0;i<index-1;i++) |
| 99 | { | |
| 100 | before=before.next; | |
| 101 | } | |
| 102 | n.next=before.next; | |
| 103 | before.next=n; | |
| 104 |
1
1. add : Replaced integer addition with subtraction → KILLED |
count++; |
| 105 |
1
1. add : replaced return value with "" for com/mylinkedlist/app/App::add → KILLED |
return "added successfully"; |
| 106 | } | |
| 107 |
1
1. add : negated conditional → KILLED |
else if(index==count_) |
| 108 | { | |
| 109 | Node n=new Node(d); | |
| 110 | last.next=n; | |
| 111 | last=n; | |
| 112 |
1
1. add : Replaced integer addition with subtraction → KILLED |
count++; |
| 113 |
1
1. add : replaced return value with "" for com/mylinkedlist/app/App::add → KILLED |
return "added successfully"; |
| 114 | } | |
| 115 | } | |
| 116 |
1
1. add : negated conditional → KILLED |
else if(index==0) |
| 117 | { | |
| 118 | Node n=new Node(d); | |
| 119 | n.next=head; | |
| 120 | head=n; | |
| 121 |
1
1. add : Replaced integer addition with subtraction → KILLED |
count++; |
| 122 |
1
1. add : replaced return value with "" for com/mylinkedlist/app/App::add → KILLED |
return "added successfully"; |
| 123 | } | |
| 124 | ||
| 125 |
1
1. add : replaced return value with "" for com/mylinkedlist/app/App::add → KILLED |
return "wrong Index"; |
| 126 | } | |
| 127 | ||
| 128 | void addFirst(int d) | |
| 129 | { | |
| 130 | add(0,d); | |
| 131 | } | |
| 132 | ||
| 133 | void addLast(int d) | |
| 134 | { | |
| 135 |
1
1. addLast : removed call to com/mylinkedlist/app/App::add → KILLED |
add(d); |
| 136 | } | |
| 137 | ||
| 138 | /* | |
| 139 | * Remove | |
| 140 | */ | |
| 141 | ||
| 142 | String remove(int index) | |
| 143 | { | |
| 144 | int count_=size(); | |
| 145 | ||
| 146 |
9
1. remove : changed conditional boundary → SURVIVED 2. remove : changed conditional boundary → KILLED 3. remove : changed conditional boundary → KILLED 4. remove : changed conditional boundary → KILLED 5. remove : Replaced integer subtraction with addition → KILLED 6. remove : negated conditional → KILLED 7. remove : negated conditional → KILLED 8. remove : negated conditional → KILLED 9. remove : negated conditional → KILLED |
if(count_>0 && index>=0 && (index<count_-1 || index>=count_ )) |
| 147 | { | |
| 148 |
1
1. remove : negated conditional → KILLED |
if(index==0) |
| 149 | { | |
| 150 | head=head.next; | |
| 151 |
1
1. remove : Replaced integer subtraction with addition → KILLED |
count--; |
| 152 | } | |
| 153 |
5
1. remove : changed conditional boundary → SURVIVED 2. remove : changed conditional boundary → SURVIVED 3. remove : Replaced integer subtraction with addition → SURVIVED 4. remove : negated conditional → KILLED 5. remove : negated conditional → KILLED |
else if(index<count_-1 && index>0) |
| 154 | { | |
| 155 | Node before=head; | |
| 156 |
4
1. remove : changed conditional boundary → KILLED 2. remove : Changed increment from 1 to -1 → KILLED 3. remove : Replaced integer subtraction with addition → KILLED 4. remove : negated conditional → KILLED |
for(int i=0;i<index-1;i++) |
| 157 | { | |
| 158 | before=before.next; | |
| 159 | } | |
| 160 | Node current=before.next; | |
| 161 | before.next=current.next; | |
| 162 |
1
1. remove : Replaced integer subtraction with addition → KILLED |
count--; |
| 163 | } | |
| 164 | else | |
| 165 |
1
1. remove : replaced return value with "" for com/mylinkedlist/app/App::remove → KILLED |
return "index is not valid"; |
| 166 | } | |
| 167 |
1
1. remove : negated conditional → KILLED |
else if(count_==0) |
| 168 |
1
1. remove : replaced return value with "" for com/mylinkedlist/app/App::remove → KILLED |
return "list is empty"; |
| 169 |
2
1. remove : changed conditional boundary → KILLED 2. remove : negated conditional → KILLED |
else if(index<0) |
| 170 |
1
1. remove : replaced return value with "" for com/mylinkedlist/app/App::remove → KILLED |
return "index is not valid"; |
| 171 |
2
1. remove : Replaced integer subtraction with addition → KILLED 2. remove : negated conditional → KILLED |
else if(index==count_-1) |
| 172 | { | |
| 173 | Node before=head; | |
| 174 |
4
1. remove : changed conditional boundary → SURVIVED 2. remove : Changed increment from 1 to -1 → KILLED 3. remove : Replaced integer subtraction with addition → KILLED 4. remove : negated conditional → KILLED |
for(int i=0;i<index-1;i++) |
| 175 | { | |
| 176 | before=before.next; | |
| 177 | } | |
| 178 | before.next=null; | |
| 179 | last=before; | |
| 180 |
1
1. remove : Replaced integer subtraction with addition → KILLED |
count--; |
| 181 | } | |
| 182 | ||
| 183 |
1
1. remove : replaced return value with "" for com/mylinkedlist/app/App::remove → KILLED |
return "removed"; |
| 184 | } | |
| 185 | ||
| 186 | void removeNodeGivenAsReference(Node n) | |
| 187 | { | |
| 188 |
1
1. removeNodeGivenAsReference : negated conditional → KILLED |
if(n.next!=null) |
| 189 | { | |
| 190 | n.data=n.next.data; | |
| 191 | n.next=n.next.next; | |
| 192 |
1
1. removeNodeGivenAsReference : Replaced integer subtraction with addition → KILLED |
count--; |
| 193 | } | |
| 194 | } | |
| 195 | ||
| 196 | /* | |
| 197 | * Swap | |
| 198 | */ | |
| 199 | ||
| 200 | void swap(int d1, int d2) | |
| 201 | { | |
| 202 | Node current=head; | |
| 203 | Node indexd1=null; | |
| 204 | Node indexd2=null; | |
| 205 |
3
1. swap : changed conditional boundary → KILLED 2. swap : Changed increment from 1 to -1 → KILLED 3. swap : negated conditional → KILLED |
for(int i=0;i<count;i++) |
| 206 | { | |
| 207 |
2
1. swap : negated conditional → KILLED 2. swap : negated conditional → KILLED |
if(current.data==d1 && indexd1==null ) |
| 208 | { | |
| 209 | indexd1=current; | |
| 210 | current=current.next; | |
| 211 | } | |
| 212 |
2
1. swap : negated conditional → KILLED 2. swap : negated conditional → KILLED |
else if(current.data==d2 && indexd2==null) |
| 213 | { | |
| 214 | indexd2=current; | |
| 215 | current=current.next; | |
| 216 | } | |
| 217 | else | |
| 218 | { | |
| 219 | current=current.next; | |
| 220 | } | |
| 221 | } | |
| 222 |
2
1. swap : negated conditional → KILLED 2. swap : negated conditional → KILLED |
if(indexd1 == null || indexd2 == null) |
| 223 | { | |
| 224 |
1
1. swap : removed call to java/io/PrintStream::println → KILLED |
System.out.println("elements not found"); |
| 225 | } | |
| 226 | else | |
| 227 | { | |
| 228 | indexd1.data=d2; | |
| 229 | indexd2.data=d1; | |
| 230 | } | |
| 231 | } | |
| 232 | ||
| 233 | public void swapNodes(int x, int y) | |
| 234 | { | |
| 235 | // Nothing to do if x and y are same | |
| 236 |
1
1. swapNodes : negated conditional → KILLED |
if (x == y) return; |
| 237 | ||
| 238 | // Search for x (keep track of prevX and CurrX) | |
| 239 | Node prevX = null, currX = head; | |
| 240 |
2
1. swapNodes : negated conditional → KILLED 2. swapNodes : negated conditional → KILLED |
while (currX != null && currX.data != x) |
| 241 | { | |
| 242 | prevX = currX; | |
| 243 | currX = currX.next; | |
| 244 | } | |
| 245 | ||
| 246 | // Search for y (keep track of prevY and currY) | |
| 247 | Node prevY = null, currY = head; | |
| 248 |
2
1. swapNodes : negated conditional → KILLED 2. swapNodes : negated conditional → KILLED |
while (currY != null && currY.data != y) |
| 249 | { | |
| 250 | prevY = currY; | |
| 251 | currY = currY.next; | |
| 252 | } | |
| 253 | ||
| 254 | // If either x or y is not present, nothing to do | |
| 255 |
2
1. swapNodes : negated conditional → KILLED 2. swapNodes : negated conditional → KILLED |
if (currX == null || currY == null) |
| 256 | return; | |
| 257 | ||
| 258 | // If x is not head of linked list | |
| 259 |
1
1. swapNodes : negated conditional → KILLED |
if (prevX != null) |
| 260 | prevX.next = currY; | |
| 261 | else //make y the new head | |
| 262 | head = currY; | |
| 263 | ||
| 264 | // If y is not head of linked list | |
| 265 |
1
1. swapNodes : negated conditional → KILLED |
if (prevY != null) |
| 266 | prevY.next = currX; | |
| 267 | else // make x the new head | |
| 268 | head = currX; | |
| 269 | ||
| 270 | // Swap next pointers | |
| 271 | Node temp = currX.next; | |
| 272 | currX.next = currY.next; | |
| 273 | currY.next = temp; | |
| 274 | } | |
| 275 | ||
| 276 | void reverse() { | |
| 277 | last=head; | |
| 278 | Node before = null; | |
| 279 | Node current = head; | |
| 280 | Node after = null; | |
| 281 |
1
1. reverse : negated conditional → KILLED |
while (current != null) |
| 282 | { | |
| 283 | after = current.next; | |
| 284 | current.next = before; | |
| 285 | before = current; | |
| 286 | current = after; | |
| 287 | } | |
| 288 | head = before; | |
| 289 | } | |
| 290 | ||
| 291 | void reverseR() | |
| 292 | { | |
| 293 | head=reverseRec(head,null,null); | |
| 294 | } | |
| 295 | ||
| 296 | Node reverseRec(Node current,Node before,Node after) | |
| 297 | { | |
| 298 |
1
1. reverseRec : negated conditional → SURVIVED |
if(current==head) |
| 299 | { | |
| 300 | last=current; | |
| 301 | } | |
| 302 |
1
1. reverseRec : negated conditional → KILLED |
if(current.next==null) |
| 303 | { | |
| 304 | Node x=current; | |
| 305 | current.next=before; | |
| 306 |
1
1. reverseRec : replaced return value with null for com/mylinkedlist/app/App::reverseRec → KILLED |
return x; |
| 307 | } | |
| 308 | after=current.next; | |
| 309 | current.next=before; | |
| 310 | before=current; | |
| 311 | current=after; | |
| 312 |
1
1. reverseRec : replaced return value with null for com/mylinkedlist/app/App::reverseRec → KILLED |
return reverseRec(current,before,after); |
| 313 | } | |
| 314 | ||
| 315 | void reverseByK(int k) | |
| 316 | { | |
| 317 | head=reverseByK(head,null,null,k); | |
| 318 | } | |
| 319 | ||
| 320 | Node reverseByK(Node current,Node before,Node after,int k) | |
| 321 | { | |
| 322 | Node tempHead=current; | |
| 323 | int kmodify=0; | |
| 324 | ||
| 325 |
3
1. reverseByK : changed conditional boundary → KILLED 2. reverseByK : negated conditional → KILLED 3. reverseByK : negated conditional → KILLED |
while(kmodify<k && current!=null) |
| 326 | { | |
| 327 | after = current.next; | |
| 328 | current.next = before; | |
| 329 | before = current; | |
| 330 | current = after; | |
| 331 |
1
1. reverseByK : Changed increment from 1 to -1 → KILLED |
kmodify++; |
| 332 | } | |
| 333 | ||
| 334 |
1
1. reverseByK : negated conditional → KILLED |
if(current!=null) |
| 335 | { | |
| 336 | tempHead.next=reverseByK(current,null,null,k); | |
| 337 | } | |
| 338 | else | |
| 339 | { | |
| 340 | last=tempHead; | |
| 341 | } | |
| 342 |
1
1. reverseByK : replaced return value with null for com/mylinkedlist/app/App::reverseByK → KILLED |
return before; |
| 343 | ||
| 344 | } | |
| 345 | ||
| 346 | void reverseAlternateKNodes(int k) | |
| 347 | { | |
| 348 | head=reverseAlternateKNodes(head,null,null,k); | |
| 349 | } | |
| 350 | ||
| 351 | Node reverseAlternateKNodes(Node current,Node before,Node after,int k) | |
| 352 | { | |
| 353 | Node tempHead=current; | |
| 354 | int kmodify=0; | |
| 355 | ||
| 356 |
3
1. reverseAlternateKNodes : changed conditional boundary → KILLED 2. reverseAlternateKNodes : negated conditional → KILLED 3. reverseAlternateKNodes : negated conditional → KILLED |
while(kmodify<k && current!=null) |
| 357 | { | |
| 358 | after = current.next; | |
| 359 | current.next = before; | |
| 360 | before = current; | |
| 361 | current = after; | |
| 362 |
1
1. reverseAlternateKNodes : Changed increment from 1 to -1 → KILLED |
kmodify++; |
| 363 | } | |
| 364 | Node lastNode=tempHead; | |
| 365 | int count=0; | |
| 366 |
1
1. reverseAlternateKNodes : negated conditional → KILLED |
if(current!=null) |
| 367 | { | |
| 368 | tempHead.next=current; | |
| 369 | } | |
| 370 |
2
1. reverseAlternateKNodes : changed conditional boundary → KILLED 2. reverseAlternateKNodes : negated conditional → KILLED |
while(count<k) |
| 371 | { | |
| 372 |
1
1. reverseAlternateKNodes : negated conditional → KILLED |
if(current==null) |
| 373 | { | |
| 374 |
1
1. reverseAlternateKNodes : replaced return value with null for com/mylinkedlist/app/App::reverseAlternateKNodes → KILLED |
return before; |
| 375 | } | |
| 376 | else | |
| 377 | { | |
| 378 | lastNode=current; | |
| 379 | current=current.next; | |
| 380 |
1
1. reverseAlternateKNodes : Changed increment from 1 to -1 → KILLED |
count++; |
| 381 | } | |
| 382 | } | |
| 383 |
1
1. reverseAlternateKNodes : negated conditional → KILLED |
if(current!=null) |
| 384 | lastNode.next=reverseAlternateKNodes(current,null,null,k); | |
| 385 | else | |
| 386 | last=tempHead; | |
| 387 |
1
1. reverseAlternateKNodes : replaced return value with null for com/mylinkedlist/app/App::reverseAlternateKNodes → KILLED |
return before; |
| 388 | } | |
| 389 | ||
| 390 | ||
| 391 | /* | |
| 392 | Traverse linked list using two pointers. Move one pointer by one and other pointer by two. | |
| 393 | When the fast pointer reaches end slow pointer will reach middle of the linked list. | |
| 394 | */ | |
| 395 | String printMiddleElement() | |
| 396 | { | |
| 397 | Node fastPointer=head; | |
| 398 | Node slowPointer=head; | |
| 399 |
2
1. printMiddleElement : negated conditional → KILLED 2. printMiddleElement : negated conditional → KILLED |
while(fastPointer.next!=null && fastPointer.next.next!=null) |
| 400 | { | |
| 401 | fastPointer=fastPointer.next.next; | |
| 402 | slowPointer=slowPointer.next; | |
| 403 | } | |
| 404 | String s ="middle element is:"+slowPointer.data; | |
| 405 |
1
1. printMiddleElement : replaced return value with "" for com/mylinkedlist/app/App::printMiddleElement → KILLED |
return s; |
| 406 | } | |
| 407 | ||
| 408 | Node getMiddleElement(Node head) | |
| 409 | { | |
| 410 | Node fastPointer=head; | |
| 411 | Node slowPointer=head; | |
| 412 |
2
1. getMiddleElement : negated conditional → KILLED 2. getMiddleElement : negated conditional → KILLED |
while(fastPointer.next!=null && fastPointer.next.next!=null) |
| 413 | { | |
| 414 | fastPointer=fastPointer.next.next; | |
| 415 | slowPointer=slowPointer.next; | |
| 416 | } | |
| 417 |
1
1. getMiddleElement : replaced return value with null for com/mylinkedlist/app/App::getMiddleElement → KILLED |
return slowPointer; |
| 418 | } | |
| 419 | ||
| 420 | void printNthNodeFromLast(int n) | |
| 421 | { | |
| 422 | Node reference=head; | |
| 423 | Node main=head; | |
| 424 |
4
1. printNthNodeFromLast : changed conditional boundary → KILLED 2. printNthNodeFromLast : Changed increment from 1 to -1 → KILLED 3. printNthNodeFromLast : negated conditional → KILLED 4. printNthNodeFromLast : negated conditional → KILLED |
for(int i=1;i<n && reference.next!=null;i++) |
| 425 | reference=reference.next; | |
| 426 |
1
1. printNthNodeFromLast : negated conditional → KILLED |
if(reference==null) |
| 427 | { | |
| 428 |
1
1. printNthNodeFromLast : removed call to java/io/PrintStream::println → KILLED |
System.out.println("size exceeds"); |
| 429 | return; | |
| 430 | } | |
| 431 |
1
1. printNthNodeFromLast : negated conditional → KILLED |
while(reference.next!=null) |
| 432 | { | |
| 433 | reference=reference.next; | |
| 434 | main=main.next; | |
| 435 | } | |
| 436 |
1
1. printNthNodeFromLast : removed call to java/io/PrintStream::println → KILLED |
System.out.println(n+"th node from the last is:"+main.data); |
| 437 | } | |
| 438 | ||
| 439 | ||
| 440 | boolean isPalindrom() | |
| 441 | { | |
| 442 | Node middle=head; | |
| 443 | Node fastPointer=head; | |
| 444 | Node slowPointer=head; | |
| 445 | //find out middle node | |
| 446 |
2
1. isPalindrom : negated conditional → KILLED 2. isPalindrom : negated conditional → KILLED |
while(fastPointer.next!=null && fastPointer.next.next!=null) |
| 447 | { | |
| 448 | fastPointer=fastPointer.next.next; | |
| 449 | slowPointer=slowPointer.next; | |
| 450 | } | |
| 451 | middle=slowPointer.next; | |
| 452 | Node link=reverseRec(middle,null,null); | |
| 453 | ||
| 454 | slowPointer.next=link; | |
| 455 | ||
| 456 | printList(); | |
| 457 | Node i=head; | |
| 458 | Node j=slowPointer.next; | |
| 459 |
1
1. isPalindrom : negated conditional → KILLED |
while(j!=null) |
| 460 | { | |
| 461 |
1
1. isPalindrom : negated conditional → KILLED |
if(i.data==j.data) |
| 462 | { | |
| 463 | i=i.next; | |
| 464 | j=j.next; | |
| 465 | } | |
| 466 | else | |
| 467 |
1
1. isPalindrom : replaced boolean return with true for com/mylinkedlist/app/App::isPalindrom → KILLED |
return false; |
| 468 | } | |
| 469 | Node link1=reverseRec(slowPointer.next,null,null); | |
| 470 | slowPointer.next=link1; | |
| 471 |
1
1. isPalindrom : replaced boolean return with false for com/mylinkedlist/app/App::isPalindrom → KILLED |
return true; |
| 472 | } | |
| 473 | ||
| 474 | ||
| 475 | ||
| 476 | String printList() | |
| 477 | { | |
| 478 | Node current=head; | |
| 479 | String s = ""; | |
| 480 |
1
1. printList : negated conditional → KILLED |
while(current!=null) |
| 481 | { | |
| 482 | s=s + current.data + " "; | |
| 483 | current=current.next; | |
| 484 | } | |
| 485 |
1
1. printList : replaced return value with "" for com/mylinkedlist/app/App::printList → KILLED |
return s; |
| 486 | } | |
| 487 | ||
| 488 | /* | |
| 489 | Floyd’s Cycle-Finding Algorithm: | |
| 490 | This is the fastest method. Traverse linked list using two pointers. | |
| 491 | Move one pointer by one and other pointer by two. | |
| 492 | If these pointers meet at some node then there is a loop. | |
| 493 | If pointers do not meet then linked list doesn’t have loop. | |
| 494 | */ | |
| 495 | boolean findLoop() | |
| 496 | { | |
| 497 |
2
1. findLoop : negated conditional → KILLED 2. findLoop : replaced boolean return with true for com/mylinkedlist/app/App::findLoop → KILLED |
if(head == null) return false; |
| 498 | Node fastPointer=head; | |
| 499 | Node slowPointer=head; | |
| 500 |
2
1. findLoop : negated conditional → KILLED 2. findLoop : negated conditional → KILLED |
while(fastPointer.next!=null && fastPointer.next.next!=null) |
| 501 | { | |
| 502 | fastPointer=fastPointer.next.next; | |
| 503 | slowPointer=slowPointer.next; | |
| 504 |
1
1. findLoop : negated conditional → SURVIVED |
if(fastPointer==slowPointer) |
| 505 |
1
1. findLoop : replaced boolean return with false for com/mylinkedlist/app/App::findLoop → KILLED |
return true; |
| 506 | } | |
| 507 |
1
1. findLoop : replaced boolean return with true for com/mylinkedlist/app/App::findLoop → KILLED |
return false; |
| 508 | ||
| 509 | } | |
| 510 | ||
| 511 | String mergeTwoSorted(App liM1,App liM2) | |
| 512 | { | |
| 513 | Node curr1=liM1.head; | |
| 514 | Node curr2=liM2.head; | |
| 515 | ||
| 516 | Node tmpHead=null; | |
| 517 | Node modifierNode=null; | |
| 518 | while(true) | |
| 519 | { | |
| 520 |
5
1. mergeTwoSorted : changed conditional boundary → KILLED 2. mergeTwoSorted : negated conditional → KILLED 3. mergeTwoSorted : negated conditional → KILLED 4. mergeTwoSorted : negated conditional → KILLED 5. mergeTwoSorted : negated conditional → KILLED |
if(curr1!=null && curr2!=null && curr1.data < curr2.data && modifierNode==null) |
| 521 | { | |
| 522 | ||
| 523 | this.head=curr1; | |
| 524 | modifierNode=curr1; | |
| 525 | curr1=curr1.next; | |
| 526 | } | |
| 527 |
5
1. mergeTwoSorted : changed conditional boundary → KILLED 2. mergeTwoSorted : negated conditional → KILLED 3. mergeTwoSorted : negated conditional → KILLED 4. mergeTwoSorted : negated conditional → KILLED 5. mergeTwoSorted : negated conditional → KILLED |
else if(curr1!=null && curr2!=null && curr1.data < curr2.data && modifierNode!=null) |
| 528 | { | |
| 529 | modifierNode.next=curr1; | |
| 530 | modifierNode=curr1; | |
| 531 | curr1=curr1.next; | |
| 532 | ||
| 533 | } | |
| 534 |
5
1. mergeTwoSorted : changed conditional boundary → KILLED 2. mergeTwoSorted : negated conditional → KILLED 3. mergeTwoSorted : negated conditional → KILLED 4. mergeTwoSorted : negated conditional → KILLED 5. mergeTwoSorted : negated conditional → KILLED |
else if(curr1!=null && curr2!=null && curr2.data < curr1.data && modifierNode==null) |
| 535 | { | |
| 536 | this.head=curr2; | |
| 537 | modifierNode=curr2; | |
| 538 | curr2=curr2.next; | |
| 539 | ||
| 540 | } | |
| 541 |
5
1. mergeTwoSorted : changed conditional boundary → KILLED 2. mergeTwoSorted : negated conditional → KILLED 3. mergeTwoSorted : negated conditional → KILLED 4. mergeTwoSorted : negated conditional → KILLED 5. mergeTwoSorted : negated conditional → KILLED |
else if(curr1!=null && curr2!=null && curr2.data < curr1.data && modifierNode!=null) |
| 542 | { | |
| 543 | modifierNode.next=curr2; | |
| 544 | modifierNode=curr2; | |
| 545 | curr2=curr2.next; | |
| 546 | ||
| 547 | } | |
| 548 |
2
1. mergeTwoSorted : negated conditional → KILLED 2. mergeTwoSorted : negated conditional → KILLED |
else if(curr1!=null && curr2!=null)//duplicate nodes remove |
| 549 | { | |
| 550 |
1
1. mergeTwoSorted : negated conditional → KILLED |
if(modifierNode==null) |
| 551 | { | |
| 552 | this.head=curr1; | |
| 553 | modifierNode=curr1; | |
| 554 | curr1=curr1.next; | |
| 555 | curr2=curr2.next; | |
| 556 | } | |
| 557 | else | |
| 558 | { | |
| 559 | modifierNode.next=curr1; | |
| 560 | modifierNode=curr1; | |
| 561 | curr1=curr1.next; | |
| 562 | curr2=curr2.next; | |
| 563 | } | |
| 564 | } | |
| 565 | else | |
| 566 | break; | |
| 567 | ||
| 568 | } | |
| 569 | ||
| 570 |
1
1. mergeTwoSorted : negated conditional → SURVIVED |
if(curr1==null) |
| 571 | { | |
| 572 | modifierNode.next=curr2; | |
| 573 | } | |
| 574 |
1
1. mergeTwoSorted : negated conditional → KILLED |
if(curr2==null) |
| 575 | { | |
| 576 | modifierNode.next=curr1; | |
| 577 | } | |
| 578 | Node curr=this.head; | |
| 579 | StringBuilder sb=new StringBuilder(); | |
| 580 |
1
1. mergeTwoSorted : negated conditional → KILLED |
while(curr!=null) |
| 581 | { | |
| 582 | sb.append(curr.data); | |
| 583 | curr=curr.next; | |
| 584 | } | |
| 585 |
1
1. mergeTwoSorted : replaced return value with "" for com/mylinkedlist/app/App::mergeTwoSorted → KILLED |
return sb.toString(); |
| 586 | ||
| 587 | } | |
| 588 | ||
| 589 | void printReverse() | |
| 590 | { | |
| 591 |
1
1. printReverse : removed call to com/mylinkedlist/app/App::printReverse → KILLED |
printReverse(head); |
| 592 | } | |
| 593 | ||
| 594 | void printReverse(Node current) | |
| 595 | { | |
| 596 |
1
1. printReverse : negated conditional → KILLED |
if(current.next!=null) |
| 597 |
1
1. printReverse : removed call to com/mylinkedlist/app/App::printReverse → KILLED |
printReverse(current.next); |
| 598 |
1
1. printReverse : removed call to java/io/PrintStream::print → KILLED |
System.out.print(current.data+" "); //tail recursion |
| 599 | } | |
| 600 | ||
| 601 | void removeDuplicatesInSortedList() | |
| 602 | { | |
| 603 | Node pre=null; | |
| 604 | Node current=head; | |
| 605 |
1
1. removeDuplicatesInSortedList : negated conditional → KILLED |
if(head==null) |
| 606 | return; | |
| 607 |
1
1. removeDuplicatesInSortedList : negated conditional → KILLED |
while(current.next!=null) |
| 608 | { | |
| 609 | pre=current; | |
| 610 | current=current.next; | |
| 611 |
1
1. removeDuplicatesInSortedList : negated conditional → KILLED |
if(pre.data==current.data) |
| 612 | { | |
| 613 | pre.next=current.next; | |
| 614 | current=pre; | |
| 615 | } | |
| 616 | } | |
| 617 | } | |
| 618 | ||
| 619 | void removeDuplicatesInUnsortedList() | |
| 620 | { | |
| 621 | HashMap<Integer,Boolean> hm=new HashMap<Integer,Boolean>(); | |
| 622 | Node current=head; | |
| 623 | Node pre=null; | |
| 624 |
1
1. removeDuplicatesInUnsortedList : negated conditional → KILLED |
while(current!=null) |
| 625 | { | |
| 626 |
1
1. removeDuplicatesInUnsortedList : negated conditional → KILLED |
if(hm.containsKey(current.data)) |
| 627 | { | |
| 628 | pre.next=current.next; | |
| 629 | current=pre.next; | |
| 630 | } | |
| 631 | else | |
| 632 | { | |
| 633 | hm.put(current.data,true); | |
| 634 | pre=current; | |
| 635 | current=current.next; | |
| 636 | } | |
| 637 | } | |
| 638 | } | |
| 639 | ||
| 640 | String swapPairWise() | |
| 641 | { | |
| 642 |
1
1. swapPairWise : removed call to com/mylinkedlist/app/App::swapPairWise → KILLED |
swapPairWise(head,head.next,null); |
| 643 | Node curr=this.head; | |
| 644 | StringBuilder sb=new StringBuilder(); | |
| 645 |
1
1. swapPairWise : negated conditional → KILLED |
while(curr!=null) |
| 646 | { | |
| 647 | sb.append(curr.data); | |
| 648 | curr=curr.next; | |
| 649 | } | |
| 650 |
1
1. swapPairWise : replaced return value with "" for com/mylinkedlist/app/App::swapPairWise → KILLED |
return sb.toString(); |
| 651 | } | |
| 652 | ||
| 653 | void swapPairWise(Node pre,Node current,Node prePre) | |
| 654 | { | |
| 655 |
3
1. swapPairWise : negated conditional → KILLED 2. swapPairWise : negated conditional → KILLED 3. swapPairWise : negated conditional → KILLED |
if(pre==null || current==null || pre==head) |
| 656 | { | |
| 657 |
2
1. swapPairWise : negated conditional → KILLED 2. swapPairWise : negated conditional → KILLED |
if(pre==null || current==null) |
| 658 | { | |
| 659 | return; | |
| 660 | } | |
| 661 |
1
1. swapPairWise : negated conditional → KILLED |
if(pre==head) |
| 662 | { | |
| 663 | head=head.next; | |
| 664 | } | |
| 665 | } | |
| 666 | pre.next=current.next; | |
| 667 | current.next=pre; | |
| 668 |
1
1. swapPairWise : negated conditional → KILLED |
if(prePre!=null) |
| 669 | { | |
| 670 | prePre.next=current; | |
| 671 | } | |
| 672 | prePre=pre; | |
| 673 | pre=pre.next; | |
| 674 | //here for even length pre will be null | |
| 675 | //so current=pre.next only if pre!=null | |
| 676 | //otherwise it will give nullpointerException! | |
| 677 |
1
1. swapPairWise : negated conditional → KILLED |
if(pre!=null) |
| 678 | { | |
| 679 | current=pre.next; | |
| 680 | } | |
| 681 |
1
1. swapPairWise : removed call to com/mylinkedlist/app/App::swapPairWise → KILLED |
swapPairWise(pre,current,prePre); |
| 682 | } | |
| 683 | ||
| 684 | void intersectionOfLists(App list1,App list2) | |
| 685 | { | |
| 686 | Node n1=list1.head; | |
| 687 | Node n2=list2.head; | |
| 688 | head=intersection(n1,n2); | |
| 689 | } | |
| 690 | ||
| 691 | Node intersection(Node n1,Node n2) | |
| 692 | { | |
| 693 |
2
1. intersection : negated conditional → KILLED 2. intersection : negated conditional → KILLED |
if(n1==null || n2==null) |
| 694 | return null; | |
| 695 |
2
1. intersection : changed conditional boundary → KILLED 2. intersection : negated conditional → KILLED |
if(n1.data<n2.data) |
| 696 |
1
1. intersection : replaced return value with null for com/mylinkedlist/app/App::intersection → KILLED |
return intersection(n1.next,n2); |
| 697 |
2
1. intersection : changed conditional boundary → KILLED 2. intersection : negated conditional → KILLED |
if(n2.data<n1.data) |
| 698 |
1
1. intersection : replaced return value with null for com/mylinkedlist/app/App::intersection → KILLED |
return intersection(n1,n2.next); |
| 699 | Node n=new Node(n1.data); | |
| 700 | n.next=intersection(n1.next,n2.next); | |
| 701 |
1
1. intersection : replaced return value with null for com/mylinkedlist/app/App::intersection → KILLED |
return n; |
| 702 | | |
| 703 | } | |
| 704 | ||
| 705 | void removeAlternateNodes() | |
| 706 | { | |
| 707 | int i=0; | |
| 708 | Node pre=null; | |
| 709 | Node current=head; | |
| 710 |
1
1. removeAlternateNodes : negated conditional → KILLED |
while(current!=null) |
| 711 | { | |
| 712 |
2
1. removeAlternateNodes : Replaced integer modulus with multiplication → KILLED 2. removeAlternateNodes : negated conditional → KILLED |
if(i%2==0) |
| 713 | { | |
| 714 | pre=current; | |
| 715 | current=current.next; | |
| 716 |
1
1. removeAlternateNodes : Changed increment from 1 to -1 → SURVIVED |
i++; |
| 717 | } | |
| 718 | else | |
| 719 | { | |
| 720 | pre.next=current.next; | |
| 721 | current=current.next; | |
| 722 |
1
1. removeAlternateNodes : Changed increment from 1 to -1 → SURVIVED |
i++; |
| 723 | } | |
| 724 | } | |
| 725 | } | |
| 726 | ||
| 727 | void removeAlternateNodesRecurcive() | |
| 728 | { | |
| 729 |
1
1. removeAlternateNodesRecurcive : removed call to com/mylinkedlist/app/App::removeAlternateNodesRecurcive → KILLED |
removeAlternateNodesRecurcive(head); |
| 730 | } | |
| 731 | | |
| 732 | void removeAlternateNodesRecurcive(Node current) | |
| 733 | { | |
| 734 |
2
1. removeAlternateNodesRecurcive : negated conditional → KILLED 2. removeAlternateNodesRecurcive : negated conditional → KILLED |
if(current==null || current.next==null ) |
| 735 | return; | |
| 736 |
1
1. removeAlternateNodesRecurcive : negated conditional → KILLED |
if(current.next.next!=null) |
| 737 | current.next=current.next.next; | |
| 738 | else | |
| 739 | current.next=null; | |
| 740 |
1
1. removeAlternateNodesRecurcive : removed call to com/mylinkedlist/app/App::removeAlternateNodesRecurcive → KILLED |
removeAlternateNodesRecurcive(current.next); |
| 741 | } | |
| 742 | ||
| 743 | void alternatingSplit(App l) | |
| 744 | { | |
| 745 |
1
1. alternatingSplit : negated conditional → KILLED |
if(head==null) |
| 746 | return; | |
| 747 | Node head1=head; | |
| 748 | Node last1=head1; | |
| 749 | Node head2=null; | |
| 750 | Node last2=null; | |
| 751 | Node current=head.next; | |
| 752 | int i=0; | |
| 753 |
1
1. alternatingSplit : negated conditional → KILLED |
while(current!=null) |
| 754 | { | |
| 755 |
2
1. alternatingSplit : Replaced integer modulus with multiplication → KILLED 2. alternatingSplit : negated conditional → KILLED |
if(i%2==0) |
| 756 | { | |
| 757 |
1
1. alternatingSplit : negated conditional → KILLED |
if(head2==null) |
| 758 | { | |
| 759 | head2=current; | |
| 760 | last2=head2; | |
| 761 |
1
1. alternatingSplit : Changed increment from 1 to -1 → SURVIVED |
i++; |
| 762 | current=current.next; | |
| 763 | } | |
| 764 | else | |
| 765 | { | |
| 766 | last2.next=current; | |
| 767 | last2=last2.next; | |
| 768 |
1
1. alternatingSplit : Changed increment from 1 to -1 → SURVIVED |
i++; |
| 769 | current=current.next; | |
| 770 | } | |
| 771 | } | |
| 772 | else | |
| 773 | { | |
| 774 | last1.next=current; | |
| 775 | last1=last1.next; | |
| 776 |
1
1. alternatingSplit : Changed increment from 1 to -1 → SURVIVED |
i++; |
| 777 | current=current.next; | |
| 778 | } | |
| 779 | } | |
| 780 |
2
1. alternatingSplit : Replaced integer modulus with multiplication → KILLED 2. alternatingSplit : negated conditional → KILLED |
if(i%2==0) |
| 781 | last2.next=null; | |
| 782 | else | |
| 783 | last1.next=null; | |
| 784 | //l1.head=head1; | |
| 785 | l.head=head2; | |
| 786 | } | |
| 787 | ||
| 788 | String isIdentical(App l1, App l2) | |
| 789 | { | |
| 790 | Node n1=l1.head; | |
| 791 | Node n2=l2.head; | |
| 792 | String result=isIdentical(n1,n2); | |
| 793 |
1
1. isIdentical : replaced return value with "" for com/mylinkedlist/app/App::isIdentical → KILLED |
return result; |
| 794 | } | |
| 795 | ||
| 796 | String isIdentical(Node n1,Node n2) | |
| 797 | { | |
| 798 |
2
1. isIdentical : negated conditional → KILLED 2. isIdentical : negated conditional → KILLED |
if(n1==null && n2==null) |
| 799 | { | |
| 800 |
1
1. isIdentical : replaced return value with "" for com/mylinkedlist/app/App::isIdentical → KILLED |
return "Identical"; |
| 801 | } | |
| 802 |
3
1. isIdentical : negated conditional → KILLED 2. isIdentical : negated conditional → KILLED 3. isIdentical : negated conditional → KILLED |
else if(n1!=null && n2!=null && n1.data==n2.data) |
| 803 | { | |
| 804 |
1
1. isIdentical : replaced return value with "" for com/mylinkedlist/app/App::isIdentical → KILLED |
return isIdentical(n1.next,n2.next); |
| 805 | } | |
| 806 | else | |
| 807 | { | |
| 808 |
1
1. isIdentical : replaced return value with "" for com/mylinkedlist/app/App::isIdentical → KILLED |
return "Not Identical"; |
| 809 | } | |
| 810 | } | |
| 811 | ||
| 812 | //Merge Sort link-list | |
| 813 | //we use the same divide and conquer approach | |
| 814 | // to partition we need to write one function as well | |
| 815 | //1. partition | |
| 816 | //2. recursively call both half | |
| 817 | //3. until both have one element => call then mergeList | |
| 818 | ||
| 819 | void mergeSort() | |
| 820 | { | |
| 821 | this.head=doMergeSort(head); | |
| 822 | } | |
| 823 | ||
| 824 | Node doMergeSort(Node head) | |
| 825 | { | |
| 826 | //single node, or no node=> return that | |
| 827 |
2
1. doMergeSort : negated conditional → KILLED 2. doMergeSort : negated conditional → KILLED |
if(head==null || head.next==null) |
| 828 |
1
1. doMergeSort : replaced return value with null for com/mylinkedlist/app/App::doMergeSort → KILLED |
return head; |
| 829 | ||
| 830 | Node middle=getMiddleElement(head); | |
| 831 | ||
| 832 | //divide the list into two parts | |
| 833 | Node front=head; | |
| 834 | Node back=middle.next; | |
| 835 | middle.next=null; | |
| 836 | ||
| 837 | //recursively call to partition list into two lists | |
| 838 | front=doMergeSort(front); | |
| 839 | back=doMergeSort(back); | |
| 840 | ||
| 841 | //front and back will contain the list into chunnks at each page | |
| 842 | //merge the list in bottom up approach | |
| 843 | //and set the head of the list and return | |
| 844 | head=mergeLists(front, back); | |
| 845 |
1
1. doMergeSort : replaced return value with null for com/mylinkedlist/app/App::doMergeSort → KILLED |
return head; |
| 846 | } | |
| 847 | ||
| 848 | //1st time call to merge=> only two nodes | |
| 849 | //then, it will always be two sorted list | |
| 850 | //so merge of two sorted list | |
| 851 | Node mergeLists(Node curr1,Node curr2) | |
| 852 | { | |
| 853 | Node head=null; | |
| 854 | Node modifierNode=null; | |
| 855 | ||
| 856 | //if any one list is empty, simply return the other | |
| 857 |
1
1. mergeLists : negated conditional → KILLED |
if(curr1==null) |
| 858 | { | |
| 859 |
1
1. mergeLists : replaced return value with null for com/mylinkedlist/app/App::mergeLists → KILLED |
return curr2; |
| 860 | } | |
| 861 |
1
1. mergeLists : negated conditional → KILLED |
else if(curr2==null) |
| 862 | { | |
| 863 |
1
1. mergeLists : replaced return value with null for com/mylinkedlist/app/App::mergeLists → KILLED |
return curr1; |
| 864 | } | |
| 865 | ||
| 866 | //modifier node is the one with correct order | |
| 867 | // curr1 and curr2 are compared and set to next of modifier | |
| 868 | ||
| 869 |
2
1. mergeLists : negated conditional → KILLED 2. mergeLists : negated conditional → KILLED |
while(curr1!=null && curr2!=null) |
| 870 | { | |
| 871 | //<= becoz to preserve the order of nodes in original list | |
| 872 |
2
1. mergeLists : changed conditional boundary → SURVIVED 2. mergeLists : negated conditional → KILLED |
if(curr1.data <= curr2.data) |
| 873 | { | |
| 874 |
1
1. mergeLists : negated conditional → KILLED |
if(modifierNode==null) |
| 875 | { | |
| 876 | head=curr1; | |
| 877 | modifierNode=curr1; | |
| 878 | curr1=curr1.next; | |
| 879 | } | |
| 880 | else | |
| 881 | { | |
| 882 | modifierNode.next=curr1; | |
| 883 | modifierNode=curr1; | |
| 884 | curr1=curr1.next; | |
| 885 | ||
| 886 | } | |
| 887 | } | |
| 888 | else //(curr2.data < curr1.data) | |
| 889 | { | |
| 890 |
1
1. mergeLists : negated conditional → KILLED |
if(modifierNode==null) |
| 891 | { | |
| 892 | head=curr2; | |
| 893 | modifierNode=curr2; | |
| 894 | curr2=curr2.next; | |
| 895 | } | |
| 896 | else | |
| 897 | { | |
| 898 | modifierNode.next=curr2; | |
| 899 | modifierNode=curr2; | |
| 900 | curr2=curr2.next; | |
| 901 | ||
| 902 | } | |
| 903 | } | |
| 904 | } | |
| 905 | ||
| 906 | ||
| 907 | //once a list is empty=> just join the other list at the end | |
| 908 |
1
1. mergeLists : negated conditional → KILLED |
if(curr1==null) |
| 909 | { | |
| 910 | modifierNode.next=curr2; | |
| 911 | } | |
| 912 |
1
1. mergeLists : negated conditional → KILLED |
if(curr2==null) |
| 913 | { | |
| 914 | modifierNode.next=curr1; | |
| 915 | } | |
| 916 | ||
| 917 |
1
1. mergeLists : replaced return value with null for com/mylinkedlist/app/App::mergeLists → KILLED |
return head; |
| 918 | ||
| 919 | ||
| 920 | }//end of mergeLists | |
| 921 | ||
| 922 | void removeifrightSideNodeIsGreater() | |
| 923 | { | |
| 924 |
1
1. removeifrightSideNodeIsGreater : negated conditional → KILLED |
if(head == null) return; |
| 925 |
1
1. removeifrightSideNodeIsGreater : removed call to com/mylinkedlist/app/App::removeifrightSideNodeIsGreater → KILLED |
removeifrightSideNodeIsGreater(null,head,head.next); |
| 926 | } | |
| 927 | ||
| 928 | void removeifrightSideNodeIsGreater(Node pre,Node current,Node after) | |
| 929 | { | |
| 930 |
2
1. removeifrightSideNodeIsGreater : negated conditional → KILLED 2. removeifrightSideNodeIsGreater : negated conditional → KILLED |
if(current==null || current.next ==null) |
| 931 | { | |
| 932 | return; | |
| 933 | } | |
| 934 |
2
1. removeifrightSideNodeIsGreater : changed conditional boundary → KILLED 2. removeifrightSideNodeIsGreater : negated conditional → KILLED |
else if(current.data<after.data) |
| 935 | { | |
| 936 |
1
1. removeifrightSideNodeIsGreater : negated conditional → KILLED |
if(current==head) |
| 937 | { | |
| 938 | head=after; | |
| 939 |
1
1. removeifrightSideNodeIsGreater : removed call to com/mylinkedlist/app/App::removeifrightSideNodeIsGreater → KILLED |
removeifrightSideNodeIsGreater(null,head,head.next); |
| 940 | } | |
| 941 | else | |
| 942 | { | |
| 943 | pre.next=after; | |
| 944 |
1
1. removeifrightSideNodeIsGreater : removed call to com/mylinkedlist/app/App::removeifrightSideNodeIsGreater → SURVIVED |
removeifrightSideNodeIsGreater(pre,after,after.next); |
| 945 | } | |
| 946 | } | |
| 947 | else | |
| 948 | { | |
| 949 |
1
1. removeifrightSideNodeIsGreater : removed call to com/mylinkedlist/app/App::removeifrightSideNodeIsGreater → KILLED |
removeifrightSideNodeIsGreater(current,after,after.next); |
| 950 | } | |
| 951 | } | |
| 952 | ||
| 953 | void removeNodeifAnyRHSisBigger() | |
| 954 | { | |
| 955 | //first reverse the list | |
| 956 | //and assign max node | |
| 957 | //all nodes right side to it smaller than max must be deleted | |
| 958 | //which is same as given question in reverse order | |
| 959 | //then if max is lesser change max | |
| 960 | //in the end again reverse the list. | |
| 961 |
1
1. removeNodeifAnyRHSisBigger : removed call to com/mylinkedlist/app/App::reverseR → KILLED |
this.reverseR(); |
| 962 | Node max=head; | |
| 963 | Node current=head.next; | |
| 964 |
1
1. removeNodeifAnyRHSisBigger : negated conditional → KILLED |
while(current!=null) |
| 965 | { | |
| 966 |
2
1. removeNodeifAnyRHSisBigger : changed conditional boundary → KILLED 2. removeNodeifAnyRHSisBigger : negated conditional → KILLED |
if(max.data<=current.data) |
| 967 | { | |
| 968 | max=max.next; | |
| 969 | current=current.next; | |
| 970 | } | |
| 971 | else | |
| 972 | { | |
| 973 | max.next=current.next; | |
| 974 | current=current.next; | |
| 975 | } | |
| 976 | } | |
| 977 |
1
1. removeNodeifAnyRHSisBigger : removed call to com/mylinkedlist/app/App::reverseR → KILLED |
this.reverseR(); |
| 978 | } | |
| 979 | ||
| 980 | void evenDataFirst() | |
| 981 | { | |
| 982 | //shift all odd elements to the end of the list | |
| 983 | //it will not even change the order of odd and even elements | |
| 984 | Node pre=null; | |
| 985 | Node current=head; | |
| 986 |
2
1. evenDataFirst : negated conditional → KILLED 2. evenDataFirst : negated conditional → KILLED |
if(head==null || head.next==null) |
| 987 | { | |
| 988 | return; | |
| 989 | } | |
| 990 | int count_ = size(head); | |
| 991 |
2
1. evenDataFirst : changed conditional boundary → KILLED 2. evenDataFirst : negated conditional → KILLED |
while(count_>0) |
| 992 | { | |
| 993 |
2
1. evenDataFirst : Replaced integer modulus with multiplication → KILLED 2. evenDataFirst : negated conditional → KILLED |
if(current.data%2==0) |
| 994 | { | |
| 995 | pre=current; | |
| 996 | current=current.next; | |
| 997 |
1
1. evenDataFirst : Changed increment from -1 to 1 → SURVIVED |
count_--; |
| 998 | } | |
| 999 | else | |
| 1000 | { | |
| 1001 |
1
1. evenDataFirst : negated conditional → KILLED |
if(current==head) |
| 1002 | { | |
| 1003 | head=current.next; | |
| 1004 | } | |
| 1005 | else | |
| 1006 | { | |
| 1007 | pre.next=current.next; | |
| 1008 | } | |
| 1009 | last.next=current; | |
| 1010 | last=current; | |
| 1011 | current=current.next; | |
| 1012 | last.next=null; | |
| 1013 |
1
1. evenDataFirst : Changed increment from -1 to 1 → TIMED_OUT |
count_--; |
| 1014 | } | |
| 1015 | } | |
| 1016 | } | |
| 1017 | } | |
Mutations | ||
| 30 |
1.1 |
|
| 35 |
1.1 |
|
| 37 |
1.1 2.2 |
|
| 47 |
1.1 2.2 3.3 |
|
| 51 |
1.1 |
|
| 61 |
1.1 2.2 3.3 |
|
| 75 |
1.1 |
|
| 79 |
1.1 |
|
| 85 |
1.1 |
|
| 92 |
1.1 2.2 3.3 4.4 5.5 |
|
| 94 |
1.1 2.2 |
|
| 98 |
1.1 2.2 3.3 4.4 |
|
| 104 |
1.1 |
|
| 105 |
1.1 |
|
| 107 |
1.1 |
|
| 112 |
1.1 |
|
| 113 |
1.1 |
|
| 116 |
1.1 |
|
| 121 |
1.1 |
|
| 122 |
1.1 |
|
| 125 |
1.1 |
|
| 135 |
1.1 |
|
| 146 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 |
|
| 148 |
1.1 |
|
| 151 |
1.1 |
|
| 153 |
1.1 2.2 3.3 4.4 5.5 |
|
| 156 |
1.1 2.2 3.3 4.4 |
|
| 162 |
1.1 |
|
| 165 |
1.1 |
|
| 167 |
1.1 |
|
| 168 |
1.1 |
|
| 169 |
1.1 2.2 |
|
| 170 |
1.1 |
|
| 171 |
1.1 2.2 |
|
| 174 |
1.1 2.2 3.3 4.4 |
|
| 180 |
1.1 |
|
| 183 |
1.1 |
|
| 188 |
1.1 |
|
| 192 |
1.1 |
|
| 205 |
1.1 2.2 3.3 |
|
| 207 |
1.1 2.2 |
|
| 212 |
1.1 2.2 |
|
| 222 |
1.1 2.2 |
|
| 224 |
1.1 |
|
| 236 |
1.1 |
|
| 240 |
1.1 2.2 |
|
| 248 |
1.1 2.2 |
|
| 255 |
1.1 2.2 |
|
| 259 |
1.1 |
|
| 265 |
1.1 |
|
| 281 |
1.1 |
|
| 298 |
1.1 |
|
| 302 |
1.1 |
|
| 306 |
1.1 |
|
| 312 |
1.1 |
|
| 325 |
1.1 2.2 3.3 |
|
| 331 |
1.1 |
|
| 334 |
1.1 |
|
| 342 |
1.1 |
|
| 356 |
1.1 2.2 3.3 |
|
| 362 |
1.1 |
|
| 366 |
1.1 |
|
| 370 |
1.1 2.2 |
|
| 372 |
1.1 |
|
| 374 |
1.1 |
|
| 380 |
1.1 |
|
| 383 |
1.1 |
|
| 387 |
1.1 |
|
| 399 |
1.1 2.2 |
|
| 405 |
1.1 |
|
| 412 |
1.1 2.2 |
|
| 417 |
1.1 |
|
| 424 |
1.1 2.2 3.3 4.4 |
|
| 426 |
1.1 |
|
| 428 |
1.1 |
|
| 431 |
1.1 |
|
| 436 |
1.1 |
|
| 446 |
1.1 2.2 |
|
| 459 |
1.1 |
|
| 461 |
1.1 |
|
| 467 |
1.1 |
|
| 471 |
1.1 |
|
| 480 |
1.1 |
|
| 485 |
1.1 |
|
| 497 |
1.1 2.2 |
|
| 500 |
1.1 2.2 |
|
| 504 |
1.1 |
|
| 505 |
1.1 |
|
| 507 |
1.1 |
|
| 520 |
1.1 2.2 3.3 4.4 5.5 |
|
| 527 |
1.1 2.2 3.3 4.4 5.5 |
|
| 534 |
1.1 2.2 3.3 4.4 5.5 |
|
| 541 |
1.1 2.2 3.3 4.4 5.5 |
|
| 548 |
1.1 2.2 |
|
| 550 |
1.1 |
|
| 570 |
1.1 |
|
| 574 |
1.1 |
|
| 580 |
1.1 |
|
| 585 |
1.1 |
|
| 591 |
1.1 |
|
| 596 |
1.1 |
|
| 597 |
1.1 |
|
| 598 |
1.1 |
|
| 605 |
1.1 |
|
| 607 |
1.1 |
|
| 611 |
1.1 |
|
| 624 |
1.1 |
|
| 626 |
1.1 |
|
| 642 |
1.1 |
|
| 645 |
1.1 |
|
| 650 |
1.1 |
|
| 655 |
1.1 2.2 3.3 |
|
| 657 |
1.1 2.2 |
|
| 661 |
1.1 |
|
| 668 |
1.1 |
|
| 677 |
1.1 |
|
| 681 |
1.1 |
|
| 693 |
1.1 2.2 |
|
| 695 |
1.1 2.2 |
|
| 696 |
1.1 |
|
| 697 |
1.1 2.2 |
|
| 698 |
1.1 |
|
| 701 |
1.1 |
|
| 710 |
1.1 |
|
| 712 |
1.1 2.2 |
|
| 716 |
1.1 |
|
| 722 |
1.1 |
|
| 729 |
1.1 |
|
| 734 |
1.1 2.2 |
|
| 736 |
1.1 |
|
| 740 |
1.1 |
|
| 745 |
1.1 |
|
| 753 |
1.1 |
|
| 755 |
1.1 2.2 |
|
| 757 |
1.1 |
|
| 761 |
1.1 |
|
| 768 |
1.1 |
|
| 776 |
1.1 |
|
| 780 |
1.1 2.2 |
|
| 793 |
1.1 |
|
| 798 |
1.1 2.2 |
|
| 800 |
1.1 |
|
| 802 |
1.1 2.2 3.3 |
|
| 804 |
1.1 |
|
| 808 |
1.1 |
|
| 827 |
1.1 2.2 |
|
| 828 |
1.1 |
|
| 845 |
1.1 |
|
| 857 |
1.1 |
|
| 859 |
1.1 |
|
| 861 |
1.1 |
|
| 863 |
1.1 |
|
| 869 |
1.1 2.2 |
|
| 872 |
1.1 2.2 |
|
| 874 |
1.1 |
|
| 890 |
1.1 |
|
| 908 |
1.1 |
|
| 912 |
1.1 |
|
| 917 |
1.1 |
|
| 924 |
1.1 |
|
| 925 |
1.1 |
|
| 930 |
1.1 2.2 |
|
| 934 |
1.1 2.2 |
|
| 936 |
1.1 |
|
| 939 |
1.1 |
|
| 944 |
1.1 |
|
| 949 |
1.1 |
|
| 961 |
1.1 |
|
| 964 |
1.1 |
|
| 966 |
1.1 2.2 |
|
| 977 |
1.1 |
|
| 986 |
1.1 2.2 |
|
| 991 |
1.1 2.2 |
|
| 993 |
1.1 2.2 |
|
| 997 |
1.1 |
|
| 1001 |
1.1 |
|
| 1013 |
1.1 |