Difference between revisions of "IB Computer Science 2"

From WLCS
Line 63: Line 63:
 
* Teacher Work Day
 
* Teacher Work Day
  
== Friday (10/29/30) ==
+
== Archives ==
'''Warmup:'''
+
* [[IBCS2 - 1011 - October]]
* Draw the memory diagram after the following code executes:
+
* [[IBCS2 - 1011 - September]]
<source lang="Java">
 
Node fun = new Node(42);
 
Node general = new Node (11);
 
Node a, b, c;
 
 
a = general;
 
b = a;
 
fun.next = b;
 
c = fun;
 
</source>
 
 
 
'''Agenda:'''
 
* Node Practice
 
** [[Media:NodeFunAgain.java]]
 
* Dynamically-sized Stacks
 
** Create a new class called DynamicStack
 
*** [[Media:DynamicStack.java]]
 
** What attribute must we keep track of when we talk about stacks?
 
** Create a Node reference for the most important stack attribute
 
** Implement push(int num) using Nodes.
 
*** push() should not return anything
 
*** push() creates a new Node with the num, and set the new Node's next reference to the top
 
*** Don't forget to update the top to be the new node!
 
** Implement pop(), which should POP and return the value on top of the stack and update the top
 
** Implement top(), which should just return the value on top of the stack
 
** Implement isEmpty() which returns true if the stack is empty
 
** Implement print() which should print your entire stack
 
** TEST YOUR STACK USING MR. BUI'S STACK MAIN OR YOUR OWN MAIN METHOD
 
* Dynamically-sized Queues
 
** Create a new class called DynamicQueue
 
*** [[Media:DynamicQueue.java]]
 
** Test out your DynamicQueue using the original QueueMain file
 
 
 
== Wednesday (10/27/10) ==
 
'''Warmup:'''
 
* What does FIFO stand for?
 
* When would you want to use a queue?  Give an example
 
* Assume the following queue operations have occurred:
 
*# Add "Nick"
 
*# Add "Scarlet"
 
*# Add "Sheng"
 
*# Remove
 
*# Add "Daniel"
 
*# Remove
 
*# What is left in the queue?
 
 
 
'''Agenda:'''
 
* Object and References Review
 
** [[Media:Point.java]]
 
** [[Media:ReferencesReview.java]]
 
* Node class
 
** [[Media:Node.java]]
 
** [[Media:NodeFun.java]]
 
* Node references practice
 
* Read through [[Media:CriterionA3_prototypeSolution.doc]]
 
* Begin working on your Prototype Solution.  It will be due next Tuesday (10/27/09).
 
 
 
'''Homework:'''
 
* Dossier - Prototype Solution rough draft due Tuesday (11/3/10)
 
 
 
== Monday (10/25/10) ==
 
'''Warmup:'''
 
* Turn in your Criteria for Success
 
* Grab a Stacks Quiz, you may start immediately
 
 
 
'''Agenda:'''
 
* Stacks Quiz!
 
* Criteria for Success peer edit
 
* Queueueueueues (Queues)
 
** [[Media:Queues.ppt]]
 
** [[Media:Queue.java]]
 
** [[Media:QueueMain.java]]
 
* Fix [[Media:Queue.java]] so that it works. You must fill in all the method bodies
 
 
 
== Thursday (10/21/10) ==
 
'''Warmup:'''
 
# What does LIFO stand for?
 
# What data structure does LIFO describe?
 
# What is the one location that you worry about in the structure from #2?
 
# What are the two actions that you can do in the structure from #2?
 
# When would you want to use the structure from #2?
 
 
 
'''Agenda:'''
 
* Array Review
 
* Stack Review
 
* Queues
 
** [[Media:Queues.ppt]]
 
** [[Media:Queue.java]]
 
** [[Media:QueueMain.java]]
 
* Fix [[Media:Queue.java]] so that it works. You must fill in all the method bodies
 
 
 
'''Homework:'''
 
* Criteria for Success due Monday (10/25/10)
 
* Stacks quiz on Monday (10/25/10)
 
 
 
== Tuesday (10/19/10) ==
 
'''Agenda:'''
 
* Introduction to Mr. Fowler
 
* Field trip debrief
 
* Sorting & Searching Review
 
** Linear Search
 
** Binary Search
 
** Selection Sort
 
** Bubble Sort
 
* Missing assignments
 
** Dossier - Analysis of the Problem
 
** [[Media:LinearSearch.java]]
 
** [[Media:BinarySearch.java]]
 
* Analyzing the Problem section - peer edits
 
* Criteria for Success
 
** [[Media:CriterionA2_criteriaforSuccess.doc]] due Monday (10/25/10)
 
* Introduction to Data Structures
 
* Stacks
 
** [[Media:Stacks.ppt]]
 
** [[Media:Stack.java]]
 
** [[Media:StackMain.java]]
 
** Stacks quiz on Monday (10/25/10)
 
 
 
'''Homework:'''
 
* Criteria for Success due Monday (10/25/10)
 
* Stacks quiz on Monday (10/25/10)
 
 
 
== Friday (10/15/20) ==
 
* Field trip
 
 
 
== Wednesday (10/13/10) ==
 
'''Agenda:'''
 
* Field trip slips!
 
* Friday Field Trip - meet in Cafeteria at 8:10AM
 
* Demo [[Media:LinearSearch.java]]
 
* Demo [[Media:BinarySearch.java]]
 
* Introduction to Security
 
** Authentication - [[Media:Authentication.ppt]]
 
 
 
== Friday (10/8/10) ==
 
'''Warmup:'''
 
* Turn in Analyzing the Problem section
 
* What are the steps necessary in order to use a dictionary?
 
** Write it out in a text editor.
 
 
 
'''Agenda:'''
 
* Peer edit analyzing the problem
 
 
 
* Review of 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
 
# 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?
 
# 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
 
 
 
* [http://euler.slu.edu/~goldwasser/demos/BinarySearch/ Binary Search Demo]
 
* [http://www.cosc.canterbury.ac.nz/people/mukundan/dsal/BSearch.html Binary Search Demo2]
 
* [[Media:BinarySearch.java]]
 
* 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
 
 
 
* Use the following [[Media:IBCS2Roster.txt]]
 
* Convert [[Media:LinearSearch.java]] and [[Media:BinarySearch.java]] so that it searches for a String name
 
 
 
== Wednesday (10/6/10) ==
 
'''Warmup:'''
 
* Pickup 5 playing cards from Mr. Bui
 
* Use the BubbleSort algorithm to hand-sort the cards from least to greatest
 
 
 
'''Agenda:'''
 
* Turn in field trip slips.
 
* Demo all programs.  Interims are due today.
 
* Work on Dossier: Analyzing the Problem
 
 
 
'''Homework:'''
 
* Analyzing the Problem due Friday (10/8/08)Due Friday (10/8/08)
 
* Any missing assignments
 
 
 
== Monday (10/4/10) ==
 
'''Warmup:'''
 
* Complete any missing assignments:
 
** [[AddressBook class lab assignment]]
 
** SelectionSort
 
 
 
'''Agenda:'''
 
* SelectionSort Review
 
* Introduction to Bubble Sort
 
# Initialize the front to be the top or beginning of the array
 
# Now go to the bottom/end of the array
 
# Compare the two adjacent elements to see if they are in proper sequential order
 
## Swap the elements if they are out of order (bigger number to the left of smaller number)
 
# Move to the next pair of adjacent elements/numbers
 
# Repeat steps 3 and 4 until the smallest number has "floated" to the top/front
 
# After you traverse the entire array
 
## Move the front so that the sorted numbers are ignored
 
## Go back to the end of the array
 
## Repeat steps 2 through 6 for the unsorted part of the array
 
<!--* [http://web.engr.oregonstate.edu/~minoura/cs162/javaProgs/sort/BubbleSort.html Bubble Sort Animation]-->
 
* [http://math.hws.edu/TMCM/java/xSortLab/ Sorting Animations]
 
* [http://www.cs.pitt.edu/~kirk/cs1501/animations/Sort2.html More Sorting Animations]
 
* Download [[Media:BubbleSort.java]]
 
** Fill in the commented parts of the BubbleSort.java file. Where there is a comment, you need to write code.
 
** Demo to Mr. Bui at the end of class
 
* Introduction to the Program Dossier
 
** [[Media:CriterionA1_problemAnalysis.doc]]
 
** Analyzing the Problem due Friday (10/8/08)
 
** Work on your Analyzing the Problem section
 
 
 
'''Homework:'''
 
* Analyzing the Problem due Friday (10/8/10)
 
 
 
== Thursday (9/30/10) ==
 
'''Warmup:'''
 
* Pickup 5 playing cards from Mr. Bui
 
* Use the SelectionSort algorithm to hand-sort the cards from least to greatest
 
 
 
'''Agenda:'''
 
* Turn in field trip slips
 
* Turn in quiz corrections
 
* Demo [[AddressBook class lab assignment]]
 
* Demo ArrayPractice exercises
 
* Demo SelectionSort
 
* Add a (s)ort option to your AddressBook
 
** In order to compare Strings:
 
<source lang="Java">
 
if (str1.compareTo(str2) < 0)
 
{
 
  System.out.println(str1 + " goes before " + str2);
 
}
 
</source>
 
* So inside your AddressBook, you'd have something like this:
 
<source lang="Java">
 
if (myContacts[i].getLastName().compareTo(myContacts[j].getLastName()) < 0)
 
</source>
 
 
 
== Back To School Night (9/29/10) ==
 
* [[Media:B2snIBCS2.ppt]]
 
 
 
== Tuesday (9/28/10) ==
 
'''Warmup:'''
 
* Create a Java file with a main() called SelectionSort
 
* Create an array of 20 ints
 
* Use your own numbers in the array
 
 
 
'''Agenda:'''
 
* Introduction to Selection Sort
 
# Find the smallest element
 
# Move to the front of the array (swap with front)
 
# Repeat Steps 1&2, but ignoring the sorted front
 
* [http://www.cs.oswego.edu/~mohammad/classes/csc241/samples/sort/Sort2-E.html Selection Sort Animation]
 
* [http://www.cs.ust.hk/faculty/tcpong/cs102/summer96/aids/select.html Another Selection Sort Animation]
 
* [http://math.hws.edu/TMCM/java/xSortLab/ Sorting Animations]
 
* Download [[Media:SelectionSort.java]]
 
** Fill in the commented parts of the SelectionSort.java file. Where there is a comment, you need to write code.
 
 
 
== Friday (9/24/10) ==
 
'''Warmup:'''
 
* You will be creating a user interface menu for use with your AddressBook
 
* Open / create your AddressBook's main method
 
* Inside the main method, create an AddressBook variable:
 
 
 
<source lang="java">
 
AddressBook book = new AddressBook();
 
</source>
 
 
 
* 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:
 
 
 
<pre>
 
(a)dd to address book
 
(f)ind a Contact
 
(p)rint address book
 
(q)uit
 
 
 
What would you like to do?
 
</pre>
 
 
 
* You should prompt for input after the menu is printed.  Review [[Media:JavaIOExample.java]] for examples of input/output
 
*# Add '''import java.io.*;''' at the very top
 
*# Add '''private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) );''' before main()
 
*# Add '''throws IOException''' so that main() reads like '''public static void main(String [] args) throws IOException'''
 
*# You may now use '''stdin.readLine();''' to read in a String
 
*# To compare Strings, use .equals() like so: '''myStr.equals("a")'''
 
* If the user inputs 'a', then print a message that says "USER SELECTED ADD"
 
* If the user inputs 'f', then print a message that says "USER SELECTED FIND"
 
* 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:'''
 
* Complete [[AddressBook class lab assignment]]
 
* Create the '''Contact remove(String fn, String ln)''' method for the AddressBook
 
*# Using a for loop, find the Contact that matches fn and ln, and save it in a variable
 
*# Once you have found the Contact, you should remember its index (location) in the array
 
*# Check if the Contact was found in the array
 
*## If it was found, you must use a loop to shift all the array elements down one index
 
*## HINT: myContacts[i] = myContacts[i+1] //where i is a loop counter
 
*# Be sure to set the last element to null (so that there isn't a duplicate Contact in the end)
 
*#* HINT: myContacts[size-1] = null;
 
*# Decrement size
 
*# Return the removed Contact
 
* Demo all assignments
 
 
 
'''Homework:'''
 
* Install the [http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html Java JDK] on your computer (be sure to choose your corresponding operator system)
 
* Install [http://www.eclipse.org/downloads/packages/eclipse-classic-360/heliosr Eclipse Classic] on your computer (be sure to choose your corresponding operator system on the right)
 
* Test it out, and let Mr. Bui know if you run into problems
 
 
 
== Wednesday (9/22/10) ==
 
'''Warmup:'''
 
* Begin working on the [[AddressBook class lab assignment]]
 
 
 
'''Agenda:'''
 
* Demo ArrayPractices and any other assignments
 
* [[AddressBook class lab assignment]]
 
 
 
== Monday (9/20/10) ==
 
'''Agenda:'''
 
* Demo [[Person class lab assignment]]
 
* Demo [[Car class lab assignment]]
 
* Demo [[Contact class lab assignment]]
 
* Review Arrays
 
** [[Media:IntroArrays.ppt]]
 
* Array practice activities
 
*# Create a new Java class named ArrayPractice1.  Create an array of 10 Strings (Use names of students in the room).  Using a for loop, print out all the Strings in the array.
 
*# Create a new Java class named ArrayPractice2.  Create an array of 10 integers (make a bunch of numbers up).  Using a for loop and an if statement, print print out only numbers greater than 10.
 
*# Create a new Java class named ArrayPractice3.  Create an array of 10 integers.  Using a for loop, calculate the sum and average.
 
* [[AddressBook class lab assignment]]
 
 
 
'''Homework:'''
 
* Install the [http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html Java JDK] on your computer (be sure to choose your corresponding operator system)
 
* Install [http://www.eclipse.org/downloads/packages/eclipse-classic-360/heliosr Eclipse Classic] on your computer (be sure to choose your corresponding operator system on the right)
 
* Test it out, and let Mr. Bui know if you run into problems
 
 
 
== Thursday (9/16/10) ==
 
'''Warmup:'''
 
* Be sure you have completed the [[Person class lab assignment]]
 
* If you have *not* completed it, then finish it for your warmup
 
* If you have already completed, then try the following warmup:
 
*# Review [[Media:JavaIOExample.java]]
 
*# In your Warmups project in Eclipse, create a new Java class named Warmup_9_16_10
 
*# Prompt the user for an int
 
*# Using an if statement, print out whether or not the user's number is positive or negative
 
 
 
'''Agenda:'''
 
* toString() methods
 
* Demo [[Person class lab assignment]]
 
* Demo [[Car class lab assignment]]
 
* Demo [[Contact class lab assignment]]
 
 
 
== Tuesday (9/14/10) ==
 
'''Warmup:'''
 
* Open Eclipse
 
* Create a new project named Warmups
 
* Create a new Java filed name Warmup9_14_10 (be sure to include the public static void main())
 
* Write a for loop that prints out all the even numbers from 100 DOWN to 0
 
 
 
'''Agenda:'''
 
* Create a new project named ClassesReview
 
* Create a new Java class named Circle
 
* Complete the Circle class with the following methods (You may use the auto-generating setter/getter feature!):
 
** Circle()
 
** getRadius()
 
** setRadius()
 
** getDiameter()
 
** getArea()
 
* Download [[Media:CircleMain.java]] to the src folder in your ClassesReview project (OR download and then import it through Eclipse)
 
* [[Person class lab assignment]]
 
* [[Car class lab assignment]]
 
* [[Contact class lab assignment]]
 
 
 
'''Homework:'''
 
* Install the [http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html Java JDK] on your computer (be sure to choose your corresponding operator system)
 
* Install [http://www.eclipse.org/downloads/packages/eclipse-classic-360/heliosr Eclipse Classic] on your computer (be sure to choose your corresponding operator system on the right)
 
* Test it out, and let Mr. Bui know if you run into problems
 
 
 
== Friday (9/10/10) ==
 
'''Warmup:'''
 
* Cram for Software Development Quiz
 
 
 
'''Agenda:'''
 
* Turn in any signed syllabi sheets
 
* Software Development Quiz
 
* Introduction to Eclipse/BlueJ/JEdit?
 
* Java Review...uh oh!
 
** semicolons!
 
** public static void main( String [] args );
 
** Hello, world! - printing / outputting to screen
 
** Prompting for input
 
** if statements
 
** while loops
 
** for loops
 
** classes, attributes, setters, & getters!
 
 
 
'''Homework:'''
 
* Install the [http://www.oracle.com/technetwork/java/javase/downloads/jdk6-jsp-136632.html Java JDK] on your computer (be sure to choose your corresponding operator system)
 
* Install [http://www.eclipse.org/downloads/packages/eclipse-classic-360/heliosr Eclipse Classic] on your computer (be sure to choose your corresponding operator system on the right)
 
* Test it out, and let Mr. Bui know if you run into problems
 
 
 
== Wednesday (9/8/09) ==
 
'''Warmup:'''
 
* List as many different places and/or ways to obtain information during the problem analysis phase of any project
 
 
 
'''Agenda:'''
 
* Turn in [[IBCS2 Summer Assignment]]
 
* Name cards
 
* Complete the [http://spreadsheets.google.com/viewform?key=p6_k1SMbS2zvMHJNJBBkFPA student survey]
 
* Introduction to Software Development
 
** [[Media:SoftwareDevelopment.ppt]]
 
* Software Development Quiz on Friday (9/10/10)
 
 
 
== Tuesday (9/7/09) ==
 
* Introductions
 
* Turn in [[IBCS2 Summer Assignment]]
 
* [[IB Computer Science II Syllabus]]
 
* Lab setup/config
 
** Login username is your first initial and lastname (e.g. pbui)
 
** Your password is your student ID number
 
** Go to System -> Preferences -> About Me -> Change Password
 
 
 
== Summer ==
 
* [[IBCS2 Summer Assignment]]
 

Revision as of 23:28, 15 November 2010

Friday (11/12/10)

Agenda:

  • Demo your completed LinkedList
  • Contact class review
  • Create a new class from your Node class and called ContactNode
  • Create a new class called ContactLinkedList
  • Convert your LinkedList to use ContactNode and call it ContactLinkedList
  • Be sure to test your ContactLinkedList
  • AddressBook class review
  • Convert your AddressBook to use ContactLinkedList instead of Contact[] array
    • Be sure to test your AddressBook with LOTS of contacts
    • HINT: Use a loop to auto-create 100s of Contacts and auto-add them

Friday - Tuesday (11/5/10 - 11/9/10)

Agenda:

  • Demo Media:DynamicStack.java
  • Demo Media:DynamicQueue.java
  • Introduction to Linked Lists
    • Media:LinkedList.java
    • Attributes: head, tail, size
    • Constructors: default
    • Methods:
      • boolean isEmpty() - returns true if the LinkedList is empty, and false otherwise
      • void append(int num) - adds a new Node with num at the end of the LinkedList
      • void add(int num, int index) - adds a new Node with num at the index specified
        • There are FIVE different scenarios when you add a Node
        • DRAW the before-and-after pictures for all FIVE secenarios
      • int remove(int index) - removes the index-th Node and returns its data
        • There are SIX different scenarios when you remove a Node
      • int getNum(int index) - returns the num found at the index (HINT: you'll need to traverse the LinkedList)
      • int search(int num) - returns the index of the Node with num (returns -1 if num not in list)
      • void print() - traverses the LinkedList and prints out each Node's data
  • Test your LinkedList using Media:LinkedListTestMain.java

Wednesday (11/3/10)

Warmup:

  • Draw the memory diagram after the following code executes:
Node head = new Node(14);
Node tail = head;
tail.next = new Node(15);
tail = tail.next;
head.next.next = new Node(926);
tail = tail.next;
tail.next = new Node(3);
tail = tail.next;

Agenda:

  • Turn in your Prototype Solutions
  • Return all papers
  • Demo your Media:DynamicStack.java
  • Review Dynamic Queue
    • Memory diagrams for each method
    • Begin/Starting scenarios for each method
    • Draw the before-and-after pictures for adding a Node to an empty Queue (be sure to use head and tail!)
    • Draw the before and after pictures for adding a Node to a non-empty Queue
    • Draw the before-and-after pictures for removing a Node from an empty Queue
    • Draw the before and after pictures for removing a Node from a non-empty Queue
  • Complete and demo Media:DynamicQueue.java

Tuesday (11/2/10)

  • Teacher Work Day

Archives