SlideShare a Scribd company logo
Lecture 1
1
Design and Analysis of Algorithms
Adnan Rashid
Adnan Rashid
CS-251: Design and
Analysis of Algorithms
(Spring 2023)
Email: adnan.rashid@seecs.edu.pk
Web: http://save.seecs.nust.edu.pk/adnanrashid/
Outline
▪ Course Objectives
▪ Introduction
▪ Assessment Plan
▪ What is an algorithm?
▪ About us
▪ General Instructions
2
Design and Analysis of Algorithms
Adnan Rashid
▪ Algorithm vs Program
▪ Properties of Algorithms
Lecture’s Content
Introduction to Algorithms (4th Edition) by
Thomas H. Cormen et al.
Section 1.1 (Page 28 onwards)
3
Design and Analysis of Algorithms
Adnan Rashid
Objectives of Course
Objective 1: Understand the operation, implementation
and performance of fundamental algorithms and data
structures, and the relative merits and suitability of each
for various applications
4
Design and Analysis of Algorithms
Adnan Rashid
Objective 2: Ability to model and implement efficient
software solutions for various application areas using
appropriately selected algorithms and data structures
Objective 3: Ability to analyze data structures and
algorithms, to compare and evaluate them with respect to
time and space requirements, in order to make the most
appropriate design choices when solving real-world problems
Algorithm Definition
▪ An algorithm is a step-by-step procedure for solving a
particular problem in a finite amount of time
▪ More generally, an algorithm is any well-defined
computational procedure that takes collection of elements
as input and produces a collection of elements as output
5
Design and Analysis of Algorithms
Adnan Rashid
Input
X
Some mysterious
processing
Output
Y = F(X)
ALGORITHM
F: X→Y
Algorithm: Examples
6
Design and Analysis of Algorithms
Adnan Rashid
▪ Repairing a lamp
▪ Matrix multiplication
▪ Calling a friend on the phone
▪ The rules of how to play a game
▪ Directions for driving from A to B
▪ A car repair manual
▪ Human brain project
▪ Internet and communication links (Graphs)
▪ A cooking recipe
Algorithm vs Program
▪ A computer program is an instance, or concrete representation,
for an algorithm in some programming language
▪ Set of instructions, which the computer follows to solve a problem
Problem
High Level
Language
Program
Algorithm: A sequence of
instructions describing
how to do a task
7
Design and Analysis of Algorithms
Adnan Rashid
Solving Problems
8
Design and Analysis of Algorithms
Adnan Rashid
When faced with a problem:
1. First clearly define the problem
2. Think of possible solutions
3. Select the one that seems the best under the prevailing
circumstances
4. And then apply that solution
5. If the solution works as desired, fine; else go back to
Step 2
Solving Problems:
General Solution-Algorithm
9
Design and Analysis of Algorithms
Adnan Rashid
▪ It is quite common to first solve a problem for a
particular case
▪ Then for another
▪ And, possibly another
▪ And watch for patterns and trends that emerge
▪ And to use the knowledge from these patterns and
trends in coming up with a general solution
▪ And this general solution is called an algorithm
One Problem, Many
Algorithms
10
Design and Analysis of Algorithms
Adnan Rashid
Problem
▪ The statement of the problem specifies, in general
terms, the desired input/output relationship
Algorithm
▪ The algorithm describes a specific computational
procedure for achieving input/output relationship
▪ Sorting a sequence of numbers into non-decreasing order
Example
▪ Various algorithms e.g., merge sort, quick sort, heap
sorts etc.
Algorithms
Problem Instances
11
Design and Analysis of Algorithms
Adnan Rashid
▪ An input sequence is called an instance of a Problem
▪ A problem has many particular instances
▪ An algorithm must work correctly on all instances of
the problem it claims to solve
▪ Many interesting problems have infinitely many
instances
▪ Since computers are finite, we usually need to limit the
number and/or size of possible instances in this case
▪ This restriction doesn’t prevent us from doing analysis
in the abstract
Properties of Algorithms
12
Design and Analysis of Algorithms
Adnan Rashid
▪ It must be composed of an ordered sequence of precise
steps
▪ It must have a finite number of well-defined instructions
/steps
▪ The execution sequence of instructions should not be
ambiguous
▪ It must be correct
▪ It must terminate
Syntax and Semantics
13
Design and Analysis of Algorithms
Adnan Rashid
An algorithm is “correct” if
its:
▪ Semantics are correct
▪ Syntax is correct
Semantics:
▪ The concept embedded in
an algorithm (the soul!)
Syntax:
▪ The actual representation
of an algorithm (the body!)
WARNINGS:
1. An algorithm can be
syntactically correct,
yet semantically
incorrect – dangerous
situation!
2. Syntactic
correctness is easier
to check as compared
to semantic
correctness
Algorithm Summary
14
Design and Analysis of Algorithms
Adnan Rashid
▪ Problem Statement
▪ Relationship between the input and output
▪ Algorithm
▪ Procedure to achieve the relationship
▪ Definition
▪ A sequence of steps that transform the input to output
▪ Instance
▪ The input needed to compute solution
▪ Correct Algorithm
▪ For every input it halts with correct output
About Us
▪ Instructor
▪ Dr. Adnan Rashid (A-226, Faculty Block, SEECS)
▪ Contact: adnan.rashid@seecs.edu.pk
▪ Telephone: +92 51 9085 2176
▪ Web: http://save.seecs.nust.edu.pk/adnanrashid/
https://seecs.nust.edu.pk/faculty/adnan-rashid/
15
Design and Analysis of Algorithms
Adnan Rashid
Course Updates
▪ Updates (on LMS, Email):
▪ Updates and Discussions (on WhatsApp):
https://tinyurl.com/yckj3x52
16
Design and Analysis of Algorithms
Adnan Rashid
Course Updates
17
Compiler Construction
Adnan Rashid
▪ Office Hours: By appointment only (via email)
▪ Code for Course Self Enrollment on LMS:
183750294
Class Schedule, LMS and
CMS
18
Compiler Construction
Adnan Rashid
▪ Consult LMS for
▪ Lecture Notes, Quizzes, Assignments and Labs
▪ Online Feedback
Day BESE-12B
Thursday 0900-1000 (Lecture Hall–IAEC)
Thursday 1000-1100 (Lecture Hall–IAEC)
Friday 1000-1100 (CR-20–SMRIMMS)
▪ Consult Qalam for
▪ Attendance and grades
Attendance Policy
19
Compiler Construction
Adnan Rashid
▪ 75-100% required at the end of semester!
▪ No compensation for attendance!
▪ Attendance will be taken at any moment
Textbook
20
Compiler Construction
Adnan Rashid
▪ Thomas H. Cormen,
Introduction to Algorithms
(4th edition) 2022, MIT
Press
Assessment Plan
(Tentative)
21
Compiler Construction
Adnan Rashid
▪ 40% Final Exam (Closed Books, Closed Notes, Comprehensive)
▪ 30% Mid Term (Closed Books, Closed Notes, Comprehensive)
▪ 10% Quizzes (Minimum 05, Surprise!)
▪ 10% Project
▪ 10% Assignments (Minimum 03)
Homework/Assignment
Policy
22
Compiler Construction
Adnan Rashid
▪ All homework assignments must be done individually
or as directed
▪ May also require uploading a soft-copy on LMS (for
plagiarism check)
▪ Cheating
▪ Helping others, getting help, looking up websites for
solutions etc.
▪ Late Submissions
▪ Late submission will get a –20% penalty up to one day
▪ -40% penalty up to 2 days (No acceptation after 2
days from deadline)
Homework/Assignment
Policy
23
Compiler Construction
Adnan Rashid
▪ Any deviation from the above rule will be considered
cheating and will be subject to the SEECS academic
dishonesty policy
▪ Contact instructor at least 03 days before the
deadline in case of emergency
http://seecs.nust.edu.pk/Internal/downloads/downloads/SE
ECS_Plagiarism_Policy_Dec2010_v1.0.pdf
Lecture Basics
24
Compiler Construction
Adnan Rashid
▪ Classes will mainly involve Slides
▪ Lectures (pdf) will be available on LMS
▪ However, no scribes from the class will be made
available
▪ Therefore, take your own notes in the class
▪ For latest/updated slides, download before each use
▪ As I might update/correct slides at any stage
Thank you!
25
Design and Analysis of Algorithms
Adnan Rashid

More Related Content

PDF
CSC446: Pattern Recognition (LN4)
PPTX
PRML Chapter 6
PDF
Pca ppt
PPTX
Solving the traveling salesman problem by genetic algorithm
PDF
Csc446: Pattren Recognition (LN1)
PDF
Towards Causal Representation Learning
PPTX
Backpropagation And Gradient Descent In Neural Networks | Neural Network Tuto...
PPTX
Diabetes prediction with r(using knn)
CSC446: Pattern Recognition (LN4)
PRML Chapter 6
Pca ppt
Solving the traveling salesman problem by genetic algorithm
Csc446: Pattren Recognition (LN1)
Towards Causal Representation Learning
Backpropagation And Gradient Descent In Neural Networks | Neural Network Tuto...
Diabetes prediction with r(using knn)

What's hot (20)

PDF
genetic algorithms-artificial intelligence
PDF
Locality Sensitive Hashing By Spark
PDF
Generative Adversarial Networks : Basic architecture and variants
PPTX
Mc Culloch Pitts Neuron
PDF
Lecture 9 Markov decision process
PDF
Applying Deep Learning to Transform Breast Cancer Diagnosis
PPTX
Hyperparameter Tuning
PDF
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
PDF
Introduction to Neural Networks
PPTX
Graph Representation Learning
PDF
Visual Explanation of Ridge Regression and LASSO
PDF
Neural Networks: Introducton
PPTX
Fuzzy logic andits Applications
PDF
Neural Networks: Multilayer Perceptron
PPTX
Kernel Method
PPTX
PRML Chapter 1
PDF
Simulated Annealing
PPTX
Decision trees for machine learning
PPT
Pattern Recognition
PPTX
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
genetic algorithms-artificial intelligence
Locality Sensitive Hashing By Spark
Generative Adversarial Networks : Basic architecture and variants
Mc Culloch Pitts Neuron
Lecture 9 Markov decision process
Applying Deep Learning to Transform Breast Cancer Diagnosis
Hyperparameter Tuning
Data Science - Part XII - Ridge Regression, LASSO, and Elastic Nets
Introduction to Neural Networks
Graph Representation Learning
Visual Explanation of Ridge Regression and LASSO
Neural Networks: Introducton
Fuzzy logic andits Applications
Neural Networks: Multilayer Perceptron
Kernel Method
PRML Chapter 1
Simulated Annealing
Decision trees for machine learning
Pattern Recognition
What Is Deep Learning? | Introduction to Deep Learning | Deep Learning Tutori...
Ad

Similar to Lecture_01_Spring_2023.pdf (20)

PDF
Design and analysis of algorithms
PPTX
Binary to hexadecimal algorithmic old.pptx
PDF
Lecture 1 (bce-7)
PPTX
Algo_Lecture01.pptx
PPTX
Data Structures_Introduction to algorithms.pptx
PPT
Unit 1 chapter 1 Design and Analysis of Algorithms
PPTX
Lecture 1.pptx
PDF
Algorithms Lecture 1: Introduction to Algorithms
PPSX
Ds03 part i algorithms by jyoti lakhani
PPT
Lec1.ppt
PPT
l01-intro (3).ppt
PDF
Lecture 2 role of algorithms in computing
PPT
Types of Algorithms.ppt
PDF
lect 1-ds algo(final)_2.pdf
PPTX
3733-lecture-1_design-and-analysis-of-algorithms.pptx
PPTX
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
PPTX
Chapter 1 Data structure.pptx
PPTX
Module 1 python.pptx
PDF
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
Design and analysis of algorithms
Binary to hexadecimal algorithmic old.pptx
Lecture 1 (bce-7)
Algo_Lecture01.pptx
Data Structures_Introduction to algorithms.pptx
Unit 1 chapter 1 Design and Analysis of Algorithms
Lecture 1.pptx
Algorithms Lecture 1: Introduction to Algorithms
Ds03 part i algorithms by jyoti lakhani
Lec1.ppt
l01-intro (3).ppt
Lecture 2 role of algorithms in computing
Types of Algorithms.ppt
lect 1-ds algo(final)_2.pdf
3733-lecture-1_design-and-analysis-of-algorithms.pptx
ANALYSIS AND DESIGN OF ALGORITHMS -M1-PPT
Chapter 1 Data structure.pptx
Module 1 python.pptx
01 Revision Introduction SLides Od Design ANd Aalaysis Of aLgo
Ad

Recently uploaded (20)

PDF
Well-logging-methods_new................
PPTX
Construction Project Organization Group 2.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Digital Logic Computer Design lecture notes
PPTX
Artificial Intelligence
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
PPT on Performance Review to get promotions
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
web development for engineering and engineering
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
additive manufacturing of ss316l using mig welding
PPTX
OOP with Java - Java Introduction (Basics)
Well-logging-methods_new................
Construction Project Organization Group 2.pptx
CH1 Production IntroductoryConcepts.pptx
Digital Logic Computer Design lecture notes
Artificial Intelligence
Foundation to blockchain - A guide to Blockchain Tech
CYBER-CRIMES AND SECURITY A guide to understanding
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPT on Performance Review to get promotions
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
web development for engineering and engineering
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
additive manufacturing of ss316l using mig welding
OOP with Java - Java Introduction (Basics)

Lecture_01_Spring_2023.pdf

  • 1. Lecture 1 1 Design and Analysis of Algorithms Adnan Rashid Adnan Rashid CS-251: Design and Analysis of Algorithms (Spring 2023) Email: adnan.rashid@seecs.edu.pk Web: http://save.seecs.nust.edu.pk/adnanrashid/
  • 2. Outline ▪ Course Objectives ▪ Introduction ▪ Assessment Plan ▪ What is an algorithm? ▪ About us ▪ General Instructions 2 Design and Analysis of Algorithms Adnan Rashid ▪ Algorithm vs Program ▪ Properties of Algorithms
  • 3. Lecture’s Content Introduction to Algorithms (4th Edition) by Thomas H. Cormen et al. Section 1.1 (Page 28 onwards) 3 Design and Analysis of Algorithms Adnan Rashid
  • 4. Objectives of Course Objective 1: Understand the operation, implementation and performance of fundamental algorithms and data structures, and the relative merits and suitability of each for various applications 4 Design and Analysis of Algorithms Adnan Rashid Objective 2: Ability to model and implement efficient software solutions for various application areas using appropriately selected algorithms and data structures Objective 3: Ability to analyze data structures and algorithms, to compare and evaluate them with respect to time and space requirements, in order to make the most appropriate design choices when solving real-world problems
  • 5. Algorithm Definition ▪ An algorithm is a step-by-step procedure for solving a particular problem in a finite amount of time ▪ More generally, an algorithm is any well-defined computational procedure that takes collection of elements as input and produces a collection of elements as output 5 Design and Analysis of Algorithms Adnan Rashid Input X Some mysterious processing Output Y = F(X) ALGORITHM F: X→Y
  • 6. Algorithm: Examples 6 Design and Analysis of Algorithms Adnan Rashid ▪ Repairing a lamp ▪ Matrix multiplication ▪ Calling a friend on the phone ▪ The rules of how to play a game ▪ Directions for driving from A to B ▪ A car repair manual ▪ Human brain project ▪ Internet and communication links (Graphs) ▪ A cooking recipe
  • 7. Algorithm vs Program ▪ A computer program is an instance, or concrete representation, for an algorithm in some programming language ▪ Set of instructions, which the computer follows to solve a problem Problem High Level Language Program Algorithm: A sequence of instructions describing how to do a task 7 Design and Analysis of Algorithms Adnan Rashid
  • 8. Solving Problems 8 Design and Analysis of Algorithms Adnan Rashid When faced with a problem: 1. First clearly define the problem 2. Think of possible solutions 3. Select the one that seems the best under the prevailing circumstances 4. And then apply that solution 5. If the solution works as desired, fine; else go back to Step 2
  • 9. Solving Problems: General Solution-Algorithm 9 Design and Analysis of Algorithms Adnan Rashid ▪ It is quite common to first solve a problem for a particular case ▪ Then for another ▪ And, possibly another ▪ And watch for patterns and trends that emerge ▪ And to use the knowledge from these patterns and trends in coming up with a general solution ▪ And this general solution is called an algorithm
  • 10. One Problem, Many Algorithms 10 Design and Analysis of Algorithms Adnan Rashid Problem ▪ The statement of the problem specifies, in general terms, the desired input/output relationship Algorithm ▪ The algorithm describes a specific computational procedure for achieving input/output relationship ▪ Sorting a sequence of numbers into non-decreasing order Example ▪ Various algorithms e.g., merge sort, quick sort, heap sorts etc. Algorithms
  • 11. Problem Instances 11 Design and Analysis of Algorithms Adnan Rashid ▪ An input sequence is called an instance of a Problem ▪ A problem has many particular instances ▪ An algorithm must work correctly on all instances of the problem it claims to solve ▪ Many interesting problems have infinitely many instances ▪ Since computers are finite, we usually need to limit the number and/or size of possible instances in this case ▪ This restriction doesn’t prevent us from doing analysis in the abstract
  • 12. Properties of Algorithms 12 Design and Analysis of Algorithms Adnan Rashid ▪ It must be composed of an ordered sequence of precise steps ▪ It must have a finite number of well-defined instructions /steps ▪ The execution sequence of instructions should not be ambiguous ▪ It must be correct ▪ It must terminate
  • 13. Syntax and Semantics 13 Design and Analysis of Algorithms Adnan Rashid An algorithm is “correct” if its: ▪ Semantics are correct ▪ Syntax is correct Semantics: ▪ The concept embedded in an algorithm (the soul!) Syntax: ▪ The actual representation of an algorithm (the body!) WARNINGS: 1. An algorithm can be syntactically correct, yet semantically incorrect – dangerous situation! 2. Syntactic correctness is easier to check as compared to semantic correctness
  • 14. Algorithm Summary 14 Design and Analysis of Algorithms Adnan Rashid ▪ Problem Statement ▪ Relationship between the input and output ▪ Algorithm ▪ Procedure to achieve the relationship ▪ Definition ▪ A sequence of steps that transform the input to output ▪ Instance ▪ The input needed to compute solution ▪ Correct Algorithm ▪ For every input it halts with correct output
  • 15. About Us ▪ Instructor ▪ Dr. Adnan Rashid (A-226, Faculty Block, SEECS) ▪ Contact: adnan.rashid@seecs.edu.pk ▪ Telephone: +92 51 9085 2176 ▪ Web: http://save.seecs.nust.edu.pk/adnanrashid/ https://seecs.nust.edu.pk/faculty/adnan-rashid/ 15 Design and Analysis of Algorithms Adnan Rashid
  • 16. Course Updates ▪ Updates (on LMS, Email): ▪ Updates and Discussions (on WhatsApp): https://tinyurl.com/yckj3x52 16 Design and Analysis of Algorithms Adnan Rashid
  • 17. Course Updates 17 Compiler Construction Adnan Rashid ▪ Office Hours: By appointment only (via email) ▪ Code for Course Self Enrollment on LMS: 183750294
  • 18. Class Schedule, LMS and CMS 18 Compiler Construction Adnan Rashid ▪ Consult LMS for ▪ Lecture Notes, Quizzes, Assignments and Labs ▪ Online Feedback Day BESE-12B Thursday 0900-1000 (Lecture Hall–IAEC) Thursday 1000-1100 (Lecture Hall–IAEC) Friday 1000-1100 (CR-20–SMRIMMS) ▪ Consult Qalam for ▪ Attendance and grades
  • 19. Attendance Policy 19 Compiler Construction Adnan Rashid ▪ 75-100% required at the end of semester! ▪ No compensation for attendance! ▪ Attendance will be taken at any moment
  • 20. Textbook 20 Compiler Construction Adnan Rashid ▪ Thomas H. Cormen, Introduction to Algorithms (4th edition) 2022, MIT Press
  • 21. Assessment Plan (Tentative) 21 Compiler Construction Adnan Rashid ▪ 40% Final Exam (Closed Books, Closed Notes, Comprehensive) ▪ 30% Mid Term (Closed Books, Closed Notes, Comprehensive) ▪ 10% Quizzes (Minimum 05, Surprise!) ▪ 10% Project ▪ 10% Assignments (Minimum 03)
  • 22. Homework/Assignment Policy 22 Compiler Construction Adnan Rashid ▪ All homework assignments must be done individually or as directed ▪ May also require uploading a soft-copy on LMS (for plagiarism check) ▪ Cheating ▪ Helping others, getting help, looking up websites for solutions etc. ▪ Late Submissions ▪ Late submission will get a –20% penalty up to one day ▪ -40% penalty up to 2 days (No acceptation after 2 days from deadline)
  • 23. Homework/Assignment Policy 23 Compiler Construction Adnan Rashid ▪ Any deviation from the above rule will be considered cheating and will be subject to the SEECS academic dishonesty policy ▪ Contact instructor at least 03 days before the deadline in case of emergency http://seecs.nust.edu.pk/Internal/downloads/downloads/SE ECS_Plagiarism_Policy_Dec2010_v1.0.pdf
  • 24. Lecture Basics 24 Compiler Construction Adnan Rashid ▪ Classes will mainly involve Slides ▪ Lectures (pdf) will be available on LMS ▪ However, no scribes from the class will be made available ▪ Therefore, take your own notes in the class ▪ For latest/updated slides, download before each use ▪ As I might update/correct slides at any stage
  • 25. Thank you! 25 Design and Analysis of Algorithms Adnan Rashid