0% found this document useful (0 votes)
76 views48 pages

L01-02 - 8.11.2022 - Introduction To Algorithms and Roadmap of This Course

The document outlines the introduction to an algorithms course. It discusses the instructor, Md. Sabir Hossain, and provides an agenda for the course including an overview of algorithms in life, their applications and necessity, algorithm basics, an example sorting algorithm, expected outcomes, and references. The course aims to teach students to design, analyze, compare, implement, and improve algorithms to solve computational problems.

Uploaded by

Samia Rahman
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)
76 views48 pages

L01-02 - 8.11.2022 - Introduction To Algorithms and Roadmap of This Course

The document outlines the introduction to an algorithms course. It discusses the instructor, Md. Sabir Hossain, and provides an agenda for the course including an overview of algorithms in life, their applications and necessity, algorithm basics, an example sorting algorithm, expected outcomes, and references. The course aims to teach students to design, analyze, compare, implement, and improve algorithms to solve computational problems.

Uploaded by

Samia Rahman
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/ 48

CSE-243

Algorithms Design & Analysis

Introduction to Algorithms & Lecture


Road Map of this course 01
Instructor
Md. Sabir Hossain
Assistant Professor
Dept. of Department of Computer Science & Engineering
Chittagong University of Engineering & Technology (CUET)
Keep in mind

“Your skills of dealing with


others determine how they
deal with you.”
Enjoy Your Life, Sheikh Abdur Rahman Al Arifi, Page-31

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Course Teachers
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Agenda
• About the Course Teachers
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
About the Course Teachers

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Algorithms in Life, How?

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Why Study Algorithms?

• Internet: Web search, packet routing, distributed file sharing, ...


• Biology: Human genome project, protein folding, ...
• Computers: Circuit layout, file system, compilers, ...
• Computer graphics: Movies, video games, virtual reality, ...
• Security: Cell phones, e-commerce, voting machines, ...
• Multimedia: MP3, JPG, DivX, HDTV, face recognition, ...
• Social networks: Recommendations, news feeds, advertisements, ...
• Physics: N-body simulation, particle collision simulation, …

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Computer Science is About Problem Solving

• A Problem is specified by
1. The givens (a formulation)
• A set of objects
• Relations between them
2. The query
• The information one is trying to extract from the formulation, the question to answer
• An algorithm is a method or procedure that solves instances of a
problem
• ‘Algorithm’ is a distortion of Al-Khawarizmi, a Persian mathematician
Real World  Computing World
Objects represented by… data Structures, ADTs, Classes
Relations implemented with… relations & functions (e.g., predicates)
Actions Implemented with… algorithms: a sequence of instructions
Algorithms Basic: Formal Definition

• Definition: An algorithm is a sequence of


unambiguous instructions for solving a problem.
• Properties of an algorithm
• Finite: the algorithm must eventually terminate
• Complete: Always give a solution when one exists
• Correct (sound): Always give a correct solution
• For an algorithm to be an acceptable solution to a problem, it must
also be effective. That is, it must give a solution in a ‘reasonable’
amount of time
• Efficient= runs in polynomial time. Thus, effective efficient
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Algorithms Basic: Example
• There can be many algorithms to solve the same problem.
• Consider Sorting problem.
• Some elements before sorting: 6 5 3 1 8 7 2 4
• After sorting: 1 2 3 4 5 6 7 8

Bubble Sort Insertion Sort Selection Sort


Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Comparisons
Sorting Nearly Sorted Random Reversed
Algorithms

Bubble Sort

Insertion Sort

Selection Sort
Algorithms Basic: Sorting

Sorting Algorithms
Non-
Comparisons Sort Comparis
ons Sort
Merge
insert
Cockt
Insert Selec Odd- ion Count
Bubbl Quick Heaps Shells Merge Intros ail Cycle Smoo Timso Radix Bucke
ion tion even (Ford- ing
e Sort sort ort ort sort ort shake sort thsort rt sort t sort
sort sort sort Johns sort
r sort
on)
sort

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Algorithms: Sorting

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Expected Outcome from this course
• At the end of this course, Student will able to
– Design Algorithms to solve any Computational Problems (by class lectures and
performing assignments)
– Analyze the proposed Algorithms by Standard Way
(Mathematically) (by class lectures and assignments)
– Compare alternative solutions to any specific problems to select
the best one (by class lectures)
– Implement Algorithms to solve Competitive Programming
Challenges (by practice and contest lab)
– Discover new era of Algorithmic implementation (by doing capstone projects)
– Modify/Improve/Propose effective and efficient algorithms to existing
ones (by research work)
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Project and research performed by the undergraduate students
• Book References
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Algorithms Basic: Classification
• There are many broad • Some general styles of
categories of algorithms algorithms include
• Deterministic versus • Brute force (enumerative
Randomized techniques, exhaustive search)
• Exact versus Approximation • Divide & Conquer
• Sequential/serial versus • Transform & Conquer
Parallel, etc. (reformulation)
• Greedy Techniques
• Backtracking
• Dynamic Programming
• Graph Algorithms
Overview

Algorithms
Analysis Designs Paradigm

Solving Sorting
Asympto Dynamic Sorting & Graph
Recurren and Divide & Greedy Backtrac
tic Program Searchin Algorith
ce Searchin Conquer Method king
Analysis ming g ms
Relations g
Algorithms Basic: Sorting

Sorting Algorithms
Non-
Comparisons Sort Comparis
ons Sort
Merge
Cock insert
Bubb Hea Merg Inser Sele Odd- tail Cycl ion Smo Coun Radi Buck
Quic Shell Intro Tims
le psor e tion ction even shak e (Ford- oths ting x et
ksort sort sort sort Johns ort
Sort t sort sort sort er sort ort sort sort sort
sort on)
sort

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Divide & Conquer
Binary Search

Merge Sort

Quick Sort

Calculate pow(x, n)

Divide & Conquer


Closest Pair of Points

Strassen’s Matrix Multiplication

Karatsuba algorithm for fast multiplication

Count Inversions

Multiply two polynomials

Tiling Problem

Convex Hull (Simple Divide and Conquer Algorithm)

Quickhull Algorithm for


Convex Hull

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Sorting and Searching

Searching & Sorting Searching

Linear Binary Ternary


Sorting
Search Search Search

Non-
Compariso
Compariso
ns Sort
ns Sort

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Greedy Method
Activity Selection Problem

Egyptian Fraction
Lists Based Job Sequencing Problem

Huffman Coding
Greedy Method

Efficient Huffman Coding for sorted input

Kruskal’s Minimum Spanning Tree

Prim’s Minimum Spanning Tree

Boruvka’s Minimum Spanning Tree

Reverse delete algorithm for MST


Graph Based Dijkastra’s Shortest Path Algorithm

Dial’s Algorithm

Dijkstra’s Algorithm for Adjacency List


Representation

Prim’s MST for adjacency list representation

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Backtracking

Backtracking
The Knight’s
Rat in a N Queen m Coloring Hamiltonian Solving
Print all tour Subset Sum Sudoku Tug of War
Maze Problem Problem Cycle Cryptarithm
permutation problem
etic Puzzles
s of a given
string

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Dynamic programming

Dynamic programming

Program Bellman
Longest Longest Longest Floyd
Matrix 0-1 for –Ford Largest
Increasi Commo Edit Palindro Warshal Ugly Subset
Coin Chain Knapsac Fibonac Algorith Indepen Tiling
ng n Distanc mic l Number Sum
Change Multipli k ci m for dent Set Problem
Subsequ Subsequ e Subsequ Algorith s Problem
cation Problem number Shortest Problem
ence ence ence m
s Paths

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Graph Algorithms

Graph Algorithm
DFS and BFS Minimum Spanning Tree

Check Applicatio Prim’s Boruvka’s


Breadth Depth Bi- Prim’s Kruskal’s
whether a ns of MST for algorithm
First First Snake and connecte Minimum Minimum
Detecting Longest Topologic given Minimum Adjacency for
Traversal Traversal Ladder d Spanning Spanning
Cycle Path al Sorting graph is Spanning List Minimum
for a for a Problem Compone Tree Tree
Bipartite Tree Represent Spanning
Graph Graph nt (MST) Algorithm
or not Problem ation Tree

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Graph Algorithms

Graph Algorithm

Shortest Path Connectivity

Dijkstra’ Tarjan’s
Johnson Articulat Fleury’s Algorith
Dijkstra’ s
’s Shortest ion Algorith Strongly Euler m to
s Algorith Bellman Floyd Biconne
algorith Path in Points Biconne Bridges Eulerian m for Connect Circuit find
shortest m for –Ford Warshall cted
m for Directed (or Cut cted in a path and printing ed in a Strongly
path Adjacen Algorith Algorith Compon
All-pairs Acyclic Vertices graph graph circuit Eulerian Compon Directed Connect
algorith cy List m m ents
shortest Graph ) in a Path or ents Graph ed
m Represe
paths Graph Circuit Compon
ntation
ents

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Graph Algorithms

Graph Algorithm

Maximum Flow Hard Problems

Find Vertex
Ford- maximum Travelling
Fulkerson Graph Travelling Cover K Centers
number of Find Salesman
Algorithm Coloring Greedy Salesman Problem Problem
edge minimum Maximum Channel Problem
for (Introducti Algorithm Problem Hamiltonia (Introducti (Greedy
disjoint s-t cut in a Bipartite Assignment (Naive and
Maximum on and for Graph (Approxim n Cycle on and Approxima
paths flow Matching Problem Dynamic
Flow Application Coloring ate using Approxima te
between network Programmi
Problem s) MST) te Algorithm)
two ng)
Algorithm)
vertices

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Prerequisite Knowledge: Data Structure
• Book References
• Project and research performed by the undergraduate students

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Prerequisite Knowledge: Data Structure

• Concepts and examples • Graphs,


of elementary data • heaps,
objects,
• Btrees,
• elementary data
structures, • Fibonacci heaps,
• array, • Recursion,
• stacks and • Memory management,
• queues. • Sorting and searching,
• Lists, • hash techniques.
• Trees,
Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Prerequisite Knowledge: Data Structure
• Book References
• Project and research performed by the undergraduate students

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Textbooks

• Algorithms, 4th • Introduction to  Fundamentals of Computer


Edition by Robert Algorithms, Third Algorithms, Second Edition,
Sedgewick and Edition (International Ellis Horowitz, Sanguthevar
Kevin Wayne, Edition), Thomas H.
Rajasekaran, Sartaj Sahni,
Addison-Wesley Cormen, Charles E.
Leiserson, Ronald L. ISBN 10: 8173716129 / ISBN
Professional,
2011, ISBN 0-321- Rivest, Clifford Stein, 13: 9788173716126, Published
57351-X. ISBN-13: 978- by Universities Press/Orient
0262033848. BlackSwan, 2008.
Book Site

• Lecture slides.
• Download code.
• Summary of content.

http://algs4.cs.princeton.edu

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Ref. Books

• (Lecture Notes Series on Computing) M H Alsuwaiyel- Algorithms


Design Techniques and Analysis -World Scientific Publishing
Company (2016)
• Anany Levitin, Introduction to the Design and Analysis of
Algorithms, 3rd Edition
• Steven S Skiena-The Algorithm Design Manual-Springer (2010)

11/8/2022

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


Agenda
• About the Instructor
• Algorithms in Life, How?
• Applications/Necessity of Algorithms
• Algorithm Basics
• Example: Sorting Algorithm
• Expected Outcome from this course
• Road Map of this Course
• Prerequisite Knowledge: Data Structure
• Book References
• Project and research performed by the undergraduate students

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


References

• https://visualgo.net/en/sorting
• https://www.cs.usfca.edu/~galles/visualization/Algorithms.html
• https://www.toptal.com/developers/sorting-algorithms/insertion-
sort
• https://www.geeksforgeeks.org/insertion-sort/
• Introduction to Algorithms, Third Edition (International Edition),
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, Clifford
Stein, ISBN-13: 978-0262033848.
• https://www.hackerearth.com/practice/algorithms/sorting/insertion
-sort/practice-problems/
• https://www.codechef.com/problems/SOPC03
Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.
Allah Hafez & Best Wishes

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.


What is research?

https://www.westernsydney.edu.au/research/researchers/preparing_a_grant_applicati
on/dest_definition_of_research#:~:text=Research%20is%20defined%20as%20the,to%20ne
w%20and%20creative%20outcomes.

Md. Sabir Hossain, Asst. Professor, Dept. of CSE, CUET.

You might also like