page 1 of 6
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 3 WITH SOLUTIONS
1. Let 1, 2 , , n be distinct lines in the Euclidean plane, and let A be
the set of points formed by intersections of these lines.
Characterize A using set
Hw#27: Recursive-Descent Parser Evaluation of Boolean Expressions
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler and Isaac Post
Section: 11:30AM
/*
* Evaluates a Boolean expression and returns its value.
*
* @param tokens
*
the cfw_@cod
page 1 of 5
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 2 WITH SOLUTIONS
1. Let P(x) be the predicate x is a dragon.
Let Q(x) be the predicate x breathes fire.
Let R(x,y) be the predicate x and y are the same object.
Rewrite the
Page 1 of 11
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 7 WITH SOME SOLUTIONS
1. Answer each question True or False, justifying each answer.
(a)
( f (n) (n ) and f (n) O (n ) ( f (n) (n ) or f (n) (n )
2
3
2
SOLUTION: False, consider the
Page 1 of 3
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 9 SOME SOLUTIONS
1.
Consider the digraph G = (V, E ) where
V = cfw_1, 2, , n and E = cfw_(i, i +1) : 1 i n 1 .
Let G * be the transitive closure of G. How many edges does G * have? D
Page 1 of 6!
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 6 SOME SOLUTIONS
1. Either prove or disprove the following:
Claim: For all n 2 , the Hamming cube H n is bipartite.
SOLUTION: Its true. Proof: Fix n 2 . Let ODDn be the set of
binary
Page 1 of 7
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 5 SOME SOLUTIONS
1. Give the running time of the following functions, using -notation. Show your
work.
function f1 (n)
s 0 ;
for i 4 to n 2 do
for j 5 to 3i !log 2 i# do s s + i j ;
Page 1 of 8
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 8 with some SOLUTIONS
1. Assume that there is an algorithm that multiplies two 5-by-5 matrices with 88
scalar multiplications and 1000 additions. Consider a recursive algorithm A
Consider the following contract specification for the static method
smooth.
1
2
3
4
5 /*
* No informal description here for obvious reasons.
6 *
7 * @replaces s2
8 * @requires |s1| >= 1
9 * @ensures <pre>
* |s2| = |s1| - 1 and
1 * for all i, j: integer, a
Hw#30: Waiting Line Family Interface Design
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler and Isaac Post
Section: 11:30AM
package components.waitingline;
/*
* cfw_@code QueueKernel enhanced with secondary methods.
*
* @param <String>
*
Hw#12 : BinaryTree and Recursion 2
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler and Isaac Post
Section: 11:30AM
/*
* Returns the cfw_@code String prefix representation of the given
* cfw_@code BinaryTree<T>.
*
* @param <T>
*
the type
Hw#21: Statement and Recursion
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler and Isaac Post
Section: 11:30AM
/*
* Reports the number of calls to primitive instructions (move, turnleft,
* turnright, infect, skip) in a given cfw_@code St
Page 1 of 6
CSE 2321 Foundations I Spring, 2013 Prof. Supowit
Homework 10 WITH SOME SOLUTIONS
1.
2. Modify the BFS algorithm so as to compute, for each vertex v in the graph, not only
v.dist (the length of shortest path from the source vertex s to v), b
Implementing the Standard
Methods
9 January 2015
OSU CSE
1
Loose Ends
In implementing several kernel interfaces
so far, you have been given code in the
skeletons for the Standard methods
The code for these methods is very
stylized and easy to adapt to a
Tree
9 January 2015
OSU CSE
1
Tree
The Tree component family allows you to
manipulate values modeled as
mathematical trees with any label type T
(i.e., tree of T)
9 January 2015
OSU CSE
2
Interfaces and Classes
Standard
Iterable
extends
extends
TreeKerne
Statement
11 January 2015
OSU CSE
1
BL Compiler Structure
Tokenizer
string of
characters
(source code)
Parser
string of
tokens
(words)
Code
Generator
abstract
program
string of
integers
(object code)
A BL program consists of some
statements
11 January 20
Linked Data Structures II:
Doubly-Linked Lists
9 January 2015
OSU CSE
1
Sequential Access
Sequential access usually means
accessing the entries of a collection (with
a string model) in increasing order of
position, by accessing the next entry in
the coll
Hw#5 : Queue Implementation on Sequence
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler and Isaac Post
Section: 11:30AM
@Override
public final void enqueue(T x) cfw_
assert x != null : "Violation of: x is not null";
this.entries.add(this
Hw#3 : Sequence Smooth as a Function
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler
Section: 11:30AM
/*
* Smooths a given cfw_@code Sequence<Integer>.
*
* @param s1
*
the sequence to smooth
* @requires <pre>
* cfw_@code |s1| >= 1
* </p
Hw#1 : Reading Formal Contract Specifications
Student name: Mingfeng Han
Professor Paolo Bucci
TA: Adam Wheeler
Section: 11:30AM
1. seq1 = <2,4,6>
seq2 = <3,5>
2. seq1 = <7>
seq2 = <>
3. it could be anything because it does not meet the requires clause si
Java Input/Output
11 April 2013
OSU CSE
1
Overview
The Java I/O (Input/Output) package
java.io contains a group of interfaces
and classes similar to the OSU CSE
components SimpleReader and
SimpleWriter component families
Except that java.io is far mo
Java Loose Ends
15 May 2014
OSU CSE
1
What Else?
A few Java issues introduced earlier
deserve a more in-depth treatment:
Try-Catch and Exceptions
Members (static vs. instance)
Nested interfaces and classes
Access modifiers
Final
15 May 2014
OSU CSE
CSE 2221 Software I: Software
Components
and
CSE 2231 Software II: Software
Development and Design
26 August 2014
OSU CSE
1
Additional CSE 2221 Policies
Class attendance is required.
Each class missed results in a 0.5 point
penalty (the first 4 labs and
CSE 2221 Software I: Software
Components
and
CSE 2231 Software II: Software
Development and Design
13 January 2015
OSU CSE
1
Welcome to CSE 2231!
Class attendance is required.
Each class missed results in a 0.5 point
penalty (the first 4 labs and the fi
Java Collections Framework
9 January 2015
OSU CSE
1
Overview
The Java Collections Framework (JCF)
is a group of interfaces and classes similar
to the OSU CSE components
The similarities will become clearly evident
from examples
See Java libraries packa
Basic Rule About Sets/Maps
Never change the entries in a Set or the
keys in a Map directly.
This applies to all components (OSUs,
JFCs, and any others).
15 November 2013
OSU CSE
1
Iterator Rule
When iterating over a collection with an
iterator (explici
Heaps and Heapsort
6 May 2013
OSU CSE
1
Heaps
A heap is a binary tree of T that
satisfies two properties:
Global shape property: it is a complete
binary tree
Local ordering property: the label in each
node is smaller than or equal to the label in
ea
Abstract Classes
8 September 2013
OSU CSE
1
The Real Story?
Standard
extends
NaturalNumberKernel
extends
Comparable
extends
NaturalNumber
implements
implements
NaturalNumber1L
8 September 2013
NaturalNumber2
OSU CSE
2
The Real Story?
Does each of NaturalN
BinaryTree
20 May 2013
OSU CSE
1
BinaryTree
The BinaryTree component family
allows you to manipulate values modeled
as mathematical binary trees with any
label type T (i.e., binary tree of T)
Another generic type like Sequence and Set
20 May 2013
OS
CSE 2231 Homework 6
@Override
public final void enqueue(T x) cfw_
assert x != null : "Violation of: x is not null";
this.entries.add(this.entries.length(), x);
@Override
public final T dequeue() cfw_
assert this.length() > 0 : "Violation of: this /= <>";