0% found this document useful (0 votes)
6 views

Session-1 & Session-2

The document provides an overview of algorithms, including their correctness, efficiency, and various design techniques such as divide and conquer and dynamic programming. It discusses the process of understanding problems, designing algorithms, proving correctness, and analyzing efficiency. Additionally, it covers important problem types and fundamental data structures used in algorithm design.

Uploaded by

integrasbiotek
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)
6 views

Session-1 & Session-2

The document provides an overview of algorithms, including their correctness, efficiency, and various design techniques such as divide and conquer and dynamic programming. It discusses the process of understanding problems, designing algorithms, proving correctness, and analyzing efficiency. Additionally, it covers important problem types and fundamental data structures used in algorithm design.

Uploaded by

integrasbiotek
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/ 18

The Design and

Analysis of Algorithms
Understanding Algorithms
◼ Correctness

◼ Efficiency
◼ Asymptotic Complexity, O() notation

◼ Modelling
◼ Graphs, Data Structures, Decomposing the Problems

◼ Techniques
◼ Divide and Conquer, Greedy, Dynamic Programming
2
Motivation

3
Abstract Level

4
Efficiency ?
◼ N cities F direct flights

◼ Dependency

◼ Online Booking requires response in


seconds

5
CHAPTER 1: INTRODUCTION

◼ What is an Algorithm
◼ Steps in Designing and Implementing
an Algorithm
◼ Important Problem Types
◼ Fundamental Data Structures

6
ALGORITHM

◼A sequence of unambiguous
instructions for solving a
problem, i.e. for obtaining the
required output for any
legitimate input in
a finite amount of time
7
Important points
◼ Non-ambiguity
◼ Range of inputs
◼ The same algorithm can be
represented in different ways
◼ Several algorithms for solving
the same problem

8
gcd(m,n)

while n ≠0 do 1. t ← min (m ,n)


r ← m mod n
m←n 2. if m % t = 0 goto 3,
n ←r else goto 4
return m
3. if n % t = 0 return t,
else goto 4

4. t ← t - 1
5. goto 2

9
Understand the problem

Decide on computational means


Exact vs approximate solution
Data structures
Algorithm design technique

Design an algorithm

Prove correctness

Analyze the algorithm

Code the algorithm

10
What does it mean to understand
the problem?
◼ What are the problem objects?
◼ What are the operations applied to the objects?

Deciding on computational means


◼ How the objects would be represented?
◼ How the operations would be implemented?

11
Design an algorithm

• Build a computational model of the


solving process
Prove correctness
• Correct output for every legitimate
input in finite time
• Based on correct math formula
• By induction 12
Analyze the algorithm
Efficiency: time and space
Simplicity
Generality: range of inputs, special cases
Optimality:
no other algorithm can do better
Coding
How the objects and operations in the
algorithm are represented in the chosen
programming language? 13
Important problem types
◼ Sorting
◼ Searching
◼ String processing
◼ Graph problems
◼ Combinatorial problems
◼ Geometric problems
◼ Numerical problems

14
Fundamental data structures

Linear data structures


◼ Array
◼ Linked list
◼ Stack
◼ Queue

Operations: search, delete, insert


Implementation: static, dynamic
15
Fundamental data structures

Non-linear data structures


◼ Graphs
◼ Trees : connected graph without cycles
 Rooted trees
◼ Ordered trees

Binary trees

Graph representation: adjacency lists,


adjacency matrix
Tree representation: as graphs; binary nodes
16
Fundamental data structures

Sets, Bags, Dictionaries


◼ Set: unordered collection of distinct elements
Operations: membership, union, intersection
Representation: bit string; linear structure
◼ Bag: unordered collection,
elements may be repeated
◼ Dictionary: a bag with operations search,
add, delete

17
Conclusion
◼ Algorithm classification
◼ By types of problems
◼ By design technique

◼ Design techniques
◼a general approach to solving problems

18

You might also like