CMPS 101 Summer 2009 Homework Assignment 3
Solutions
1. (1 Point) The last exercise in the handout entitled Some Common Functions. 4n 2n Use Stirling's formula to prove that = n n . Proof: By Stirling
CMPS 101 Algorithms and Abstract Data Types
ADTs and Modules in Java and ANSI C
Introduction This document introduces the concepts of Modules and ADTs, and describes how to implement them in both Java
CMPS 101 Summer 2009 Homework Assignment 5
Solutions
1. (3 Points) p. 538: 22.2-2 Show the d and values that result from running breadth-first search on the undirected graph below using the following
CMPS 101 Summer 2009 Homework Assignment 8
(practice only, do not turn in)
1. (1 Point) 12.2-1 Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the number
CMPS 101 Summer 2009 Homework Assignment 7
1. (1 Point) Let x V (G ) and suppose that after INITIALIZE-SINGLE-SOURCE(G, s) is executed, some sequence of calls to Relax( ) causes d [ x ] to be set to a
CMPS 101 Summer 2009 Homework Assignment 6
Solutions
1. (1 Point) p.551: 22.4-1 Show the ordering of vertices produced by TOPOLOGICAL-SORT when it is run on the dag of Figure 22.8, under the assumptio
CMPS 101 Summer 2009 Homework Assignment 6
1. (1 Point) p.551: 22.4-1 Show the ordering of vertices produced by TOPOLOGICAL-SORT when it is run on the dag of Figure 22.8, under the assumption of Exerc
CMPS 101 Summer 2009 Homework Assignment 5
1. (3 Points) p. 538: 22.2-2 Show the d and values that result from running breadth-first search on the undirected graph below using the following vertices a
CMPS 101 Summer 2009 Homework Assignment 4
Solutions
1. (3 Points) Consider the function T (n) defined by the recurrence formula
1 n < 3 6 T ( n) = n3 2T ( n / 3 ) + n a. (1 Points) Use the iteration
CMPS 101 Summer 2009
Homework Assignment 4
1. (3 Points) Consider the function T (n) defined by the recurrence formula
1 n < 3 6 T ( n) = n3 2T ( n / 3 ) + n a. (1 Point) Use the iteration method to w
CMPS 101 Summer 2009 Homework Assignment 3
1. (1 Point) The last exercise in the handout entitled Some Common Functions. 4n 2n Use Stirling's formula to prove that = n n . 2. (2 Points) (Exercise 1 fr
CMPS 101 Summer 2009 Homework Assignment 2
Solutions
1. (1 Point) p.50: 3.1-1 Let f (n) and g (n) be asymptotically non-negative functions. Using the basic definition of notation, prove that f (n) + g
CMPS 101 Summer 2009 Homework Assignment 2
1. (1 Point) p.50: 3.1-1 Let f (n) and g (n) be asymptotically non-negative functions. Using the basic definition of notation, prove that f (n) + g (n) = (ma
CMPS 101 Summer 2009 Homework Assignment 1
Solutions
1. (1 Point) p.27: 2.2-2 Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element
CMPS 101 Summer 2009 Homework Assignment 1
1. (1 Point) p.27: 2.2-2 Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[1] .
CMPS 101 Midterm 2 review One solution
Problem 7 from the review sheet: Let G be a directed graph. Prove that if G contains a directed cycle, then G contains a back edge. (Hint: use the white path the
CMPS 101 Midterm 1 Some solutions to review problems and one additional problem
Problem 2 from the Midterm 1 review sheet State whether the following assertions are true or false. If any statements ar
CMPS 101 Algorithms and Abstract Data Types
Recurrence Relations
Iteration Method Recall the following example from the induction handout.
0 T ( n) = T ( n / 2 ) + 1 n =1 n2
We begin by illustrating a
CMPS 101 Summer 2009 Midterm Exam 2
Solutions
1. (20 Points) Let G be a directed graph. Determine whether, at any point during a Depth First Search of G, there can exist an edge of the following kind.
CMPS 101 Algorithms and Abstract Data Types Summer 2009 Midterm Exam 1 Solutions
1. (20 Points) Prove that ( f (n) ( g (n) = ( f (n) g (n) . In other words, if h1 (n) = ( f (n) and h2 (n) = ( g (n) ,
CMPS 101
Midterm 1
Review Problems
1. Let f (n) and g (n) be asymptotically non-negative functions which are defined on the positive integers. a. State the definition of f (n) = O ( g (n) . b. State t
CMPS 101 Algorithms and Abstract Data Types Introduction to Algorithm Analysis Summary of the Theory Side of this Course
Mathematical Preliminaries o Asymptotic growth rates of functions o Some commo
CMPS 101 Algorithms and Abstract Data Types
Induction Proofs
Let P(n) be a propositional function, i.e. P is a function whose domain is (some subset of) the set of integers and whose codomain is the s
CMPS 101 Algorithms and Abstract Data Types Graph Theory
Graphs A graph G consists of an ordered pair of sets G = (V , E ) where V , and E V ( 2) = cfw_2 - subsets of V , i.e. E consists of unordered
CMPS 101 Final Review Problems
1. Let T be a binary tree, and let n(T ) and h(T ) denote its number of nodes and height, respectively. Show that h(T ) lg( n(T ) . (Hint: this was proved in the solutio
CMPS 201 Algorithms and Abstract Data Types
Some Common Functions
We present several common functions and estimates which occur frequently in the analysis of algorithms. Floors and Ceilings Given x R
CMPS 101 Algorithms and Abstract Data Types
Asymptotic Growth of Functions
We introduce several types of asymptotic notation which are used to compare the relative performance and efficiency of algori
CMPS 101 Algorithms and Abstract Data Types
Some Additional Remarks on ADTs and Modules in ANSI C
Suppose you wish to implement an ADT in C. The particular ADT is unimportant, so lets just call it a B