Algorithms
Algorithms
(CS3401 – Algorithms)
(Regulation 2021)
Dr. S. Nithyanantham,
Assistant Professor,
School of Engineering,
Computer Science and Engineering,
Presidency University,
Bangalore.
Research scholar,
National Institute of Technology,
Tirchy.
A.R.S. Publications
No. 11, Veerabathra Nagar, Part II,
8th Street, Medavakkam,
Chennai – 600 100, Tamil Nadu, India.
Phone: 044 – 48587467, Mobile: 9840025186
eMail: [email protected]
web: www.arspublications.com
PREFACE
This book “Algorithms” is about analysis of algorithm and its complexity techniques. It helps to
analyse the efficiency of various graph traversal algorithms. It provides the ability to solve various
problems using linear and state space tree approach. It gives an understanding towards various classes of
problems in polynomial and non-polynomial approaches.
Unit I: Introduction towards algorithm analysis with time and space complexities. It provides an
understanding towards asymptotic notations. Contributes a knowledge on several search
and sort algorithms with its efficiency notation.
Unit II: Outline on representing and traversing on graphs. It provides the practical approach
towards the construction of minimum spanning tree and shortest path detection along
with network flow.
Unit III: Transitory awareness on divide and conquer methodology adapted to perform merge and
quick sort. Provides a procedure to perform dynamic programming on matrix-
multiplication, multi-stage graph and optimal binary search trees. Able to understand the
greedy approach and its applicability on problem solving techniques.
Unit IV: Brief knowledge over state space tree approach on the backtracking and branch and
bound techniques. It provides detailed procedures for solving problems n-Queens,
Hamiltonian, Subset sum, Graph colouring, 15-Puzzle, Assignment, Knapsack and
Travelling salesman.
Unit V: Provides a study over tractable and intractable problems with bin packing problem.
Understanding towards problem reduction, approximation and randomized algorithms
with travelling salesman.
ACKNOWLEDGEMENT
Primarily, we would like to thank God. In the process of putting this book together, we realized
how true this gift of writing is for us to share our knowledge. You give us the power to believe in our
passion and pursue our dreams. We could never have done this without the faith we have in you, the
Almighty.
We wholeheartedly thank next God, thy Parents, for showing faith with us and giving us
liberty to choose what we desire. We salute you all for the selfless love, care, pain and sacrifice you did to
shape our life.
We sincerely thank our Colleagues, Friends and Well-wishers for their understanding, patience in
addition, constant encouragement.
Finally, we offer our special thanks to Thiru. A. Ramesh, A. R. S. Publishers and his Colleagues for
their tireless effort in overseeing the production of the book.
The authors would be happy to collect opinion for supplementary improvement of the book.
Dr. S. Nithyanantham
Mrs. R. Shalini
K. Sriram Kumar
Mr. P. Krishna Sankar
CS3401 ALGORITHMS LTPC
3024
UNIT I INTRODUCTION 9
Algorithm analysis: Time and space complexity - Asymptotic Notations and its properties Best
case, Worst case and average case analysis – Recurrence relation: substitution method - Lower
bounds – searching: linear search, binary search and Interpolation Search, Pattern search: The
naïve string matching algorithm - Rabin-Karp algorithm - Knuth-Morris-Pratt algorithm. Sorting:
Insertion sort – heap sort.
INTRODUCTION
1.1 Algorithm analysis 2
1.3 Searching 16
1.5 Sorting 34
UNIT – II
GRAPH ALGORITHMS
2.3 Connectivity 13
2.7 Matching 49
UNIT IV
4.1 Backtracking 2
4.1.1 n-Queen problem 3
UNIT V
NP-COMPLETE AND APPROXIMATION ALGORITHM
5.1.2 NP algorithms 4
5.3.1 TSP 13
5.4 Randomized Algorithms 21