Design and Analysis Algorithms
Lecture 9
Quicksort
A[pq]
q
A[q+1r]
Sort an array A[pr]
Divide
Partition the array A into 2 subarrays A[p.q-1] and A[q+1.r],
such that each element of A[p.q-1] is smaller than each
element in A[q+1.r]
The index (pivot) q

Design and Analysis Algorithm
Lecture 4
Recurrent Algorithms
BINARY SEARCH
for an ordered array A, finds if x is in the array A[lohi]
Alg.: BINARY-SEARCH (A, lo, hi, x)
1
2
3
if (lo > hi)
2 3 5
return FALSE
mid (lo+hi)/2
lo
if x = A[mid]
return TRUE
if (

Design and Analysis of Algorithms
Lecture 2
Algorithm Analysis
The amount of resources used by the algorithm
Space
Computational time
Running time:
The number of primitive operations (steps) executed
before termination
Order of growth
The leading t

Design and Analysis of Algorithms
Fall 2016
Introduction
Lecture 1
Course details
This course is designed for third year undergraduate
students at Princess Sumaya University for Technology
University.
Course Title: Design and Analysis of Algorithms
Course

Design and Analysis of Algorithms
Lecture 7
Insertion Sort
Idea: like sorting a hand of playing cards
Start with an empty left hand and the cards facing
down on the table
Remove one card at a time from the table, and insert
it into the correct position

Design and Analysis
Algorithms
Lecture 10
Background on Trees
Def: Binary tree = structure composed of a finite set
of nodes that either:
Contains no nodes, or
Is composed of three disjoint sets of nodes: a root node, a
left subtree and a right subtree

Design and Analysis Algorithms
Lecture 16
Properties of DFS
u = [v] DFS-VISIT(v) was
called during a search of us
adjacency list
u
v
1/
2/
w
3/
Vertex v is a descendant of vertex u
in the depth first forest v is
discovered during the time in which
u is

Design and Analysis Algorithms
Lecture 15
Graphs
Applications that involve not only a set of items, but also the
connections between them
Maps
Schedules
Hypertext
Computer networks
Circuits
Graphs - Background
Graphs = a set of nodes (vertices) with edge

Design and Analysis Algorithm
Lecture 17
Minimum Spanning Trees
A connected, undirected graph:
Vertices = houses, Edges = roads
A weight w(u, v) on each edge (u, v) E
Find T E such that:
4
1. T connects all vertices
2. w(T) = (u,v)T w(u, v) is
minimized

Design and Analysis Algorithm
Presentation
Assembly Line Scheduling
Dynamic Programming
An algorithm design technique for optimization
problems (similar to divide and conquer)
Divide and conquer
Partition the problem into independent subproblems
Solve

Design and Analysis Algorithms
Presentation
Count Sort, Radix Sort, and Bucket Sort
How Fast Can We Sort?
Insertion sort, Bubble Sort, Selection Sort
Merge sort
(n2)
(nlgn)
Quicksort
(nlgn)
What is common to all these algorithms?
These algorithms sor

Design and Analysis Algorithms
Presentation
Longest Common Subsequence
Longest Common Subsequence
Given two sequences
X = x1, x2, , xm
Y = y1, y2, , yn
find a maximum length common subsequence
(LCS) of X and Y
E.g.:
X = A, B, C, B, D, A, B
Subsequence

CMPS 101
Abstract Data Types
Winter 2003
Programming Assignment 3
Breadth First Search and Shortest Paths in Graphs
Due Thursday February 6, 12:00 midnight
The purpose of this assignment is to implement a Graph ADT and associated algorithms in java. You w