Problem: Median Finding Algorithm for Joint Databases
You are interested in analyzing some hard to obtain data from two separate databases. Each database contains n numerical values - so there are 2n values total- and you may assume that no two values are
CMPT 307 Data Structures and Algorithms Exercises on Median and Order Statistics. Due: Thursday, October 15th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resourses must be explic
CMPT 307 Last Name
This is a sample!
First Name and Initials
Midterm Test
Some Day, 2009
Student No. NO AIDS allowed. Answer ALL questions on the test paper. Use backs of sheets for scratch work. Total Marks: 100 1. What running times of the insertion sot
Chapter 1
Introduction: Some Representative Problems
1.1 A First Problem: Stable Matching
As an opening topic, we look at an algorithmic problem that nicely illustrates many of the themes we will be emphasizing. It is motivated by some very natural and pr
CMPT 307 Data Structures and Algorithms Exercises on Divide and Conquer. Due: Thursday, November 19th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resources must be explicitly men
CMPT 307 Data Structures and Algorithms Outline Solutions to Exercises on Elementary Data Structures
1. Suggest how storage for elements can be allocated and deallocated within the hash table itself by linking all unused slots into a free list. Assume tha
CMPT 307 Data Structures and Algorithms Exercises on Sorting. Due: Thursday, October 8th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resourses must be explicitely mentioned on yo
CMPT 307 Data Structures and Algorithms Exercises on Elementary Data Structures. Due: Thursday, October 22th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resourses must be explici
CMPT 307 Data Structures and Algorithms Exercises on Heaps and Stable Matchings. Due: Thursday, September 24th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resourses must be expli
CMPT 307 Data Structures and Algorithms Exercises on Red-Black Trees. Due: Thursday, November 5th (at the beginning of the class)
Reminder: the work you submit must be your own. Any collaboration and consulting outside resources must be explicitly mention
CMPT 307 Data Structures and Algorithms Outline Solutions to Exercises on Heaps and Stable Matchings
1. Describe a (n log n) time algorithm that, given a set S of n integers and another integer x, determines whether or not there exist two elements in S wh
CMPT 307 Data Structures and Algorithms Outline Solutions to Exercises on Sorting
1. Show that the worst-case running time of Heapify-Up on a heap of size n is (log n). If the new value added to the very end of the heap is smaller than any other element o
CMPT 307 Data Structures and Algorithms Outline Solutions to Exercises on Sorting
1. Show that the second smallest of n elements can be found with n + log n 2 comparisons in the worst case. The smallest of n numbers can be found with n 1 comparisons as fo
CMPT 307 Data Structures and Algorithms Outline Solutions to Exercises on Red-Black Trees
1. Show that any arbitrary n-node binary search tree can be transformed into any other arbitrary n-node binary search tree using O(n) rotations. Since the exercise a
More Heaps
Data Structures and Algorithms Andrei Bulatov
Algorithms More Heaps
22-2
Binomial Heap: Union
Create heap H that is union of heaps H and H'. "Mergeable heaps." Easy if H and H' are each order k binomial trees. connect roots of H and H' choose s
Massachusetts Institute of Technology 6.046J/18.410J: Introduction to Algorithms Professors Piotr Indyk and Bruce Tidor
Handout 9 February 27, 2003
Problem Set 2 Solutions
Problem 2-1.
Matching Nuts and Bolts
(a) The problem statement does not describe ex
Problem 1 A heap of size n has at most n/2h+1 nodes with height h. Proof : Property 1: Let Sh be the set of nodes of height h, subtrees rooted at nodes in Sh are disjoint. In other words, we cannot have two nodes of height h with one being an ancestor of
CMPT 307 - Data Structures and Algorithms:
Problem Set 3
1. Recurrences Give asymptotic upper and lower bounds for T (n) in each of the following recurrences. Assume that T (n) is constant for n 2. Make your bounds as tight
as possible, and justify your a
Sequence Alignment
Data Structures and Algorithms Andrei Bulatov
Algorithms Sequence Alignment
20-2
Shortest Path: Finding Negative Cycles
Two questions: - how to decide if there is a negative cycle? - how to find one? Lemma It suffices to find negative c
Binomial Heaps
Data Structures and Algorithms Andrei Bulatov
Algorithms Binomial Heaps
21-2
Priority Queues
Supports the following operations. Insert element x. Return min element. Return and delete minimum element. Decrease key of element x to k. Applic
Heapsort
Data Structures and Algorithms Andrei Bulatov
Algorithms Heapsort
4-2
Heap Property
A heap is a nearly complete binary tree, satisfying an extra condition Let Parent(i) denote the parent of the vertex i Max-Heap Property: Key(Parent(i) Key(i) for
QuickSort and Others
Data Structures and Algorithms Andrei Bulatov
Algorithms Quicksort
5-2
Heap Property
A heap is a nearly complete binary tree, satisfying an extra condition Let Parent(i) denote the parent of the vertex i Max-Heap Property: Key(Parent(
QuickSort
Data Structures and Algorithms Andrei Bulatov
Algorithms Quicksort
6-2
Probability Reminder
Sample space Event Probability Discrete random variable: A variable that takes values with certain probability Example: The amount of money you win buyin
Sorting in Linear Time
Data Structures and Algorithms Andrei Bulatov
Algorithms Sorting in Linear Time
7-2
Comparison Sorts
The only test that all the algorithms we have considered so far is comparison The only information we obtain about an input sequenc
Order Statistics
Data Structures and Algorithms Andrei Bulatov
Algorithms Order Statistics
8-2
Medians and Statistics
We consider the following problems: - Find a minimal and maximal elements in a sequence - Find i-th smallest element in a sequence The Th
Hash Tables
Data Structures and Algorithms Andrei Bulatov
Algorithms Hash Tables
10-2
The Dictionary Problem
We have a dictionary Each entry of the dictionary consists of a key, a word, and an article explaining the word We to perform several simple opera
Hash Tables II
Data Structures and Algorithms Andrei Bulatov
Algorithms Hash Tables II
11-2
Hash Tables
In case of collision create a list of elements with the same hash value
h(k1 ) k1
k2 k4
key article next
h( k 2 )
key article next key article next
k3
Binary Search Trees
Data Structures and Algorithms Andrei Bulatov
Algorithms Binary Search Trees
12-2
Binary Search Tree
A binary search tree is a binary rooted tree, in which keys satisfy the Binary Search Tree property: Let x be a node in a binary searc