Prof. Spencer
March 27, 2017
FUNDAMENTAL ALGORITHMS MIDTERM
SOLUTIONS
1. (15) Let A[1 N ] be an array with all entries integers between 0 and
N 1. How long would RADIX-SORT take to sort A assuming tha
, Fundamental Algorithms: HW 9 solutions
8.0. a) Without looking at the book, write a version of the FloydWarshall algorithm that includes path recovery. You can
assume that EdgCst(i, j) = 00 if G doe
CSCI-GA.1170-001/002 Fundamental Algorithms
September 23, 2012
Problem Set 3
Lecturer: Yevgeniy Dodis
Due: Tuesday, September 25
Problem 3-1 (Recurrences and Matrix Exponentiation) 18 points
The seque
CSCI-GA.1170-001/002 Fundamental Algorithms
November 13, 2012
Problem Set 7
Lecturer: Yevgeniy Dodis
Due: Tuesday, November 20
Problem 7-1 (Bracketings)
8 (+7) Points
Imagine a unary alphabet with a s
CSCI-GA.1170-001/002 Fundamental Algorithms
October 9, 2012
Problem Set 6
Lecturer: Yevgeniy Dodis
Due: Wednesday, October 17
Problem 6-1 (Find the Josephus Permutation)
10 points
According to Josephu
CSCI-GA.1170-001/002 Fundamental Algorithms
September 9, 2012
Problem Set 1
Lecturer: Yevgeniy Dodis
Due: Tuesday, September 11
Problem 1-1 (Counting Inversions)
10 points
Let A[1, . . . , n] be an ar
Algorithm Design and Analysis
2/12/2010
Lecture 15: Selection in worst case linear time
Instructor: Mike Kowalczyk
1
Selection in worst case linear time
Problem definition:
Problem name: Selection
Inp
6.006 Introduction to Algorithms
Recitation 7
September 30, 2011
Sort Stability
A sorting algorithm is stable if elements with the same key appear in the output array in the same
order as they do in t
. Darn 9? 3(ch (ij)
. TO Ponahu 50"
" MEMMMM SPahrunil M
(2-, (redcol cu VMLmCJV-LEE
WW
D173 (a) 1 cfw_S
\I
Pm (KC/Ll ucav; O O
E e v '
L\-00\0W( z um? a C ) L/ \( 1/
WW : NIL O < 7,0
t: 0 \>0
31
CS 253: Algorithms
Chapter 8
Sorting in Linear Time
Credit: Dr. George Bebis
How Fast Can We Sort?
2
How Fast Can We Sort?
Insertion sort:
O(n2)
Bubble Sort, Selection Sort:
(n2)
Merge sort:
(nlgn)
Qu
Fundamental Algorithms
Courant, Fall 2017
Homework 7
Instructor: Amir Shpilka
Due Date: Wed Nov 1, 11:55pm
1. (Dont be greedy)
(a) (3 points) Show, by means of a counterexample, that the following gre
Fundamental Algorithms
Courant, Fall 2017
Homework 8
Instructor: Amir Shpilka
Due Date: Wed Nov 8, 11:55pm
1. You are opening a new chain of hipster artisanal locally-sourced vegan coffe shops on Firs
Fundamental Algorithms
Courant, Fall 2017
Homework 9
Instructor: Amir Shpilka
Due Date: Wed Nov 15, 11:55pm
1. (3 points) Prove that a binary tree that is not full cannot correspond to an optimal pref
Fundamental Algorithms
Courant, Fall 2017
Homework 11
Instructor: Amir Shpilka
Due Date: Wed Dec 6, 11:55pm
1. (a) (4 points) Assume that all edge weights of an undirected graph G are equal to the sam
Fundamental Algorithms
Courant, Fall 2017
Homework 10
Instructor: Amir Shpilka
Due Date: Wed Nov 29, 11:55pm
1. The diameter of an undirected tree T = (V, E) on n vertices V (and (n 1) edges E) is the
Homework
assignments
are
incredibly
time-consuming
.
He
often
merely
skims
over
info
that
's
central
to
the
hw
,
or
doesn
't
even
get
to
the
topic
until
the
day
it
's
due
.
Tests
were
way
too
long
.
disappointing N
class N
. .
davi N
only N
gave N
2 N
lectures N
, ,
the N
rest N
were N
classes N
explaining N
the N
homework N
. .
he N
clearly N
made N
no N
effort N
to N
prepare N
lessons N
, ,
a
disappointing N
class N
. .
davi N
only N
gave N
2 N
lectures N
, ,
the N
rest N
were N
classes N
explaining N
the N
homework N
. .
he N
clearly N
made N
no N
effort N
to N
prepare N
lessons N
, ,
a
disappointing N
class N
. .
davi N
only N
gave N
2 N
lectures N
, ,
the N
rest N
were N
classes N
explaining N
the N
homework N
. .
he N
clearly N
made N
no N
effort N
to N
prepare N
lessons N
, ,
a
disappointing
class
.
davi
only
gave
2
lectures
,
the
rest
were
classes
explaining
the
homework
.
he
clearly
made
no
effort
to
prepare
lessons
,
a
syllabus
,
slides
,
etc
.
Grades
were
based
100%
on
/*
* scorer for NLP class Spring 2016
* ver.1.0
*
* score a key file against a response file
* both should consist of lines of the form:
* sentences are separated by empty lines
*/
import
import
impor
CSCI-GA.1170-001/002 Fundamental Algorithms
September 23, 2015
Problem Set 3
Lecturer: Yevgeniy Dodis
Due: Tuesday, September 29
Problem 3-1 (Stock Prot)
10 (+5) Points
Sometimes, computing extra info
Homework N
assignments N
are N
incredibly N
time-consuming N
. .
He N
often N
merely N
skims N
over N
info N
that N
's N
central N
to N
the N
hw N
, ,
or N
doesn N
't N
even N
get N
to N
the N
Fundamental Algorithms
Courant, Fall 2017
Homework 6
Instructor: Amir Shpilka
Due Date: Wed Oct 18, 11:55pm
1. (a) (6 points) Give an algorithm that constructs a balanced binary search tree from an ar
Homework 6 Solutions
Fundamental Algorithms, Spring 2012, Professor Ezra
INSTRUCTIONS:
Remember that we have a no late homework policy. Special permission must be obtained
in advance if you have a va