Difference between revisions of "IB Computer Science II"

From WLCS
Line 4: Line 4:
  
 
== Thursday (9/25/08) ==
 
== Thursday (9/25/08) ==
# Download [[Media:LinearSearch.java]]
+
* Introduction to Linear Search
# Fill in the commented parts of LinearSearch.java and demo a working linear search to Mr. Bui
+
* Download [[Media:LinearSearch.java]]
# Linear Search performance evaluation
+
* Fill in the commented parts of LinearSearch.java and demo a working linear search to Mr. Bui
* What is the best case scenario? i.e. What is the minimum # of comparisons?
+
* Linear Search performance evaluation
* What is the worst case scenario? i.e. What is the maximum # of comparisons?
+
# What is the best case scenario? i.e. What is the minimum # of comparisons?
* What is the average # of comparisons?
+
# What is the worst case scenario? i.e. What is the maximum # of comparisons?
 +
# What is the average # of comparisons?
 +
# Can we do better than a linear search?
  
 +
* Introduction to Binary Search
 +
# Assume sorted list
 +
# Go to the middle point
 +
# If the middle element matches the key, then the search is over
 +
# If the key is less than middle element, go to the left (down), else go to the right (up)
 +
# Repeat steps 2-4 until the key is found or when the left and right bounds pass each other
 +
 +
* Binary Search Demo
 +
* Binary Search Demo2
 +
* BinarySearch Example Code
 +
* Binary Search performance evaluation
 +
# What is the best case scenario? i.e. What is the minimum # of comparisons?
 +
# What is the worst case scenario? i.e. What is the maximum # of comparisons?
 +
# What is the average # of comparisons?
 +
* Binary Search Advantages & Disadvantages
 +
*
 +
* Sorting & Searching Review
 +
** Selection Sort
 +
** Bubble Sort
 +
** Linear Search
 +
*** Binary Search
  
 
== Wednesday (9/24/08) ==
 
== Wednesday (9/24/08) ==

Revision as of 10:04, 25 September 2008

Welcome to the IB Computer Science II Homepage!

You may find the old IBCS2 website here: IBCS2_0708

Thursday (9/25/08)

  • Introduction to Linear Search
  • Download Media:LinearSearch.java
  • Fill in the commented parts of LinearSearch.java and demo a working linear search to Mr. Bui
  • Linear Search performance evaluation
  1. What is the best case scenario? i.e. What is the minimum # of comparisons?
  2. What is the worst case scenario? i.e. What is the maximum # of comparisons?
  3. What is the average # of comparisons?
  4. Can we do better than a linear search?
  • Introduction to Binary Search
  1. Assume sorted list
  2. Go to the middle point
  3. If the middle element matches the key, then the search is over
  4. If the key is less than middle element, go to the left (down), else go to the right (up)
  5. Repeat steps 2-4 until the key is found or when the left and right bounds pass each other
  • Binary Search Demo
  • Binary Search Demo2
  • BinarySearch Example Code
  • Binary Search performance evaluation
  1. What is the best case scenario? i.e. What is the minimum # of comparisons?
  2. What is the worst case scenario? i.e. What is the maximum # of comparisons?
  3. What is the average # of comparisons?
  • Binary Search Advantages & Disadvantages
  • Sorting & Searching Review
    • Selection Sort
    • Bubble Sort
    • Linear Search
      • Binary Search

Wednesday (9/24/08)

  • Demo missing assignments
  • Dossier
    • Past examples
    • Work on your Analysis of the Problem section

Back to School Night

Monday - Tuesday (9/22/08 - 9/23/08)

Warmup:

  • Assume you have the following integers: 5, 2, 3, 8, 4
  • What are the steps to selection sort the integers? Show the movement of the integers.
  • What are the steps to bubble sort the integers? Show the movement of the integers.

Agenda:

  • Demo SelectionSort.java to Mr. Bui
  • Introduction to Bubble Sort
  1. Initialize the front to be the top or beginning of the array
  2. Now go to the bottom/end of the array
  3. Compare the two adjacent elements to see if they are in proper sequential order
    1. Swap the elements if they are out of order (bigger number to the left of smaller number)
  4. Move to the next pair of adjacent elements/numbers
  5. Repeat steps 3 and 4 until the smallest number has "floated" to the top/front
  6. After you traverse the entire array
    1. Move the front so that the sorted numbers are ignored
    2. Go back to the end of the array
    3. Repeat steps 2 through 6 for the unsorted part of the array

Assignment:

  • Verify that you have Java and JCreator installed on your home computer.

Friday (9/19/08)

  • Introduction to Selection Sort
  1. Find the smallest element
  2. Move to the front of the array (swap with front)
  3. Repeat Steps 1&2, but ignoring the sorted front

Wednesday - Thursday (9/17/08 - 9/18/08)

Agenda:

  • AddressBook class lab assignment is due at the end of the day tomorrow.
  • Your AddressBook demo should use the menu system you created in the warmup yesterday
    • When the user selects to ADD a Contact, you should prompt them for a first name, last name, phone, and address.
    • You should then create a new Contact
    • Add the Contact to your AddressBook using the AddressBook's add() method
  • The PRINT menu choice should print the entire AddressBook using the print() method
  • Make sure your menu runs again after the user makes a choice (HINT: use a loop somewhere)

Tuesday (9/16/08)

Warmup:

  • You will be creating a user interface menu for use with your AddressBook
  • Open / create your AddressBook's main method
  • Print out a message that explains the program (e.g. "Welcome to YOUR_NAME's address book!")
  • Print out a menu with the following options:
(a)dd to address book
(p)rint address book
(q)uit

What would you like to do? 
  • You should prompt for input after the menu is printed. Review Media:JavaIOExample.java for examples of input/output
  • If the user inputs 'a', then print a message that says "USER SELECTED ADD"
  • If the user inputs 'p', then print a message that says "USER SELECTED PRINT"
  • If the user inputs 'q', then print a message that says "USER SELECTED QUIT"

Agenda:

  • Demo JCreator
  • Add a String address attribute to your Contact class
  • Demo your Person, Car, and Contact classes to Mr. Bui (LATE)
  • AddressBook class lab assignment

Monday (9/15/08)

Wednesday - Friday (9/10/08 - 9/12/08)

  • Receive textbooks
    • Write your name on the inside cover
    • Tell Mr. Bui your number
  • Demo to Mr. Bui your Person, Car, and Contact classes
  • Complete Lab 14 in eimacs
  • Complete Test 12 in eimacs

Monday - Tuesday (9/8/08 - 9/9/08)

Agenda

Friday (9/5/08)

Warmup Determine whether or not each of the following lines result in x evaluating true or false:

1 boolean x;
2 x = 50 > 20;
3 x = !x;
4 x = true && false;
5 x = false || false;
6 x = false || false || false || false || false || true;
7 x = true && true && true && false;
8 x = x || !x;
9 x = x && !x;

Agenda

Assignment

Tuesday - Thursday (9/2/08 - 9/4/08)

  1. Write a Hello, world! program ( Hint: Java program template )
    1. Create a new Java program using JEdit or whatever editor you prefer
    2. Use the Java program template as a guide
    3. Insert your code
    4. Compile and execute your code
      1. Open terminal
      2. Navigate to your Java file
      3. javac FILENAME
      4. Execute your code: java PROGRAM_NAME
  2. Write a program that prints Hello, world 20 times
  3. Write a program that prints Hello, world infinite times