Docsity

Closed Laboratories 5-7 - Programming and Problem Solving II | CSE 1302, Lab Reports of Computer Science

Toggle sidebar
bg1
CSE 1302 Closed Labs 5-7
Lab#5 – Week of February 23, 2009
Objective – to study polymorphism
Polymorphic Sorting– Chapter 9, pages 182-185
Complete all steps, except 7
Turn in Numbers.java and Strings.java and the outputs from each, using ascending
sequence.
Turn in SalesPerson.java and output from step 6. The instructions are a little confusing
but I want the output to be in descending order on total sales and ascending order for the
names within the same total sales bracket. That means:
…. 4935
Black, Jane 3000
Jones, James 3000
Jones, Jane 3000
Smith, Walt 3000
…. 2850
Lab#6 – Week of March 2, 2009
Objective – To test search and sort algorithms
Timing Searching and Sorting Algorithms – Chapter 9, pages191-195
Turn in IntegerList and IntegerListTest, table filled in, and answer to question
(extra credit).
1. Notice that the last column of sort table should read Insertion Sort
(sorted array)
2. Add another 2 columns to table to test the enhanced bubble sort on unsorted
and sorted data.
3. Change the insertion logic to sort in descending order and use it in
sortDescending method
4. The selection sort is missing two methods (swap and minIndex) – add them
or copy the code for a selection sort using one method from last week’s lab or from my
class website (Announcements). Use this selection sort code in the sortAscending
method.
5. Make sure the selection sort and bubble sort are increasing order and the
insertion sort is decreasing order by creating small arrays, sorting them, and then printing
them.
6. Sort an array filled with random numbers with the selection sort for the first
timing and then sort it again with the selection sort for the second timing.
7. Sort an array filled with random numbers with the insertion sort for the third
timing and then sort it again with the insertion sort for the fourth timing.
8. Sort an array filled with random numbers with the enhanced bubble sort for the
fifth timing and then sort it again with the enhanced bubble sort for the sixth timing.
9. Remember that the data in an array must be in ascending sequence to search it
with the binary search method. Fill the arrays with sorted data before calling the binary
pf2

Partial preview of the text

Download Closed Laboratories 5-7 - Programming and Problem Solving II | CSE 1302 and more Lab Reports Computer Science in PDF only on Docsity!

CSE 1302 Closed Labs 5- Lab#5 – Week of February 23, 2009 Objective – to study polymorphism Polymorphic Sorting– Chapter 9, pages 182- Complete all steps, except 7 Turn in Numbers.java and Strings.java and the outputs from each, using ascending sequence. Turn in SalesPerson.java and output from step 6. The instructions are a little confusing but I want the output to be in descending order on total sales and ascending order for the names within the same total sales bracket. That means: …. 4935 Black, Jane 3000 Jones, James 3000 Jones, Jane 3000 Smith, Walt 3000 …. 2850 Lab#6 – Week of March 2, 2009 Objective – To test search and sort algorithms Timing Searching and Sorting Algorithms – Chapter 9, pages191- Turn in IntegerList and IntegerListTest, table filled in, and answer to question (extra credit).

  1. Notice that the last column of sort table should read Insertion Sort (sorted array)
  2. Add another 2 columns to table to test the enhanced bubble sort on unsorted and sorted data.
  3. Change the insertion logic to sort in descending order and use it in sortDescending method
  4. The selection sort is missing two methods (swap and minIndex) – add them or copy the code for a selection sort using one method from last week’s lab or from my class website (Announcements). Use this selection sort code in the sortAscending method.
  5. Make sure the selection sort and bubble sort are increasing order and the insertion sort is decreasing order by creating small arrays, sorting them, and then printing them.
  6. Sort an array filled with random numbers with the selection sort for the first timing and then sort it again with the selection sort for the second timing.
  7. Sort an array filled with random numbers with the insertion sort for the third timing and then sort it again with the insertion sort for the fourth timing.
  8. Sort an array filled with random numbers with the enhanced bubble sort for the fifth timing and then sort it again with the enhanced bubble sort for the sixth timing.
  9. Remember that the data in an array must be in ascending sequence to search it with the binary search method. Fill the arrays with sorted data before calling the binary

search method. Since it doesn’t matter if you fill the arrays to be used with the sequential search with sorted or unsorted data, you might as well fill the search array with sorted data once, then sequentially search it and then binary search it.

  1. Extra Credit: if you choose to do the discussion question, it should be thorough – write a short paragraph on sorting and another on searching. Explain why the times changed (or didn’t change) for the different methods and how the algorithms were affected by the larger array sizes. Lab#7 – Week of March 16, 2009 Objectives – To learn to ignore, trap and write your own exceptions Exceptions Aren’t Always Errors – Chapter 10, page 205 Use the phrase “I won the lottery for 2 million!!!” Placing Exception Handlers – Chapter 10, page 206 Use the 3 phrases: 10 20 30 40 50 1 fish, 2 fish We have 3 dogs and 2 cats. Throwing Exceptions – Chapter 10, page 208 Run the program with: a negative number a value between 0- a value > 16 For each lab, turn in the source and output. Staple all three labs together in the order given. We will be trying some Pair Programming techniques in lab today. See flyer handed out in class on Monday, March 16th. Team assignments will be on the board when you get to lab. Both members of a team should read the assignment and discuss an approach together for several minutes. Then the Driver will type as the Navigator directs. Both members can continually make suggestions for corrections and/or changes to the code. Change positions for each new mini lab on exceptions – Driver becomes Navigator and Navigator becomes Driver. Email me any pros or cons you experience with this lab arrangement before the end of this week.