Welcome to Scribd. Sign in or start your free trial to enjoy unlimited e-books, audiobooks & documents.Find out more
Standard view
Full view
of .
0 of .
Results for:
P. 1
Design and Analysis of Algorithms

Design and Analysis of Algorithms

Ratings: (0)|Views: 393|Likes:

Availability:

See more
See less

11/19/2012

pdf

text

original

Design and Analysis of AlgorithmsChapter 1
Design and Analysis of Algorithms -Chapter 11
Algorithm Algorithm
AnAn
algorithmalgorithm
is a sequence of unambiguousis a sequence of unambiguousinstructions for solving a problem, i.e., forinstructions for solving a problem, i.e., forobtaining a required output for any legitimateobtaining a required output for any legitimateinput in a finite amount of time.input in a finite amount of time.

Design and Analysis of Algorithms -Chapter 12
Historical PerspectiveHistorical Perspective
Euclid’s algorithm for finding the greatest common divisorEuclid’s algorithm for finding the greatest common divisor
thth
centurycenturymathematicianmathematicianwww.lib.virginia.edu/science/parshall/khwariz.htmlwww.lib.virginia.edu/science/parshall/khwariz.html

Design and Analysis of Algorithms -Chapter 13
Notion of algorithmNotion of algorithm
“computer”Algorithmic solution problemalgorithminput output
Design and Analysis of Algorithms -Chapter 14
Example of computational problem: sortingExample of computational problem: sorting
Statement of problem:Statement of problem:
Input: Input:
A sequence of A sequence of
nn
numbers <anumbers <a
11
,,aa
22
, …, a, …, a
nn
>>
Output:Output:
A reordering of the input sequence <aA reordering of the input sequence <a
´´11
,,aa
´´22
, …,, …,aa
´´
nn
>>so thatso thataa
´´
aa
´´
j  j
wheneverwhenever
<<
j  j
Instance: The sequence <5, 3, 2, 8, 3>Instance: The sequence <5, 3, 2, 8, 3>
Algorithms:Algorithms:
Selection sortSelection sort
Insertion sortInsertion sort
Merge sortMerge sort
(many others)(many others)
Design and Analysis of Algorithms -Chapter 15
Selection SortSelection Sort
Input: arrayInput: array
a[1],…,[1],…,a[n[n]
Output: arrayOutput: array
a
sorted in nonsorted in non--decreasing orderdecreasing order
Algorithm:Algorithm:for
i
=1 to
n
swap
a[
i
]
with smallest of
a[i],…a[
n
]
Design and Analysis of Algorithms -Chapter 16
Some WellSome Well--known Computational Problemsknown Computational Problems
SortingSorting
SearchingSearching
Shortest paths in a graphShortest paths in a graph
Minimum spanning treeMinimum spanning tree
PrimalityPrimalitytestingtesting
Traveling salesman problemTraveling salesman problem
Knapsack problemKnapsack problem
ChessChess
Towers of HanoiTowers of Hanoi
Program terminationProgram termination