Katherine Kahla
CompSci 125 001
HW3
3.7. Write code to declare and instantiate an object of the Random class (call the object reference
variable rand). Then write a list of expressions using the nextInt method that generates random
numbers in the followin
Katherine Kahla
CompSci 125 001
HW2
2.10. Given the following declarations, what result is stored in each f the listed assignment
statements?
a. 5
b. 5.0
c. 3
k. 3
l. 3.0
m. 0.0
q. 0
2.11. For each of the following expressions, indicate the order in which
1.5. If a language uses 240 unique letters and symbols, how many bits would be needed to store
each character of a document? Why?
You would need 2^8 bits because to represent 240 unique letters and symbols you need at
least 240 bits and the smallest 2^N i
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 10
Chapter 10 Exercise Solutions
EX 10.1. Create a UML class diagram for the ProductCodes program.
EX 10.2. What would happen if the try statement were removed from the level1 method of the Exce
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 9
Chapter 9 Exercise Solutions
EX 9.1. Draw and annotate a class hierarchy that represents various types of faculty at a university. Show what characteristics would be represented in the various
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 8
Chapter 8 Exercise Solutions
EX 8.1. Draw a UML class diagram showing an inheritance hierarchy containing classes that represent different types of clocks. Show the variables and method names
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 7
Chapter 7 Exercise Solutions
EX 7.1. Which of the following are valid declarations? Which instantiate an array object? Explain your answers. int primes = cfw_2, 3, 4, 5, 7, 11; Invalid; an int
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 6
Chapter 6 Exercise Solutions
EX 6.1. Write a method called average that accepts two integer parameters and returns their average as a floating point value. public double average (int num1, int
Java Software Solutions, 6th Edition
Exercise Solutions, Ch. 5
Chapter 5 Exercise Solutions
EX 5.1. What happens in the MinOfThree program if two or more of the values are equal? If exactly two of the values are equal, does it matter whether the equal val
Java Software Solutions, 6h Edition
Exercise Solutions, Ch. 4
Chapter 4 Exercise Solutions
EX 4.1. For each of the following pairs, which represents a class and which represents an object of that class?
a. Superhero, Superman Class: Superhero, Object: Sup
COMPSCI 342-001 Data Structure and Algorithms (Fall 2011)
Lab Assignment #2, Due on 10/17/2011, Monday (11PM)
Introduction:
Suppose we are inserting n keys into a hash table of size m. Then the load factor
is dened to be n/m. For open addressing n m, wh
COMPSCI 342-001 Data Structure and Algorithms (Fall 2011)
Lab Assignment #1, Due on 9/09/2011, Friday (11PM)
Introduction:
This programming assignment asks you to design a cache implementation using linked list data
structure. That is, write a Cache class
1
COMPSCI 342-001 Data Structures and Algorithms (Fall 2011)
Homework #2 (75 points), Due on 9/21/2011 (Wednesday), class time
Q1(10 points): Asymptotic Notations
(a)(6 points) Try to show 1 n2 20n 100 = (n2 ) using the basic denition of nota5
1
tion. Th
COMPSCI 342-001 Data Structures and Algorithms (Fall 2011)
Homework 1 (70 points), Due on 9/07/2011 (Wednesday)
n
1. (10 points) Suppose that a computer does not know how to compute the value C2 directly
2
if n > 2, but the computer can return C2 = 1 in c
EtYB7&vT"&$
%@ 6$ B $ 8
a2&) T"Y)51a2E0B7" 754G7Y"1#wf&()b1277tPT8xY651G7Y"777Px754w8E8B7rw(8X274 w
0
8 B 2 ' 8 t S) " D" S $ $ B 2 ' 1" 0 B 2 0@ B 1 $ t
BEY1VW277("754TSxV6E0bBHY"fV(6b1R7("777P754G5BX2Y6512E85)(8xV754321&T)Y'T%7("E1e&7#!
8 P@ 1 B 2 ) 8
COMPSCI 225-002 Introduction to Computer Science II (Fall 2011)
Programming Assignment #4, Due on 10/11/2011, Tuesday (11PM)
Introduction:
This assignment will ask you to implement a Queue ADT using two stack instance variables s1 and
s2 . Please use TwoS
COMPSCI 225-002 Introduction to Computer Science II (Fall 2011)
Programming Assignment #3, Due on 9/20/2011, Tuesday (11PM)
Introduction:
This assignment will require you to nish the implementation of the LinkedList class, which implements Cloneable inter
COMPSCI 225-002 Introduction to Computer Science II (Fall 2011)
Programming Assignment #1 & #2, Due on 9/06/2011, Tuesday (11PM)
Introduction:
This assignment is designed to get you familiar with program development using Eclipse. There
are two parts of t
1
COMPSCI 225-002 Intro. to CS II (Fall 2011)
Homework #1 (80 points), due on 9/22/2011, Thursday
Q1(18 points): Running Time Analysis.
(a)(9 points) For the following functions f , please nd the tight (as good as possible)
upper bounds in the order hier
1.1
Indicate whether each of the following method calls is valid. Describe why it isnt valid or, if it is valid,
describe what it does. Assume people is an array of Person objects and peopleList is a List of Person objects.
a. people.sort();
b. Arrays.sor
1.1
Explain the effect of the following method calls.
Set<String> s = new HashSet<String>();
s.add("hello");
s.add("bye");
s.addAll(s);
Set<String> t = new TreeSet<String>();
t.add("123");
s.addAll(t);
System.out.println(s.containsAll(t);
System.out.print
1.1
Draw binary expression trees for the following infix expressions. Your trees should enforce the Java rules for
operator evaluation (higher-precedence operators before lower-precedence operators and left associativity).
a. x / y + a b * c
b. (x * a) y
1.1
Trace the execution of the call mystery(4) for the following recursive method using the technique shown in
Figure 5.2. What does this method do?
public static mystery(int n) cfw_
if (n = 0)
return 0;
else
return n * n + mystery(n 1);
mystery(4) (cond
1.1
Draw the queue in Figure 4.3 as it will appear after the insertion of customer Harris and the removal of one
customer from the queue. Which customer is removed? How many customers are left?
Original Queue (Fig 4.3)
Thome
Abreu
Jones
After insertion of
1.1
Assume that the stack names is defined as in Figure 3.2(c) and perform the following sequence of operations.
Indicate the result of each operation and show the new stack if it is changed.
names.push("Jane");
names.push("Joseph");
String top = names.po
1.1
Describe the effect of each of the following operations on object myList as shown at the bottom of Figure 2.2.
What is the value of myList.size() after each operation?
myList.add("Pokey");
myList.add("Campy");
int i = myList.indexOf("Happy");
myList.s
1.1
What are the two parts of an ADT? Which part is accessible to a user and which is not? Explain the
relationships between an ADT and a class; between an ADT and an interface; and between an interface and
classes that implement the interface.
An ADT con