Upload
aubrie-cain
View
229
Download
5
Tags:
Embed Size (px)
Citation preview
CS 615: Design & Analysis of
Algorithms
Chapter 1: Introduction, Algorithmic Notation and
Flowcharts
April 20, 2023 CS 615 Design & Analysis of Algorithms 2
Course Content
1.1. IntroductionIntroduction, , Algorithmic Notation and Flowcharts (Brassard & Bratley, Chap. 3)
2. Efficiency of Algorithms (Brassard & Bratley, Chap 2)
3. Basic Data Structures (Brassard & Bratley, Chap. 5)
4. Sorting (Weiss, Chap. 7)5. Searching (Brassard & Bratley, Chap. 9)6. Graph Algorithms (Weiss, Chap. 9)7. Randomized Algorithms (Weiss, Chap. 10)8. String Searching (Sedgewick, Chap. 19)9. NP Completeness (Sedgewick, Chap. 40)
April 20, 2023 CS 615 Design & Analysis of Algorithms 3
Content
Text books, Lectures Assessments
Asymptotic NotationNotation for “the order of”Maximum RuleFlowchartsBasic Flowchart Constructions
April 20, 2023 CS 615 Design & Analysis of Algorithms 4
InstructorYusuf Altunel
Email:[email protected]
Web:http://web.iku.edu.tr/~yaltunel
Tel:(212) 498 42 10
April 20, 2023 CS 615 Design & Analysis of Algorithms 5
Text BooksMain Resources
Data Structures and Algorithm Analysis in C, 2nd Edition; Mark Allen Weiss; Addison Wesley Longman, 1997Fundamentals of Algorithmics; Gilles Brassard & Paul Bratley; Prentice-Hall, 1996.Data Structures, Algorithms & Software Principles, Thomas A. Standish, Addison Wesley, 1995.
Other ResourcesAlgorithms, Richard Johnsonbaugh and Marcus Schaefer, Pearson, 2004, ISBN 0-02-360692-4. http://condor.depaul.edu/~rjohnson/algorithm/index.htmlAlgorithm Design: Foundations, Analysis, and Internet Examples; Michael T. Goodrich & Roberto Tamassia; Wiley, 2002, ISBN 978-0-471-38365-9. http://ww3.algorithmdesign.net/ Algorithms, Robert Sedgewick, Addison-Wesley 1983, e-book.
April 20, 2023 CS 615 Design & Analysis of Algorithms 6
LecturesCourses and labs
Day Hours Location
Theory Thu 11:00-12:45 (2 Hours) Lab 251
Lab Fri 11:00-12:45 (2 Hours) Lab 251
April 20, 2023 CS 615 Design & Analysis of Algorithms 7
Follow up the courseUse the web page of the coursehttp://web.iku.edu.tr/~yaltunel/Spring2005/CS615
Use the email group of the courseSend an empty email to subscribe:
[email protected] To send a message:
[email protected] access on web:
http://groups.yahoo.com/group/CS_615
April 20, 2023 CS 615 Design & Analysis of Algorithms 8
AssessmentParticipation
%10
Project%30
MidTerm%30
Final%40
BonusGrading: %110%10 Bonus
•Please take care of the rules and regulations of the University.
•Otherwise you might be reported to the faculty, as well as lose all bonus options of this course.
April 20, 2023 CS 615 Design & Analysis of Algorithms 9
Project
A real world application with dynamically constructed graph should be implemented until the end of the semester!Details will be announced later!
April 20, 2023 CS 615 Design & Analysis of Algorithms 10
Algorithmic Notation and Algorithmic Notation and Flowcharts (Brassard & Flowcharts (Brassard & Bratley Chp: Chapter 3)Bratley Chp: Chapter 3)
April 20, 2023 CS 615 Design & Analysis of Algorithms 11
Asymptotatic NotationUsed to express
The time taken by an algorithmWithin a multiplicative constant
PermitsSimplification in measuring other tangible things
Deals withThe behavior of functions in the limits
For sufficiently large parameters
An asymptotically superior algorithm is very often preferable
April 20, 2023 CS 615 Design & Analysis of Algorithms 12
Notation for “the order of”f:NR0 be an arbitrary function
from the natural numbersto the nonnegative numbers
The mathematical symbol order of isdenoted by O(f(n))the set of all functions t: NR0 such that
t(n) cf(n) for all nn0
O(f(n))={t: NR0 |(cR+)(nN)[t(n) cf(n)]}Examples
f(n)=n3-3n2-n-8 O(n3)f(n)= n3 O(n3)
Maximum Rule:Let f,g: NR0 be two arbitrary functionsO(f(n),g(n))=O(max(f(n),g(n)))
April 20, 2023 CS 615 Design & Analysis of Algorithms 13
Example for Maximum RuleAn algorithm that proceeds in three steps:
InitializationTake time in O(n2)
ProcessingTake time in O(n3)
FinalizationTake time in O(nlogn)
The complete algorithm takes time inO(n2 + n3 + nlogn)= O(max(n2,n3,nlogn))=O(n3)
April 20, 2023 CS 615 Design & Analysis of Algorithms 14
Results of Maximum RuleIf t(n) is a complicated function
the most significant term of t(n) gives the order of function discarding its coefficient
Example:f(n)= 12n3- 5n2 + logn + 36
O(f(n))=O(n3)
f(n)= 999999n94 - 345n35 + 1O(f(n))=O(n94)
April 20, 2023 CS 615 Design & Analysis of Algorithms 15
Scale of Strength for O-Notation
the relationship between order of functions
O(1) < O(logn) < O(n) < O(nlogn) < O(n2) < O(n3) < O(2n) < O(10n)
O(1)O(logn)
O(n)O(nlogn
)O(n2)O(n3)O(2n)
O(10n)
Higher in order
Mor
e ef
fici
ent
April 20, 2023 CS 615 Design & Analysis of Algorithms 16
ExamplesWhat is the order of 18nlog2n + 19n + 3
=O(18nlog2n + 19n + 3)
=O(max (nlogn, n, 3) )=O(nlogn)
What is the order of n4 + 2n + 3nlogn + 3
=O(n4 + 2n + 3nlogn + 3)=O(max (n4, 2n, nlogn , 3) )=O(2n)
April 20, 2023 CS 615 Design & Analysis of Algorithms 17
Flowcharts
Process
Process
Decision
Data
Terminator
Display
April 20, 2023 CS 615 Design & Analysis of Algorithms 18
Basic Flowchart Constructions
FirstTask
NextTask
Sequence
Cond
ElsePart
ThenPart
F T
Cond
F
T
If Then Else Repeat-Until
April 20, 2023 CS 615 Design & Analysis of Algorithms 19
Basic Flowchart Constructions
Cond1
F
T
CondF
T
Selection (Case) While-Do
Cond2
...
T
Condn
F
T
...
April 20, 2023 CS 615 Design & Analysis of Algorithms 20
Basic Flowchart Constructions
for (i=1; i<n; i++) {..}for (<initialization>; <condition>; <post statement>) <statement>
initialization
Cond
statement
post statement
T
F
For statement
April 20, 2023 CS 615 Design & Analysis of Algorithms 21
Data Flow: Example
End
Cond1
Task2
FT
Start
Task1
Cond2
Task3
Task4
Cond3
FT
TF
StartTask1
if Cond1
thenif Cond2
then Task2
else Task3
else repeatTask4
until Cond3
End
April 20, 2023 CS 615 Design & Analysis of Algorithms 22
Example find Maximum
max<numberF
T
Start
get a number
max= infinitive
max=number
More numbers?T
end
Show max
T
F
Startmax= minimumdo
get a number if (max<number)then max = number
while more numbersshow max
End
April 20, 2023 CS 615 Design & Analysis of Algorithms 23
End of Chapter 1Introduction, Algorithmic Notation and Flowcharts