225_07_mergesort - Problemoftheday: Executethecodeonthe

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Execute the code on the  next slide starting with this  and determine what  happens on this example. Problem of the day:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2  while (result.list2.rear.next!= null )  {    result.list1.rear.next= result.list2.rear.next;    result.list1.rear= result.list2.rear.next;    result.list1.n++;    if (result.list1.rear.next != null)    {       result.list2.rear.next= result.list1.rear.next;       result.list2.rear= result.list1.rear.next;       result.list2.n++;     }  }                 result.list1.rear.next= null;        result.list2.rear.next= null;        return(result);
Background image of page 2
3   public SplitList evenOddSplit()  {    SplitList result;         boolean done;        result= new SplitList();        if (start== null) return(result);        result.list1.start= start;        result.list1.rear = start;        result.list1.n++;        if (start.next == null) return(result);        result.list2.start= start.next;        result.list2.rear = start.next;        result.list2.n++;         done= false; Corrected code
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4   while (result.list2.rear.next!= null  )  {    result.list1.rear.next= result.list2.rear.next;    result.list1.rear= result.list2.rear.next;    result.list1.n++;    if (result.list1.rear.next != null)    {       result.list2.rear.next= result.list1.rear.next;       result.list2.rear= result.list1.rear.next;       result.list2.n++;     }     else  done= true;  }                   result.list1.rear.next= null;        result.list2.rear.next= null;        return(result);
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2012 for the course CSC 225 taught by Professor Valerieking during the Spring '10 term at University of Victoria.

Page1 / 18

225_07_mergesort - Problemoftheday: Executethecodeonthe

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online