COMPUTER 2430 Object Oriented Programming and Data Structures I
Expected Learning Outcomes Develop software using elementary data structures. Design, implement, and test programs using classes, inheritance, and polymorphism. Compare and contrast algorithm efficiency at a very basic level. Write module tests, system tests, and develop test specifications. Perform simple object-oriented analysis and design. Work in a small team (two or three people) on the analysis, design, implementation, and testing of a project.
Quiz 5 What is the Big O for each of the following: Deleting from a regular array and keep the order O(N) for (int i = index; i < count – 1; i ++) items[i] = items[i + 1]; count --;
Quiz 5 What is the Big O for each of the following: 2. The Queue method remove of circular array implementation O(1) Object obj = items[front]; front = (front + 1) % items.length; return obj;
Quiz 5 What is the Big O for each of the following: 3. Finding the sum of a list of numbers O(N) int sum = 0; for (int i = 0; i < count; i ++) sum += items[i];
Quiz 5 What is the Big O for each of the following: 3. Finding the sum of a list of Additive instances O(N) Additive sum = new Additive(); for (int i = 0; i < count; i ++) sum = sum.plus(items[i]);
Quiz 5 What is the Big O for each of the following: 4. Insertion Sort, average case O(N2) for i = 1 to (size - 1) j = i while j > 0 and a[j] < a[j - 1] Swap a[j], a[j - 1] j --
Quiz 5 for I = (N + 4) downto 2 for J = (I - 2) to (N + 5) if --- The total number of times “if” is executed is: ___________________
Two Formulas How Many last – first + 1 What is the sum? (first + last) * (number of items) / 2
How Many? last – first + 1 first – last + 1 1 + 2 + 3 + . . . + 10 20 + 19 + 18 + . . . + 5 + 4 + 3 3 + 4 + 5 + . . . + 18 + 19 + 20
What is the Sum? s = 20 + 19 + . . . + 4 + 3 s = 3 + 4 + . . . + 19 + 20 2*s = (20 + 3) + (19 + 4) + . . . + (4+19) + (3 +20) = (first + last) * (number of items) s = (first + last) * (first – last + 1) / 2
Quiz 5 Pass I First of J Last of J # of Comparisons N+4 N+3 N+2 . 4 3 for I = (N + 4) downto 2 for J = (I - 2) to (N + 5) if --- The total number of times “if” is executed is: ___________________ Pass I First of J Last of J # of Comparisons N+4 N+3 N+2 . 4 3 2 N+2 N+1 N . 2 1 N+5 . 4 5 6 . N+4 N+5 N+6
Quiz 5 for I = (N + 4) downto 2 for J = (I - 2) to (N + 5) if --- The total number of times “if” is executed is: ___________________ 4 + 5 + 6 + . . . + (N+4) + (N+5) + (N+6) = (4 + (N+6)) * ((N+6) – 4 + 1) / 2 = (N+10) * (N+3) / 2 = (N2 + 13N + 30) / 2
Quiz 5: Sorting a. Bubble Sort, 3rd iteration (I = 0, 1, 2) I = 0 7 1 6 5 2 8 3 4 1 7 2 6 5 3 8 4 1 2 7 3 6 5 4 8 1 2 3 7 4 6 5 8
Quiz 5: Sorting b. Insertion Sort, 3rd iteration (I = 1, 2, 3) I = 1 7 1 6 5 2 8 3 4 1 7 6 5 2 8 3 4 1 6 7 5 2 8 3 4 1 5 6 7 2 8 3 4
Quiz 5: Sorting c. Selection Sort, 3rd iteration (I = 0, 1, 2) I = 0 7 1 6 5 2 8 3 4 1 7 6 5 2 8 3 4 1 2 6 5 7 8 3 4 1 2 3 5 7 8 6 4
Binary Search Code Tracing Array of integers Array of Date Array of Comparable Tracing In array Not in array Format
Quiz 6 Wednesday Binary search Hashing Counting
Expected Learning Outcomes Develop software using elementary data structures. Design, implement, and test programs using classes, inheritance, and polymorphism. Compare and contrast algorithm efficiency at a very basic level. Write module tests, system tests, and develop test specifications. Perform simple object-oriented analysis and design. Work in a small team (two or three people) on the analysis, design, implementation, and testing of a project.
Prog 6 Must use PFigure as is It’s different from Pfig of Lab12 Minimum of three sub-classes from Pfigure One drawing and one picture Must make and use a PFigureList Containing instances from at least two sub-classes Polymorphism! Move cannot just left-right, up-down, or bounce
SE Tool Time plan Time Log Monday, Dec 3, by 11 pm Punch in/out when working on Prog 6
Prog 6 Group folders
Counting Exercise