


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Paper; Class: Analysis Of Algorithms; Subject: Computer Science; University: University of Texas - San Antonio; Term: Unknown 1989;
Typology: Papers
1 / 4
This page cannot be seen from the preview
Don't miss anything!



What is an Algorithm?
Definition of an Algorithm..................................... 2Example: Euclid’s Algorithm................................... 3Pseudocode for Euclid’s Algorithm............................... 4Sieve of Eratosthenes........................................ 5 Fundamentals of Algorithmic Problem Solving
Design and Analysis Steps..................................... 6Algorithm Design Techniques................................... 7 Important Problem Types
Important Problem Types..................................... 8 Fundamental Data Structures
Abstract Data Types......................................... 9Linear Data Structures...................................... 10Graphs................................................. 11Trees.................................................. 12Binary Search Trees........................................ 13First Child-Next Sibling Representation........................... 14Sets and Dictionaries....................................... 15
2
algorithm
is a sequence of unambiguous instructions for solving a problem in a
finite amount of time. An input to an algorithm is an
instance
of the problem.
CS 3343 Analysis of Algorithms
Chapter 1: Slide – 2
solves the problem of finding the greatest common divisor of
two positive integers. ^
The allowed inputs and desired output of the problem must be specified. ^
Each step in the algorithm must be unambiguous. ^
The order of steps must be unambiguous. We will use
pseudocode
in the book’s style.
CS 3343 Analysis of Algorithms
Chapter 1: Slide – 3
Euclid
(m, n
// Computes gcd(
m,^
n) by Euclid’s algorithm
// Input: Two integers
m >
0 and
n^ ≥
// Output: Greatest common divisor of
m^
and
n
if^ n
then return
m
else return
Euclid
(n, m
mod
n)
CS 3343 Analysis of Algorithms
Chapter 1: Slide – 4
Sieve
(n)
// Implements the sieve of Eratosthenes// Input: An integer
n >
// Output: A list
of all primes
n
for p^ ←
2 to
n^ do
p]^ ←
true
for p^ ←
2 to
n⌋^
do
if^ A
[p]^
then
p^ is prime
add
p^ to the list
j^ ←
p^ ∗
p while
j^ ≤
n^ do
// eliminate multiples of
p
A[j
false j^ ←
j^ +
p
return
CS 3343 Analysis of Algorithms
Chapter 1: Slide – 5
Fundamentals of Algorithmic Problem Solving
6
Chapter 1: Slide – 6
Brute Force. Straightforward, naive approach. ^
Divide-and-Conquer. Divide into smaller insts. ^
Decrease-and-Conquer. Decrease instance size. ^
Transform-and-Conquer. Modify instance first. ^
Space and Time Tradeoffs. Use more space now to save time later. ^
Dynamic Programming. Record results of smaller, reoccuring instances. ^
Greedy Technique. Make locally optimal decisions. ^
Iterative Improvement. Improve one change at a time. CS 3343 Analysis of Algorithms
Chapter 1: Slide – 7
Chapter 1: Slide – 12
Chapter 1: Slide – 13
Chapter 1: Slide – 14
is an unordered collection of distinct items. A^ bit vector
can be used to represent a subset of a small set. E.g., 0011010100
might represent the subset
}^ of
A^ multiset
or^
bag
is an unordered collection of items, not necessarily distinct.
A^ list
is an ordered collection of items. Dictionary ADT: add/search for/delete item. CS 3343 Analysis of Algorithms
Chapter 1: Slide – 15