Minimum Spanning Trees
weighted graph API
cycles and cuts
Kruskals algorithm
Prims algorithm
advanced topics
References:
Algorithms in Java, Chapter 20
http:/www.cs.princeton.edu/introalgsds/54mst
1
Minimum Spanning Tree
Given. Undirected graph G with pos

CS2210b: Data Structures and Algorithms
Winter 2014: Midterm Examination Solutions
120 minutes
Instructions:
Write your name and student number in the space provided.
Please check that your exam is complete. It should have 14 pages in total
The examina

Algorithms
R OBERT S EDGEWICK | K EVIN W AYNE
2.4 P RIORITY Q UEUES
API and elementary implementations
FOURTH
EDITION
API and elementary implementations
binary heaps
Algorithms
2.4 P RIORITY Q UEUES
binary heaps
heapsort
Algorithms
event-driven simu

COS 226, FALL 2013
COS 226 course overview
What is COS 226?
Intermediate-level survey course.
Programming and problem solving, with applications.
Algorithm: method for solving a problem.
Data structure: method to store information.
ALGORITHMS
AND
DATA STR

COS 226
Algorithms and Data Structures
Spring 2008
Midterm
This test has 8 questions worth a total of 80 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
dev

COS 226
Algorithms and Data Structures
Fall 2009
Final
This test has 12 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, both sides, in your own
hand

COS 226
Algorithms and Data Structures
Fall 2010
Final
This test has 14 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, both sides, in your own
hand

COS 226
Algorithms and Data Structures
Fall 2011
Final
This test has 14 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, both sides, in your own
hand

COS 226
Algorithms and Data Structures
Fall 2012
Final Exam
This test has 16 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, both sides, in your own

COS 226
Algorithms and Data Structures
Spring 2012
Final
This test has 14 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, both sides, in your own
ha

COS 226
Algorithms and Data Structures
Spring 2008
Final
This test has 12 questions worth a total of 100 points. You have 180 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet (8.5-by-11, in your own handwriting).

COS 226
Algorithms and Data Structures
Spring 2012
Midterm Solutions
1. Analysis of algorithms.
(a)
(b)
3
3
800,000,000 N
N3
2. Data structure and algorithm properties.
E Min height of a binary heap with N keys.
A. 1
E Max height of a binary heap with N k

COS 226
Algorithms and Data Structures
Spring 2008
Midterm Solutions
1. 8 sorting algorithms.
87495632
2. More sorting.
(a) Heapsort.
(b) Quicksort partitioning (but instead of using the rightmost element, use the value 1
million, swapping all keys strict

COS 226
Algorithms and Data Structures
Fall 2009
Midterm
This test has 8 questions worth a total of 60 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
devic

Version 2.0 Specification
July 2003
Copyright Microsoft Corporation 1999-2003. All Rights Reserved.
Notice
2003 Microsoft Corporation. All rights reserved.
Microsoft, Windows, Visual Basic, Visual C#, and Visual C+ are either registered trademarks or tra

COS 226
Algorithms and Data Structures
Fall 2012
Final Exam Solutions
1. Analysis of algorithms.
(a) 400 seconds
(b) 4M R
2. Graphs.
(a) The method marked[v] returns true if and only if there is a directed path from s to v .
(b) E + V , as usual for depth

COS 226
Algorithms and Data Structures
Spring 2012
Final Solutions
1. Analysis of algorithms.
(a) f (N ) =
1
1/2
100 N
(b) 24N + 64M bytes
Object overhead (16 bytes)
inner class (8 bytes)
four references (32 bytes)
char (2 bytes)
padding (6 bytes)
Integer

1
COS 226
Algorithms and Data Structures
Fall 2010
Midterm Solutions
1. Analysis of algorithms.
(a) For each expression in the left column, give the best matching description from the right
column.
B.
1 + 2 + 4 + 8 + . . . + N 2N
C.
1 + 2 + 3 + 4 + . . .

COS 226
Algorithms and Data Structures
Fall 2010
Midterm
This test has 8 questions worth a total of 60 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
devic

COS 226
Algorithms and Data Structures
Spring 2012
Midterm
This test has 9 questions worth a total of 60 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
dev

COS 226
Algorithms and Data Structures
Fall 2012
Midterm
This test has 9 questions worth a total of 55 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
devic

COS 226
Algorithms and Data Structures
Fall 2012
Midterm Solutions
1. Union nd.
ABC
A. The id[] array contains a cycle: 8 2 4 0 8.
B. The height of the forest is 4 > lg(10).
C. The size of tree rooted at the parent of 3 is less than twice the size of tree

COS 226
Algorithms and Data Structures
Fall 2011
Midterm
This test has 9 questions worth a total of 60 points. You have 80 minutes. The exam is closed
book, except that you are allowed to use a one page cheatsheet. No calculators or other electronic
devic

COS 226
Algorithms and Data Structures
Fall 2011
Final Solutions
1. Analysis of algorithms.
(a) T (N ) =
1
5/3 .
10 N
When N increases by a factor of 8, the memory usage increases by a factor of 32. Thus,
T (N ) = aN b , where b = log8 32 = lg 32/ lg 8 =

Geometric Algorithms
range search
quad and kd trees
intersection search
VLSI rules check
References:
Algorithms in C (2nd edition), Chapters 26-27
http:/www.cs.princeton.edu/introalgsds/73range
http:/www.cs.princeton.edu/introalgsds/74intersection
1
Overv

Balanced Trees
2-3-4 trees
red-black trees
B-trees
References:
Algorithms in Java, Chapter 13
http:/www.cs.princeton.edu/introalgsds/44balanced
1
Symbol Table Review
Symbol table: key-value pair abstraction.
Insert a value with specified key.
Search for v