Problem 3
Say we have a greedy solution that packs each truck with as many boxes as possible
before sending the truck off. We can label these packages as p1, p2,pn. Assume that
an optimal solution exi
Problem 22
No. Consider a graph G = (V, E) with three vertices v1, v2, and v3 and three edges e1 =
(v1, v2), e2 = (v2, v3), and e3 = (v3, v1) with weights 1, 2, and 2 respectively. Two possible
minimu
Problem 6
If we consider the last line to contain the words wj, wj+1, , wn, then the final line
will have a slack of !,! = !
! (! + 1) ! . Thus, a recursive formula for the
!
optimum solution is
Problem 17
By Mengers theorem, the size of the minimum s-t cut is equal to the max number of
edge-disjoint s-t paths in a network. Therefore, we know that there are k edgedisjoint paths in our net
Problem 6
If we consider the last line to contain the words wj, wj+1, , wn, then the final line will
ci
(+1)c n .
have a slack of
Thus, a recursive formula for the optimum solution
n1
S j , n=L
i= j
Problem 5.2
The algorithm is similar to the original inversion counting algorithm.
Count-inversions(L):
If L has 1 element:
Return (0, L)
Divide L into two halves A and B
(vA, A) =
Problem 17
By Mengers theorem, the size of the minimum s-t cut is equal to the max number of
edge-disjoint s-t paths in a network. Therefore, we know that there are k edgedisjoint paths in our network
CS118
Spring 2017 Practice Midterm Exam
1 hour 50 minutes
Close book and closed notes,
except a SINGLE piece of paper as a cheat sheet.
NO use of any device except calculators.
This exam has 6 pages,
CS 180 Homework 1
Jack Wu
April 13, 2017
Chapter 2 Problems
5.
(a) TRUE: Since f (n) is O(g(n), N0 such that n > N0 , f (n) < Cg(n). Thus, log2 f (n) < log2 Cg(n) =
log2 C + log2 g(n) Clog2 g(n).
(b)
CS 180 Homework 4
Jack Wu
April 29, 2017
4.22
Consider the following counter example where A and B are a minimum spanning trees, but A B is not a
minimum spanning tree:
Figure 1:
4.25
Run Kruskals alg
CS 180 Homework 6
Jack Wu
May 25, 2017
6.19
Notation:
* |s| = number of elements in s
* s 1 = the string s with its last element removed
* s[n] = the last bit of the string s
We can see that this prob
CS 180 Homework 3
Jack Wu
April 22, 2017
Chapter 4 Problems
3.
We will prove that the current greedy algorithm is optimal by induction. Suppose our greedy algorithm only
requires 1 truck for the day a
CS 180 Homework 7
Jack Wu
June 1, 2017
7.11
This statement is true. Suppose he is missing backwards edges for which that an additional flow of F can
be sent if those edges were included. Then that mea
CS 180 Homework 2
Jack Wu
April 20, 2017
Chapter 8 Problems
15.
We will show that this problem is NP-Complete by showing that solving this problem would solve the Set
Cover problem, an already establi
CS 180 HW 5
Jack Wu
May 18, 2017
6.3
(a) Consider the following ordered graph. The longest path is cfw_(v1 , v3 ), (v3 , v4 ), (v4 , v5 ) which gives length
3, but the algorithm finds the path cfw_(v1
#include "GL/freeglut.h"
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include "vecmath.h"
using namespace std;
/ Globals
/ This is the list of points (3D vectors)
vector<
Wednesday:
How to make I/O faster (disk or flash drivers)
Lower latency/ Higher throughput
faster rpm
faster arms
clever data placement
(flash drives) higher recording density (more bits per surf
Monday:
More Virtual Memory. Typical
Last week we were given a simple model where there was a linear table. Each process
got its own page table. CR3 points to an array of PTEs. Each PTE points to a p
Lecture 1 - 4/3/17
Textbook: Computer Systems: A Programmers Perspective, 3rd Edition
You will probably need the textbook
GNU/Linux Seasnet Servers -> used for grading
use lnxsrv07 & lnxsrv09
*note: r
Lecture 3 - 4/10/17
unsigned int n = [.];
unsigned int hi = n > 7; / throws away the first 7 bits by right shifting
(signed char/short) sInt lo = n & 127;
unsigned int n2 = (hi < 7) | lo; / NOT sa
Lecture 5 - 4/17/17
%rip- keeps track of the next instruction to be executed
Essentially every instruction will change this number.
%rip = [?]- set %rip so that our program does what we want it to do
Lecture 9 - 5/1/17 - Floating Point
Approximate!
wishy-washy, bits are not necessarily all to be trusted
Ariane 5- 500 million dollar mistake
crashed because of floating point problem. Floating poin
Monday: Register Renaming and Caches
Register renaming- getting data where it needs to be as quickly as possible
inside the execution unit, register renaming is used
micro-ops refer to different cop
Lecture 1 - 4/3/17
Textbook: Computer Systems: A Programmers Perspective, 3rd Edition
You will probably need the textbook
GNU/Linux Seasnet Servers -> used for grading
use lnxsrv07 & lnxsrv09
*note: r