Assigned: 01/26/10
Due: 02/02/10
CprE 288 Spring 2010
Homework 2
Name:
Section:
NOTE: The homework is due in the class on the due date. Homework answers must be
typed using a word editor. Handwritten answers will not be accepted. A hard copy is
required f
Com S 228 Spring 2016
Assignment 5: Dijkstras Algorithm for Solving
Mazes
Due at 11:50 pm on Thursday, April 21
Introduction
This assignment gives you opportunities to develop your programming skills in implementing a graph algorithm for finding a shortes
CS 228: Introduction to Data Structures
Lecture 16
Monday, February 23, 2015
The AbstractCollection<E> Class
AbstractCollection<E> is a generic abstract class
that implements of all the methods of Collection<E>,
except size() and iterator(). It serves as
CS 228: Introduction to Data Structures
Lecture 15
Monday, February 16, 2015
Creating a Generic Array
As we saw last time, because of erasure
E foo = (E) bar;
/ unchecked warning
is essentially equivalent to the code
Object foo = (Object) bar;
Still, in o
CS 228: Introduction to Data Structures
Lecture 14
Friday, February 13, 2015
Wild Cards and Bounds
As we have seen, generic sorting methods typically come
in one of two forms, corresponding to two ways of
comparing objects in Java.
1. For an existing clas
ProcedureBased Programming
main()
func1()
func2()
.
first function invoked
at execution
func3()
func4()
The functions within a program communicate through values
that they receive and return.
Application: Banking
Maintain a collection of bank accounts
st
Priority Queues
Priority Queues
Priority queues prioritize collections of keyvalue pairs,
based on a total order on the keys.
Example: Values are airline flights, and the keys are
(arrival or departure) times, e.g.,

(11:16 am, DL3347).
An entry with a
QuickSort
partition
Precondition: Array arr and indices first and last
such that
0 first last arr.length
Postcondition: Rearranges arr and returns p so that:
first
p
pivot
pivot
last
> pivot
partition
private static int partition(int[] arr,
int first, in
Insertion Sort
for i = 1 to n 1:
insert A[i] in proper place amongst A[0.i]
INSERTIONSORT(A)
n = A.length
for i = 1 to n1
temp = A[i]
j = i 1
while j > 1 & A[j] > temp
A[j+1] = A[j]
j
A[j+1] = temp
Loop Invariant
INV. At the start of iteration i of the ou
DFS
dfs(G):

 foreach node v in G
  color(v) = white
  pred(v) = null

 foreach node v in G
  if color(v) = white
   dfsVisit(G, v, color, pred)

 return pred
dfsVisit(G, u, color, pred):

 color(u) = grey

 foreach neighbor v of u
 
BreadthFirst Search
BFS(G,s):
let Q be an empty queue
foreach node v in G except s
 color(v) = white
 dist(v) =
 pred(v) = null
color(s) = grey
dist(s) = 0
pred(s) = null
Q.enqueue(s)
while !Q.isEmpty()
 let u = Q.front()
 foreach neighbor v of u

Com S 228 Spring 2016
Assignment 1: Biosequence Class Hierarchy
Due at 11:50 pm on Thursday, February 4
Introduction
This assignment gives you opportunities to organize biosequence data and operations
by using objectoriented concepts in Java according to
COM S 228, Spring 2016
Programming Project 2
Sorting and Searching
Problem Overview
Sorting is of enormous importance in the practice of computing. Rare is the application that does not include sorting in its implementation. Everything from word processin
Assigned: 02/09/10
Due: 02/16/10
CprE 288 Spring 2010
Homework 4
Name: Pengqing Xie
Section: B
NOTE: The homework is due in the class on the due date. Homework answers must be
typed using a word editor. Handwritten answers will not be accepted. A hard cop
Assigned: 02/02/10
Due: 02/09/10
CprE 288 Spring 2010
Homework 3
Name: Pengqing Xie
Section: B
NOTE: The homework is due in the class on the due date. Homework answers must be
typed using a word editor. Handwritten answers will not be accepted. A hard cop
Assigned: 01/19/09
Due: 01/26/09
CprE 288 Spring 2010
Homework 1
NOTE: The homework is due in the class on the due date. Homework answers must be
typed using a word editor. Handwritten answers will not be accepted. A hard copy is
required for inclass sub
Homework 1
Pengqing Xie
1. a) ATmega128 which made by Atmel Corporation, and its CPU frequency is 16MHz.
b) Program Memory: 128K bytes Onchip InSystem Reprogrammable Flash memory
for program storage
SRAM Data Memory: 4K bytes, The ATmega128 supports two
Com S 228: Introduction to Data Structures
Instructors
Jeremy Sheaffer
Office: 110 Atanasoff Hall
Lecture: MWF 8:00am8:50am
Ofce Hours: TBA
Xiaoqiu (Siaochcw) Huang
Ofce: 205 Atanaso' Hall
Lecture: MWF 11:00amllc50am
Email: sheafferiastateedu
Phone: 294
Final Exam for Com S 228 Spring 2016
Name:
University ID:
There are 10 pages and 5 questions. Please start with easy questions. We will give
partial credit for a partially correct solution. You are not allowed to use any books,
notes, calculators, or elec
Exam 2 for Com S 228 Spring 2016 on March 24, 2016
Name:
University ID:
Recitation section (please circle one):
Section
Section
Section
Section
Section
Section
Section
1
2
3
4
5
6
7
R
R
R
R
R
T
T
10:00am10:50am
2:10pm3:00pm
1:10pm2:00pm
4:10am5:00am
3
Solution to Exam 1 for Com S 228 Spring 2016 on February 17, 2016
Name:
University ID:
Recitation section (please circle one):
Section
Section
Section
Section
Section
Section
Section
1
2
3
4
5
6
7
R
R
R
R
R
T
T
10:00am10:50am
2:10pm3:00pm
1:10pm2:00pm
Ten Great Writers who cudtn even Spell
number 4 made me lol!
Assigned October 29, 2014
Due 23:59:00 November 12, 2014
Fainali, xen, aafte sam 20 iers ov orxogrefkl riform, wi wud hev a lojikl, kohirnt
speling in ius xrewawt xe Ingliyspiking
werld.
Trees
Com S 228 Spring 2016
Assignment 3: A Chunky List
Due at 11:50 pm
Thursday, March 10
1. Introduction
This assignment gives you opportunities to develop your programming and debugging skills in working
with a linked data structure and to become familiar wi
Dijkstra
DIJKSTRA(G,s):

 for each node v in G except s
  d(v) =
  pred(v) = null
 d(s) = 0

 let Q be a priority queue containing the nodes of G

prioritized by dvalue
 let C be an empty set

 while Q is not empty
  u = removeMin(Q)
 
Line Segments & Vectors
y
= ()
(
x
Points (vectors):, =
Line segment:
Dot (Inner) Product
=
Cross (Vector) Product
is the signed area
of the parallelogram.

and are collinear with the origin iff .
Turning of Consecutive Segments
Segments and . Move from
Shortest Paths in
DAGs
Edge Relaxation
RELAX(u,v):
 if d(v) > d(u) + w(u,v)
  d(v) = d(u) + w(u,v)
  pred(v) = u
s
u
v
Pathrelaxation property
If
p=
v0
v1
v2
vk
is a shortest path from s = v0 to vk, and we relax the edges of p
in the order
(v0,v1),
Shortests Paths in DAGs
When the graph is a directed acyclic graph (DAG), relax
edges according to a topological ordering of vertices.
Correctness
Path relaxation property: If
is a shortest
path from to , and relax in the order ( , ), (, ), after the
rela
Applications of DFS
In time, we can
Find connected components of .
Determine if has a cycle.
Determine if removing a vertex or edge will disconnect .
Determine if is planar, i.e., if it can be drawn on the plane
with no crossing edges.
Detecting Cycles
Fa
Notes by YanBin Jia (partially modified from Dr. FernandezBacas)
Graph
A graphis a set of vertices (nodes) and a set of
edges which are pairs of vertices.
vertex
edge
12 vertices
13 edges
A Directed Graph
In a directed graph (digraph), edges are ordered
Classification of
Edges
Edge Types
1. Tree edges
2. Back edges: from descendant to ancestor
3. Forward edges: from ancestor to descendant
4. Cross edges: all others
A
B
C
E
D
F
G
H
Tree
Back
Forward
Cross
A
B
C
E
D
F
G
H
Tree
Back
Forward
Cross
A
B
C
E
D
Dijkstra
DIJKSTRA(G,s):

 for each node v in G except s
  d(v) =
  pred(v) = null
 d(s) = 0

 let Q be a priority queue containing the nodes of G

prioritized by dvalue
 let C be an empty set

 while Q is not empty
  u = removeMin(Q)
 
BreadthFirst Search
BFS(G,s):
let Q be an empty queue
foreach node v in G except s
 color(v) = white
 dist(v) =
 pred(v) = null
color(s) = grey
dist(s) = 0
pred(s) = null
Q.enqueue(s)
while !Q.isEmpty()
 let u = Q.front()
 foreach neighbor v of u

Shortest Paths in
DAGs
DAGSHORTESTPATHS(G,s):

 topologically sort the nodes of G

 / Initialization
 foreach node v in G
  d(v) =
  pred(v) = null
 d(s) = 0

 foreach node u in G in topological order
  foreach neighbor v of u
   / Relax