Professional Documents
Culture Documents
Chapter 1: Introduction: Definition of An Algorithm
Chapter 1: Introduction: Definition of An Algorithm
Chapter 1: Introduction
Progress is possible only if we train ourselves to think about programs without thinking of them as pieces of executable code. (Edsger Dijkstra)
Denition of an Algorithm
An algorithm is a sequence of unambiguous instructions for solving a problem in a nite amount of time. An input to an algorithm is an instance of the problem.
Chapter 1: Slide 2
Fundamentals of Algorithmic Problem Solving 6 Design and Analysis Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Algorithm Design Techniques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Important Problem Types 8 Important Problem Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Fundamental Data Structures Abstract Data Types. . . . . . . . . . . . . Linear Data Structures . . . . . . . . . . . Graphs . . . . . . . . . . . . . . . . . . . . . . Trees . . . . . . . . . . . . . . . . . . . . . . . Binary Search Trees . . . . . . . . . . . . . First Child-Next Sibling Representation Sets and Dictionaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 . 9 10 11 12 13 14 15
Chapter 1: Slide 4
Sieve of Eratosthenes
algorithm Sieve(n) // Implements the sieve of Eratosthenes // Input: An integer n > 1 // Output: A list L of all primes n for p 2 to n A[p] true do for p 2 to n do if A[p] then // p is prime add p to the list L j pp while j n do // eliminate multiples of p A[j] false j j+p return L
CS 3343 Analysis of Algorithms Chapter 1: Slide 5
Chapter 1: Slide 6
Stack ADT: push, pop. Queue ADT: enqueue, dequeue. Priority Queue ADT: add item, nd/delete largest.
CS 3343 Analysis of Algorithms Chapter 1: Slide 10
Graphs
Chapter 1: Slide 11
Trees
Chapter 1: Slide 12
Chapter 1: Slide 14
Chapter 1: Slide 13