0% found this document useful (0 votes)
23 views121 pages

DAABook

Uploaded by

jeevitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views121 pages

DAABook

Uploaded by

jeevitha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 121

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/305440962

Design and Analysis of Algorithms

Book · July 2012

CITATIONS READS

2 365

1 author:

Digambar Padulkar
Vidya Pratishthan’s, College of Engineering, Baramati
5 PUBLICATIONS 2 CITATIONS

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Electricity Transformer Life Time Estimation with Association Rule Mining View project

All content following this page was uploaded by Digambar Padulkar on 20 July 2016.

The user has requested enhancement of the downloaded file.


Knapsack Subset Job Knapsack
Problem Selection Sequencing Problem

n-Queen Backtracking Branch Traveling


Problem Algorithms and Bound Salesman

Traveling Big O
Salesman

Design and
Knapsack Dynamic Asymptotic
Problem Programming
Analysis of Notations
Thet
Algorithms

Multistage
Omega Ω
Graph

Divide and
Greedy Sorting
Conquer Techniques
Algorithms
Algorithms

Job
Sequencing
Problems
Image Data
Processing Mining
Knapsack Algorithms Algorithms
Problems
2
Contents

1 Dynamic Programming 5
1.1 Principle of optimality:- . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Optimal Binary Search Tree(OBST) . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Multistage Graph . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.5 0/1 Knapsack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
1.6 Travelling Sales Person Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
1.7 Flow Shop Scheduling Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

2 Backtracking Algorithms 35
2.1 4-Queens Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.2 Graph Coloring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.3 Graph Coloring-4 nodes- 3 -colors . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.4 Hamiltonian Cycle/Circuit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
2.5 0/1 Knapsack with Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
2.5.2 Solved example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

3 Branch and Bound Algorithms 65


3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.2 Job Sequencing Problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
3.3 LC-Branch and Bound for 0/1 Knapsack . . . . . . . . . . . . . . . . . . . . . . . 70
3.4 FIFO-Branch and Bound for 0/1 Knapsack . . . . . . . . . . . . . . . . . . . . . 73
3.5 Branch and Bound-Traveling Salesman Problem . . . . . . . . . . . . . . . . . . . 73

4 NP-Completeness 79
4.1 NP-Completeness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1.1 Satisfiability Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
4.1.2 Node Cover Decision Problem . . . . . . . . . . . . . . . . . . . . . . . . . 87
4.1.3 Chromatic Number Decision Problem . . . . . . . . . . . . . . . . . . . . 91
4.2 NP-Hard Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
4.3 Cooks Theorem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

5 Parallel Algorithms 111

3
4 CONTENTS
1

Dynamic Programming

Dynamic programming is an algorithm that can be used when the solution to the problem
can be viewed as result of sequence of decisions. In dynamic programming there is possibility
of getting many more sub sequences, they are not leading to the optimal result. some of them
many satisfy the required criteria(principle of optimality) but not resulting as whole sequence
as optimal one.

1.1 Principle of optimality:-


Whatever initial stage decisions are, the remaining decisions must contribute to the optimal
decision sequence with regards to the state resulting from the first decision.
The problems can be solved by dynamic programming are Multistage graph, Optimal Binary
Search Tree(OBST), 0/1 Knapsack, Travelling salespersons Problem(TSP) etc. The problems
above stated are illustrated as bellow one by one.

1.2 Introduction

5
1.3. OPTIMAL BINARY SEARCH TREE(OBST) 7

1.3 Optimal Binary Search Tree(OBST)


14 CHAPTER 1. DYNAMIC PROGRAMMING

1.4 Multistage Graph


1.5. 0/1 KNAPSACK 19

1.5 0/1 Knapsack


1.6. TRAVELLING SALES PERSON PROBLEM 23

1.6 Travelling Sales Person Problem


28 CHAPTER 1. DYNAMIC PROGRAMMING

1.7 Flow Shop Scheduling Problem


34 CHAPTER 1. DYNAMIC PROGRAMMING
2

Backtracking Algorithms

2.1 4-Queens Problem

35
2.2. GRAPH COLORING 39

2.2 Graph Coloring


44 CHAPTER 2. BACKTRACKING ALGORITHMS

2.3 Graph Coloring-4 nodes- 3 -colors


2.4. HAMILTONIAN CYCLE/CIRCUIT 47

2.4 Hamiltonian Cycle/Circuit


52 CHAPTER 2. BACKTRACKING ALGORITHMS

2.5 0/1 Knapsack with Backtracking


2.5.1 Introduction
0/1 knapsack with backtracking approach is a maximization problem like a 0/1 knapsack problem
with dynamic programing. The maximization of the knapsack means to maximize the profit
by satisfying the constraint of weight gained in the knapsack. This can be represented in
mathematical terms as nX
P = xi p i (2.1)
i=0

This function must be maximized by satisfying following constraints


n
X
W = x i wi ≤ m (2.2)
i=0

Where xi takes value 0 or 1 (0 not selected the item 1 selected item)


Assume that there is set of items as S
We are forming a set s as a solution set which is subset of S

s⊆S (2.3)

2.5.2 Solved example


64 CHAPTER 2. BACKTRACKING ALGORITHMS
3

Branch and Bound Algorithms

3.1 Introduction

3.2 Job Sequencing Problem

65
70 CHAPTER 3. BRANCH AND BOUND ALGORITHMS

3.3 LC-Branch and Bound for 0/1 Knapsack


3.4. FIFO-BRANCH AND BOUND FOR 0/1 KNAPSACK 73

3.4 FIFO-Branch and Bound for 0/1 Knapsack

3.5 Branch and Bound-Traveling Salesman Problem


78 CHAPTER 3. BRANCH AND BOUND ALGORITHMS
4

NP-Completeness

4.1 NP-Completeness
4.1.1 Satisfiability Principles

79
4.1. NP-COMPLETENESS 87

4.1.2 Node Cover Decision Problem


4.1. NP-COMPLETENESS 91

4.1.3 Chromatic Number Decision Problem


98 CHAPTER 4. NP-COMPLETENESS

4.2 NP-Hard Problems


4.3. COOKS THEOREM 101

4.3 Cooks Theorem


110 CHAPTER 4. NP-COMPLETENESS
5

Parallel Algorithms

111
View publication stats

You might also like