CSE 2320
Test 1
Summer 2009
Name _
Last 4 Digits of Mav ID # _
Multiple Choice. Write your answer to the LEFT of each problem. 3 points each
1. The time to compute the sum of the n elements of an integer array is in:
A. ( n )
C. n 2
B. ( n log n )
D. n 3
CS 3343 (Spring 2013) Assignment 5
Due: Thursday, March 21, before class starts
1. (20 points) Stable sorting and in-place sorting.
Indicate whether the following sorting algorithms are stable and/or in-place. Also, provide their time
complexity (with jus
CSE 2320 Notes 11: Rooted Trees
(Last updated 10/30/11 2:56 PM)
Sedgewick 5.4-5.7, 12.5-12.9
11.A. TREES
Representing Trees (main memory, disk devices in CSE 3330)
Binary tree
C
Key
Mandatory
Left Right
Left
Right
A
D
Optional
B
Parent
Key
Data
Subtree Si
Summer 2011
Long Answer
1. Two int arrays, A and B, contain m and n ints each, respectively. The elements within each of these arrays
appear in ascending order without duplication (i.e. each table represents a set). Give Java code for a algorithm
to find
CS 3343 (Spring 2013) Assignment 4
Due: March 7 before class starts
1. (25 points) Quick sort.
a. (10 points) Study the pseudocode of the Partition algorithm in lecture9.ppt. Using Slide #37 as a
model, illustrate the operation of Partition on array A = [
CS 3343: Analysis of
Algorithms
Lecture 5: Solving recurrence by
recursion-tree method
2/20/2013
1
Problem of the day
How many multiplications do you need to
compute 316?
316 =3 x 3 x 3 . x 3
Answer: 15
316 =38 x 38
38 =34 x 34
Answer: 4
34 =32 x 32
32 =
CS 3343: Analysis of
Algorithms
Lecture 9: Review for midterm 1
Analysis of quick sort
2/20/2013
1
Exam (midterm 1)
Closed book exam
One cheat sheet allowed (limit to a single
page of letter-size paper, double-sided)
Thursday, Feb 21, 9:30 10:45am
Bas
CS 3343: Analysis of
Algorithms
Lecture 10: Heap sort
2/20/2013
1
Heap sort
Another (n log n) sorting algorithm
In practice quick sort wins
The heap data structure and its variants
are very useful for many algorithms
2/20/2013
2
Selection sort
<=
Sorte
CS 3343 (Spring 2013) Assignment 1
Solution
1. (20 points) Order the following functions according to their order of growth from the lowest to the
highest. If you think that two functions are of the same order (i.e f (n) (g(n), put them in the same
group.
CS 3343: Analysis of
Algorithms
Lecture 14: Order Statistics
Order statistics
The ith order statistic in a set of n elements
is the ith smallest element
The minimum is thus the 1st order statistic
The maximum is the nth order statistic
The median is t
CS 3343: Analysis of
Algorithms
Lecture 4: Sum of series, Analyzing
recursive algorithms
2/20/2013
1
Outline
Review of last lecture
Sum of series
Analyzing recursive algorithms
2/20/2013
2
L Hopitals rule
lim f(n) / g(n) = lim f(n) / g(n)
n
2/20/2013
n
CS 3343: Analysis of
Algorithms
Lecture 2: Asymptotic Notations
2/20/2013
1
Outline
Review of last lecture
Order of growth
Asymptotic notations
Big O, big ,
2/20/2013
2
How to express algorithms?
Increasing precision
English
Pseudocode
Real programmi
CS 3343: Analysis of
Algorithms
Lecture 1: Introduction
2/20/2013
Some slides courtesy from Jeff Edmonds @ York University
1
The course
Instructor: Dr. Jianhua Ruan
jruan@cs.utsa.edu
Office: S.B. 4.01.48
Office hours: Tue 12-2pm
TA: Navid Pustch
npu
CS 3343 (Spring 2013) Assignment 7
Due: April 18 (Thur) before class starts
Your name:
Discussed with:
1. (20 points) Use greedy algorithm to solve the fractional knapsack problem: given n items, where each
item has a weight and a value, and a knapsack th
CS 3343 (Spring 2013) Assignment 6
Due: April 4 before class starts
1. (15 points) Hash tables
(a) Demonstrate the insertion of the keys 4, 85, 40, 66, 18, 75, 94, 71, 68, 76 into a hash table with
collision resolved by chaining. Let the table have m = 9
CS 3343 (Spring 2013) Assignment 3
Solution
1. (20 points) Assume that T (1) (1). Solve the following recurrences using the recursion tree method.
a. T (n) = 4T (n/2) + n2
sum
n2
n2
n2/4
n2/16
n2/4
n2/16
n2/4
n2
n2/4
n2
n2/16 n2/16
h = log2n
1
1
n2
Total
CS 3343 (Spring 2013) Assignment 3
Due: Thursday, Februray 7 before class starts
1. (20 points) Assume that T (1) (1). Solve the following recurrences using the recursion tree method.
a. T (n) = 4T (n/2) + n2
b. T (n) = T (n 2) + n
c. T (n) = T (n/2) + T
CS 3343 (Spring 2013) Assignment 2
Solution
1. (20 points) Find the order of growth of the following sums (i.e., is it in (n2 ), (nlgn), or . . . ?) If the
analysis involves multiple steps, write down each intermediate step. (Be succinct, however.)
n
(2i
CS 3343 (Spring 2013) Assignment 2
Due: Jan 31 before class starts
1. (20 points) Find the order of growth of the following sums (i.e., is it in (n2 ), (nlgn), or . . . ?) If the
analysis involves multiple steps, write down each intermediate step. (Be suc
CS 3343: Analysis of
Algorithms
Lecture 15: Hash tables
Hash Tables
Motivation: symbol tables
A compiler uses a symbol table to relate
symbols to associated data
Symbols: variable names, procedure names, etc.
Associated data: memory location, call gra
CS 3343: Analysis of
Algorithms
Lecture 17: Intro to Dynamic
Programming
In the next few lectures
Two important algorithm design techniques
Dynamic programming
Greedy algorithm
Meta algorithms, not actual algorithms (like
divide-and-conquer)
Very use
CS 3343: Analysis of
Algorithms
Lecture 19: Introduction to Greedy
Algorithms
Outline
Review of DP
Greedy algorithms
Similar to DP, not an actual algorithm, but a
meta algorithm
Two steps to dynamic programming
Formulate the solution as a recurrence
r
Common Algorithms
Arrays
sort information -> ex: spreadsheet, itunes (sorting music)
o three different sorting algorithsm (how efficient? why are they called what they're called? how
do we position? how hard is it to write?)
1. bubble sort: start with fir
CSE 2320 Lab Assignment 1
Due September 25, 2014
Goals:
1.
Understanding of binary search.
2.
Understanding of maps/permutations, indirection, and swapping.
Requirements:
1.
Write a C program to maintain n counters indexed by 0 . n-1. n will be the first
CSE 2320
Name _
Test 1
Fall 2011
Last 4 Digits of Mav ID # _
Multiple Choice. Write your answer to the LEFT of each problem. 4 points each
1. The time to compute the sum of the n elements of an integer array is in:
A.
2.
3.
( n )
B.
( n log n )
C.
n 2
D
CSE 2320
Name _
Test 1
Fall 2012
Last 4 Digits of Mav ID # _
Multiple Choice. Write your answer to the LEFT of each problem. 4 points each
1. The time to find the maximum of the n elements of an integer array is in:
A.
2.
( n )
B.
( n log n )
The time to
CSE 2320
Name _
Test 1
Fall 2009
Last 4 Digits of Mav ID # _
Multiple Choice. Write your answer to the LEFT of each problem. 2 points each
t 1
k
1. What is the value of 2 ?
k =0
k B. 2 t 1 C. 2 t +1 1 D. 2 t +1 + 1
A. 2
2.
3.
4.
f ( n ) ( g( n ) . Which o
CSE 2320
Name _
Test 1
Fall 2010
Last 4 Digits of Mav ID # _
Multiple Choice. Write your answer to the LEFT of each problem. 3 points each
1. The time to convert an array, with priorities stored at subscripts 1 through n, to a minheap is in:
A. ( n )
B. (