Difference between revisions of "IB Computer Science 2"

From WLCS
Line 1: Line 1:
 +
== Monday (11/7/16) ==
 +
'''Agenda:'''
 +
* Node Quiz
 +
** Closed-note, closed-book
 +
** Use a pencil!
 +
* If you wish to turn in any missing work, then you must e-mail me your code for review
 +
* Work on Dynamically-sized Stacks
 +
** [https://www.cs.usfca.edu/~galles/visualization/StackLL.html Dynamic Stack Visualization]
 +
** Stack scenarios and Before-&-After pictures
 +
**# Load the [https://www.cs.usfca.edu/~galles/visualization/StackLL.html Dynamic Stack Visualization]. Considering the following questions and use the visualization tool to help you answer them.
 +
**# What does an empty stack look like? (The top reference variable is null)
 +
**# For each of the following actions, assess what the picture looks like Before? then After?
 +
**## push(4)
 +
**## push(2)
 +
**## pop()
 +
**## pop()
 +
** Create a new class called DynamicStack
 +
** What attribute must we keep track of when we talk about stacks? (Hint: rhymes with "mop")
 +
** Create a Node reference for the most important stack attribute
 +
** Implement '''void push(data)''' using Nodes.
 +
*** push() should not return anything
 +
*** push() creates a new Node with the data parameter, and set the new Node's next reference to the top
 +
*** Don't forget to update the top to be the new node!
 +
** Implement '''int pop()''' using Nodes
 +
*** pop() removes the value on top of the stack, return it
 +
*** pop() should also update the top
 +
*** pop() returns '''null''' if the stack is empty
 +
** Implement '''isEmpty()''' which returns true if the stack is empty, and false otherwise
 +
** Implement '''print()''' which should print your entire stack from top down (to null)
 +
** TEST YOUR STACK
 +
*** Be sure to push A LOT of data to test the dynamic size
 +
*** Also test popping A LOT of data to make sure it works too
 +
 
== Thursday (11/3/16) ==
 
== Thursday (11/3/16) ==
 
'''Agenda:'''
 
'''Agenda:'''

Revision as of 20:55, 6 November 2016

Monday (11/7/16)

Agenda:

  • Node Quiz
    • Closed-note, closed-book
    • Use a pencil!
  • If you wish to turn in any missing work, then you must e-mail me your code for review
  • Work on Dynamically-sized Stacks
    • Dynamic Stack Visualization
    • Stack scenarios and Before-&-After pictures
      1. Load the Dynamic Stack Visualization. Considering the following questions and use the visualization tool to help you answer them.
      2. What does an empty stack look like? (The top reference variable is null)
      3. For each of the following actions, assess what the picture looks like Before? then After?
        1. push(4)
        2. push(2)
        3. pop()
        4. pop()
    • Create a new class called DynamicStack
    • What attribute must we keep track of when we talk about stacks? (Hint: rhymes with "mop")
    • Create a Node reference for the most important stack attribute
    • Implement void push(data) using Nodes.
      • push() should not return anything
      • push() creates a new Node with the data parameter, and set the new Node's next reference to the top
      • Don't forget to update the top to be the new node!
    • Implement int pop() using Nodes
      • pop() removes the value on top of the stack, return it
      • pop() should also update the top
      • pop() returns null if the stack is empty
    • Implement isEmpty() which returns true if the stack is empty, and false otherwise
    • Implement print() which should print your entire stack from top down (to null)
    • TEST YOUR STACK
      • Be sure to push A LOT of data to test the dynamic size
      • Also test popping A LOT of data to make sure it works too

Thursday (11/3/16)

Agenda:

Tuesday (11/1/16)

Agenda:

Wednesday - Friday (10/26/16 - 10/28/16)

Agenda:

Thursday - Monday (10/20/16 - 10/24/16)

Agenda:

  • Demo Person, Car, Vector classes
  • Introduction to Stacks - Media:Stacks.ppt
    • Be able to describe the characteristics of a stack
    • Be able to explain the operations of a stack
    • Be able to describe different stack applications
    • If given a list or an array, be able to explain their use as stacks
  • Data Structure Visualizations
  • Practice Stack Exercises
    1. Push the following words onto a stack: "Washington-Lee", "Generals", "Computer", "Science". What will the words be in the order of popping them all.
    2. Imagine that you are stuck in a dungeon. You are using a stack to keep track of your movements so that you can find your way back to the beginning of the dungeon. Diagram the stack after the following moves: forward, left, left, right, forward, forward, right, forward, left. Using your stack, what would the order of moves be to return back to your starting position?
    3. Assume you are given a list of numbers that you can only access one at a time in their order. Describe how you would use stacks to reverse their order
  • Static-sized Stack class walk-through
    • Implement a Stack using a static data structure (e.g. array)
    • Test out our implementation to find weaknesses
    • Fix the weaknesses in our implementation
  • Queues - Media:Queues.ppt
  • Work on Java - Static Queue Assignment

Wednesday (10/19/16)

  • PSATs

Monday (10/17/16)

Agenda:

  • Mr. Bui has jury duty
  • Use class time to work on any missing assignments (e.g. MatrixMult, Person, Car, Vector, etc.)
  • If you have no missing assignments, then you should work on your Internal Assessment

Thursday (10/13/16)

Agenda:

Homework:

Thursday - Tuesday (10/6/16 - 10/11/16)

Agenda:

  • Demo your matrix functions
  • Java Objects
  • Point Class assignment walk-through
    1. You will create two java files: Point.java and PointMain.java
      • Point.java - the Point class definition will be here
      • PointMain.java - only the main() method will be located here
    2. Declare and initialize the following private attributes in the Point class
      • double x = 0.0
      • double y = 0.0
    3. Define two Point() constructors:
      • default constructor: Point()
      • specific constructor Point(double newX, double newY)
    4. Define the following public methods in the Point class
      • double getX() - returns the x-coordinate
      • double getY() - returns the y-coordinate
      • void setX(double newX) - sets the x-coordinate to the new x-coordinate parameter
      • void setY(double newY) - sets the y-coordinate to the new y-coordinate parameter
      • String toString() - returns a String representation of the Point object
    5. Go to your PointMain.java file to test out your Point class
    6. In the main method, create several new instances of Point objects
    7. Print out each of your Point objects
    8. Define a static method in PointMain.java named double slope(Point p1, Point p2) - returns the slope between p1 and p2
    9. Test and print out your slope method when you use it with your instantiated Point objects in the main() method
  • Complete and demo the following:

Tuesday (10/4/16)

Agenda:

  • Two-Dimensional Array Assignment
    1. Write a method (function): matrixAdd(m1, m2) that returns a new matrix that is the sum of m1 and m2
      • Be sure to check if the two matrices are the same size (if not, then return null)
    2. Write a method (function): matrixMult(m1, m2) that returns the product of matrix m1 and m2
      • Be sure to check the rules of matrix multiplication
      • Return a null matrix if their sizes do not allow for proper multiplication

Archives