COT 5407 U01/RXA - INTRODUCTION TO ALGORITHMS - FALL 2015
Quiz 02
Advanced Design and Analysis Techniques
Allan Manamel | Panther ID : 5700508
12/3/2015
Q1. Show how to compute the length of an LCS using only 2 * min (m, n) entries in the c
table plus O (
Chapter 13: Red-Black Trees
A red-black tree is a node-colored BST.
Each node is colored either black or red. The
following special rules apply:
1. The root is always black.
2. A nil is considered to be black. This
means that every non-NIL node has two
ch
Recurrence: Solve, Prove, Ruminate.
Chris Brown
September 14, 2005
1
The problem
Solve
T (0) = 0
T (n) =
1 n1
T (i) + cn, n > 0.
n i=0
Prove your answer. What is the asymptotic order of T (n)? What can you say about
generalizations?
2
Solution (creating a
CBs Answers, Asst. 2
CSC 172 8 Sept. 1997
Read the handout on Mathematical Preliminaries. 1. How many different 5-card draw poker hands may be dealt from a 52 card deck? 52 choose 5, or , or
2. How many different 5-card draw poker hands may be dealt from
Chapter 9: Medians and Order Statistics
The selection problem is the problem of
computing, given a set A of n distinct
numbers and a number i, 1 i n, the ithh
order statistics (i.e., the ith smallest
number) of A.
We will consider some special cases of th
Universal Hashing
Suppose that a situation in which an
application that employs hashing is repeatedly
executed and in which the hash function is
selected from a pool of hash functions at
each execution.
Let H be the pool of hash functions.
We say that H i
g v V t v t g f d t u P &d t U X V u iz V wd V X z Wf X bV f d f z V v f z u g u cfw_ W f z U W f d U g W 6V g U X V f z wV Piz wV g d (V &dX V f z g g r t v t " u X V H X V R G u X u 6 W f z f FU V V z V V X V v v v t z t t u V V X V t u &FU Pz d t U e
COT5407 Fall 2006 Quiz #1
Instructor: Tao Li
September 7th, 2006
Student ID:
Name:
1. Let R be the binary relation over the set of real number, dened by
(A, B) R A is a proper subset of B.
For each of the following statements below, answer whether it is t
Example of Inserting Sorted Numbers
x 1 2 3 4 5 6 7 8 9 10
1 Insert 1. A leaf so red. Realize it is root so recolor to black.
1
1
Insert 2
make 2 red. Parent is black so done. 1 2
2
Insert 3
1 Insert 3. Parent is red. Parent's sibling is black (null) 3 is
Order Statistics
Many of the slides are from Prof. Plaisteds resources at University of North Carolina at Chapel Hill
Order Statistic
Selection Problem
Selection problem:
Input: A set A of n distinct numbers and a number i, with 1 i n. Output: the eleme
External Memory Dictionary Task: Given a large amount of data that does not t into main memory, process it into a dictionary data structure.
Need to minimize number of disk accesses
With each disk read, read a whole block of data
Construct a balanced s
Amortized Analysis
Amortized Analysis
Some of the slides are from Prof. Leong Hon Wais resources at National University of Singapore
Incrementing a Binary Counter
k-bit Binary Counter: A[0.k1]
x=
i
k 1
i =0 A[i ] 2
INCREMENT(A)
1. i 0
2. while i < length
Chapter 24: Single-Source Shortest Paths
Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible destination.
Similar to BFS.
We will assume either
no negative-weight edges, or no reachable negati
Elementary Sorting Algorithms
Many of the slides are from Prof. Plaisted's resources at University of North Carolina at Chapel Hill
Sorting Definitions
Input: n records, R1 . Rn , from a file. Each record Ri has
i
a key K possibly other (satellite) infor
Fibonacci numbers
Fibonacci numbers:
0, 1, 1, 2, 3, 5, 8, 13, 21,
34, .
where each number is the sum of the
preceding two.
Recursive definition:
F(0) = 0;
F(1) = 1;
F(number) = F(number-1)+ F(number2);
Redundant Calculations I
To compute fib(n), we
Growth Rates
Growth rates of functions:
In a loglog chart, the slope of the line corresponds to the growth rate of the function
T (n )
Linear n Quadratic n2 Cubic n3
1E+30 1E+28 1E+26 1E+24 1E+22 1E+20 1E+18 1E+16 1E+14 1E+12 1E+10 1E+8 1E+6 1E+4 1E+2
COT 5407: Introduction to Algorithms
Tao Li
ECS318; Phone x6036 : taoli@ cs.fiu.e du
http:/www.cs.fiu.e du/~taoli/class/C OT5407-F09/inde x.htm l
10/06/09
COT 5407
1
Why should I care about Algorithms?
Cartoon from Intractability by Garey and Johnson
8/28