Week 6 CS 302
Jim Williams, PhD
This Week
Lab: Multi-dimensional Arrays
Exam 1: Thursday
Lecture:
Methods
Review
Midterm Exam 1
What is the location of the
exam?
3650 Humanities
125 Ag Hall
272 Bascom
Other (due to
conflicts)
Midterm Exam - Thursday
Br
CS 354 - Machine Organization
Monday, October 17, 2016
Project p3 (6%) due 10 pm Monday, October 24th (exam week)
Homework hw5 (1.5%) due 10 pm Friday, October 21 st
Last Time
Designing a Cache
0 blocks
sets & tags
0 lines
Basic Cache Operation
Today
Bas
CS 354 - Machine Organization
Wednesday, October 5, 2016
Project p2 (6%) due 10 pm THIS Friday, October 7th
* . 255.1
Last Time
Placement Policy
Free Block - Too Much/Too Little
Coalescing Free Blocks
Footers
Today
Footers (from last time)
Explicit Free L
CS 354 - Machine Organization
Monday, September 26, 2016
Homework hw2 (1.5%) due 10 pm TOMORROW Tuesday, September 27th
Project p2 (6%) due 10 pm Friday, October 7th
Last Time
File l/O and stdio.h
Where Do | Live?
C Memory Model
Address Space Layout
Today
CS 354 - Machine Organization
Wednesday, September 28, 2016
Last Time
Continue pages
Heap Terms
brk (unistd . 11)
Today
implicit Heap Allocator (stdlib . h) (from last time)
Allocator Design (from last time)
A Bit of Linux
Simple View of Heap
Free Block
CS 354 - Machine Organization
Friday, September 9, 2016
We assume that you have successfully completed CS 302 and CS/ECE 252.
Jim Skrentny, 5379 CS, skrentny@_cs.wisc.edu
Canvas website: https:/canvas.wisc.edu/courses/3949
Outlines: On Canvas select Files
CS 354 - Machine Organization
Wednesday, October 19, 2016
Project p3 (6%) due 10 pm Monday, October 24th (exam week)
Homework hw5 (1.5%) due 10 pm Friday, October 21 st
Midterm Exam Thursday October 27th, 7:15 - 9:15 pm
replies have been posted/sent for m
CS 354 - Machine Organization
Friday, September 30, 2016
Last Time
Implicit Heap Allocator (stdlib . h)
Allocator Design
A Bit of Linux
Simple View of Heap
Free Block Organization
Today
Simple View of Heap (from last time) - '
Free Block Organization (f
CS 354 - Machine Organization
Monday, October 3, 2016
- Last Time
Simple View of Heap
Free Block Organization
lmplicit Free List
Placement Policy
Today
Placement Policy (from last time)
Free Block Too Much/Too Little (from last time)
Coalescing Free Blo
CS 354 - Machine Organization
Wednesday, September 7, 2016
We assume that you have successfully completed CS 302 and CSIECE 252.
Waitlisted? Continue attending. Some seats open as students finalize their schedules.
Instructor
- Jim Skrentny
- skrentny@cs.
2. a) Step 1: Hypothesize a Loop Invariant
At the end of each iteration of the while loop in P(G,s)
count_of_vertices_reachable_from (s) = count + |A|
Where |A| = set of uncounted nodes reachable from
some node on the stack
2
Step 2: Run a few iterations
1. a) Let,
n be the number of points on the circumference of the circle, and
R(n) denotes the number of regions (inside the circle)
When there is no point on the circle (i.e. n = 0) the entire circle is a single region. So
R(n) = 1
Values of R(n) for n =
1. b) Figure 1.b shows the induction step when going from n = 5 to n + 1 (6). The five new
line segments added in this step are dashed and colored red.
The number of new regions introduced by the sixth point can be determined by
considering the number of
1.
a)
Initially we have a set of classes C and a set of rooms R. The goal is to build a set of class
to room assignments such that we maximize the number of classes and also maximize the
number of students for any such assignment.
Note that all rooms beco
1.
b)
Let prove that our greedy algorithm returns an optimal set (S) of assignments.
1. S is a compatible set of assignments
We can immediately declare that the assignments in the set S returned by the
algorithm are all compatible, such that there is no o
1.
c)
Although our previous algorithm was complete and correct, we can improve its running time
by altering its looping constructs and using more complex data structures.
We can do considerably better if we use a priority queue to store the classes. Itll
2. b) This implementation of DFS is a simple loop based algorithm, so as long as the
bounds of the while loop do not increase infinitely the algorithm will definitely
terminate.
Lets now analyze the bounding condition of our while loop and understand if a
2. c) Program correctness can be formalized using a kind of judgment called a Hoare triple
P cfw_ S Q
Where:
P and Q are the pre and post conditions involving the variables in the program
S is the program statement itself
This means that If P is true abo
CS 301: Conditions
February 1, 2016
Admin stuf
Assignment due Thursday at noon
Lab sections meet today - optional
First program grades available by end of Tuesday
Official department tutoring available!
Conditions
When you have diferent situations, you ma
CS 302: Types and Input
January 25, 2016
Function landmarks
def f(x):
" This is a function. It does stuff
. "
return 3.14159 * (x * 2)
Indenting and functions
Functions are like reverse paragraphs - everything IN
them is indented.
When writing a paragraph
CS 301: First Programs
January 22, 2016
What a
program looks
like
So.
.what did you get when you "downloaded Python"?
What is the "interpreter"?
Later: What is LiClipse?
Program skills:
Hello World
hello w orld
Creating a program
Producing output
Running
CS 301: Types and Input
January 27, 2016
Admin stuf
Course website: http:/pages.cs.wisc.edu/~cs3011/
First assignment due Thursday at noon
Office hours: today 2:30-4:30 in CS 5395
If you just added, see me after class
Variables vs Function Calls
We can do
CS 301: Data Types
January 29, 2016
Admin stuf
Course website: http:/pages.cs.wisc.edu/~cs3011/
First assignment was due yesterday at noon
If you just added, see me after class
raw_input return type
raw_input() always gives back a string.
When might this
CS 301: Conditions
February 5, 2016
Admin stuf
Reminder: no late work.
Tutoring available M-W afternoon/evenings
if statement syntax
if condition1:
# code for w hen condition1 is true
elif condition2:
# code for w hen condition2 is true
else:
# code for w
CS 301: Conditions
February 3, 2016
Admin stuf
Assignment due tomorrow at noon
Office hours today, 2:30-4:30pm (assignment
help)
Office hours tomorrow, 12:30-2:15pm (general)
Tutoring available M-W afternoon/evenings
Basic if statement flow chart
g et g u
CS 301: Logic and Loops
February 8, 2016
Admin stuf
Hand in programs as many times as you want!
Lab sections meet today
Tutoring available M-W afternoon/evenings
if statement syntax
if condition1:
# code for w hen condition1 is true
elif condition2:
# cod