Birthday: Month: _ Day: _
Question #1
a) What is the output of the following code? Write your answer in the box.
When you create
the new array the
values are set to 0
int[] myArray = cfw_1, 2, 3, 4, 5;
System.out.println(myArray[4]);
myArray = new int[4];
Trees:
2-3 Trees (BST)
Every node has 2 or 3 children; each
node stores 1 or 2 entries. Each
internal node has one more child than
entries. Perfectly balanced: find,
insert and remove take O(log n) even
in the worst case. The splitting
process is applied
Name:
CS 61BL: Midterm 1
Summer 2012
CS61BL
Login: cs61blCourtney Wang
Midterm 1
Tuesday 7/03/2012
120 minutes
Name:
Student ID:
Instructions.
1. Put your name and login at the top of every page.
2. Attempt all or as many questions as you can. We cant giv
03/06/13
23:14:16
CS 61B: Lecture 19
Friday, March 8, 2013
Todays reading:
1
19
Sierra & Bates, p. 664.
ENCAPSULATED LISTS (a case study in encapsulation)
=
Homeworks 3, 4, and 5 introduced you to three different implementations of
linked lists, each fund
03/04/13
23:48:04
18
CS 61B: Lecture 18
Wednesday, March 6, 2013
Todays reading:
Sierra & Bates, pp. 80-84.
ENCAPSULATION
=
A _module_ is a set of methods that work together as a whole to perform some
task or set of related tasks. A module is _encapsulate
02/11/13
18:57:30
CS 61B: Lecture 10
Wednesday, February 13, 2013
Todays reading:
1
10
Sierra & Bates, pp. 95-109, 662.
equals()
=
Every class has an equals() method. If you dont define one explictly, then
"r1.equals(r2)" returns the same boolean value as
05/11/13
22:18:25
CS 61B: Lecture 1
Wednesday, January 23, 2013
Prof. Jonathan Shewchuk, [email protected]
Email to prof & all TAs at once (preferred): [email protected]
Todays reading: Sierra & Bates, pp. 1-9, 18-19, 84.
Handout: Course Overview (also availabl
/*
* Compilation: javac StdDrawPlus.java
* Execution:
java StdDrawPlus
*
* Standard drawing library. This class provides a basic capability for
* creating drawings with your programs. It uses a simple graphics model that
* allows you to create drawings co
/*ShieldPiece.java*/
/*
* Represents a ShieldPiece in Checkers61bl
* @author
*/
public class ShieldPiece extends Piece cfw_
/*
* Define any variables associated with a ShieldPiece object here.
* variables MUST be private or package private.
*/
/*
* Constr
/*BombPiece.java*/
/*
* Represents a BombPiece ins Checkers61bl
* @author
*/
public class BombPiece extends Piece cfw_
/*
* Constructs a new BombPiece
* @param side what side this BombPiece is on
* @param b
Board that this BombPiece belongs to
*/
public B
import java.util.ArrayList;
import java.util.LinkedList;
import junit.framework.TestCase;
public class TimerTest extends TestCase cfw_
public void testDiff() cfw_
ArrayList<Integer> arr = new ArrayList<Integer>();
LinkedList<Integer> link = new LinkedList
import java.util.*;
import junit.framework.TestCase;
public class ListTest extends TestCase cfw_
public void testConstructor() cfw_
List l1 = new List();
assertEquals ("( )", l1.toString();
assertTrue (l1.isEmpty();
assertTrue (l1.size()=0);
public void
03/08/13
23:49:50
CS 61B: Lecture 20
Monday, March 11, 2013
Todays reading:
1
20
Goodrich & Tamassia, Chapter 4 (especially 4.2 and 4.3).
Next, you must learn how to express this idea rigorously. Here is the
central lesson of todays lecture, which will be
03/11/13
23:48:47
21
CS 61B: Lecture 21
Wednesday, March 13, 2013
Theta is symmetric: if f(n) is in Theta(g(n), then g(n) is in Theta(f(n).
For instance, n^3 is in Theta(3 n^3 - n^2), and 3 n^3 - n^2 is in Theta(n^3).
n^3 is not in Theta(n), and n is not
03/20/13
03:31:58
CS 61B: Lecture 24
Wednesday, March 20, 2013
Todays reading:
1
24
Goodrich & Tamassia, Chapter 7.
ROOTED TREES
=
A _tree_ consists of a set of nodes and a set of edges that connect pairs of
nodes. A tree has the property that there is ex
Algorithms Case Study:
Sorting
Quote of the Week: It would be reasonable to suppose
that a routine time or an eventless time would seem
interminable. It should be so, but it is not. It is the dull
eventless times that have no duration whatsoever. A
time s
Review and Additional Data
Structure Tradeoffs
Quote of the Week: You know people for a
reason, a season, or a lifetime.
via Samantha Eng, source unknown
Regex puzzle hunt winning teams
Will be announce on piazza tonight, after I
confer with the TAs
Come
ADTs, Hashing, Gitlet Intro
Quote of the week: More than cleverness, we
need kindness and gentleness.
ADTs
Abstract Data Types, or ADTs, are purely
theoretical descriptions of data structures
Described only in terms of behavior and the
operations they sup
Welcome to CS 61BL!
Quote of the week: Speak casually, but never think casually.
Lets introduce the staff
Your TAs! Say hello to them if you see them around!
Lets introduce the staff
Me
NOT a professor. A Berkeley alumnus.
Call me Joseph, or Joe, or Joey
Debugging, Big O, Lists
Quote of the week: If we are indeed in as bad a state as I take us to
be, pessimism will turn out to be one more cultural luxury that we
shall have to dispense with in order to survive in these hard times.
You have an exam coming u
Midterm I
Solutions
Problem 1. (10 points) A miscellany.
a.
int[][] arr = new int[3][];
arr[0] = new int[2];
arr[1] = new int[3];
arr[2] = new int[4];
Another way to do this is with an initializer:
int[][] arr = cfw_new int[2], new int[3], new int[4];
b.
05/06/13
22:04:12
CS 61B:
Practice for the Final Exam
[6]
We will cover some of these questions for review, but please attempt these
questions before that comes to pass. Starred problems are particularly
difficult-much more difficult than any exam questio
04/01/13
22:12:18
CS 61B: Lecture 27
Wednesday, April 3, 2013
2-3-4 TREES
=
A 2-3-4 tree is a perfectly balanced tree. It has a big advantage over regular
binary search trees: because the tree is perfectly balanced, find, insert, and
remove operations tak
05/16/13
05:04:31
29
CS 61B: Lecture 29
Monday, April 8, 2013
GRAPHS (continued)
=
Breadth-first search (BFS) is a little more complicated than depth-first
search, because its not naturally recursive. We use a queue so that vertices
are visited in order a
05/15/13
22:32:15
1
28
CS 61B: Lecture 28
Friday, April 5, 2013
GRAPHS
=
A graph G is a set V of vertices (sometimes called nodes), and a set E of edges
(sometimes called arcs) that each connect two vertices together. To confuse
you, mathematicians often