tutorial09

tutorial09 - CSC2520 CSC2520 DataStructures Tutorial09...

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

View Full Document Right Arrow Icon
CSC 2520 CSC 2520 Data Structures Data Structures Tutorial 09 Tutorial 09 Assignment 3 Assignment 3 20 th  March 2007
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 Assignment 3 Assignment 3 Due: 2 April 2007, 5:00 pm Submission method Written part (Q1 to Q4) Assignment box on 10/F. Programming part (Q5 to Q7) WebCT http://www.cuhk.edu.hk/wbt/webctce/ Bonus coupons: Please attach to the written  part.
Background image of page 2
3 Assignment 3 Assignment 3 Written Exercises 1. Quicksort Algorithm You should clearly state the position of the  pivot  in  each steps. Show clearly each step in the processing  of sorting. (Lecture 11) Refer to tutorial05.ppt in Page 13 & Page 14.
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 Assignment 3 Assignment 3 Written Exercises Complexity and Big-O ( O(??) ) Try to decide how many times the two loops will be  executed. (Lecture 10) 4. AVL Tree (Balanced Binary Search Tree) Show clearly what the tree should look like after each  node is inserted, perform rotation if necessary. Please  also indicate what kind of rotation is used.   Refer to the exercise 4 in tutorial08.ppt 
Background image of page 4
5 Assignment 3 Assignment 3 Written Exercises For the written exercieses of this assignment  Please submit to assignment box in 10/F Please attach the Bonus coupons to the written part.
Background image of page 5

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

View Full DocumentRight Arrow Icon
6 Assignment 3 Assignment 3 Programming Exercises Q5. Write a function  mergesortList  that receives a  List ADT   argument, sorts the list into  ascending order , and returns  the sorted list as a List ADT value. The function prototype is  as follows: static List mergesortList(List list1);
Background image of page 6
7 Assignment 3 Assignment 3 Programming Exercises Example:   public static void main(String[] args) { List list1, list2; list1 = new Cons(9,ListCons(3,ListCons(8,EmptyList()))); list2 = mergesortList(list1); /* list1 = [9,3,8] ; list2 = [3,8,9] */ }
Background image of page 7

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

View Full DocumentRight Arrow Icon
8 Assignment 3 Assignment 3 Programming Exercises Note: MUST use the mergesort algorithm The implementation in the lecture notes is for array, not for  list However, the similar procedures can be used: three parts –  divide, merge and mergesortList.
Background image of page 8
9 Assignment 3 Assignment 3 MergeSort for array void mergeSort(int[] array) {      if (array.length<=1) return;  /* Because array is already sorted! */      int n1 = array.length/2;      int n2 = array.length - n1;      int[] a1 = new int[n1]; System.arraycopy(array, 0, a1, 0, n1);      int[] a2 = new int[n2]; System.arraycopy(array, n1, a2, 0, n2);           mergeSort(a1); mergeSort(a2);     merge(array, a1, a2); 
Background image of page 9

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

View Full DocumentRight Arrow Icon
Image of page 10
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 23

tutorial09 - CSC2520 CSC2520 DataStructures Tutorial09...

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

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