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

Analysis of Algorithm

This document provides an overview of an analysis of algorithms lecture. It introduces the objectives of the course, which are to understand algorithm foundations, analyze algorithms mathematically, and gain familiarity with classical problems. It defines key terms like algorithm, data structure, and algorithmics. It discusses how to analyze algorithms based on input size and the goal of minimizing time and space. Examples of multiplication algorithms are provided and students are assigned to implement a divide and conquer multiplication algorithm.

Uploaded by

Muhammad Atif
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Analysis of Algorithm

This document provides an overview of an analysis of algorithms lecture. It introduces the objectives of the course, which are to understand algorithm foundations, analyze algorithms mathematically, and gain familiarity with classical problems. It defines key terms like algorithm, data structure, and algorithmics. It discusses how to analyze algorithms based on input size and the goal of minimizing time and space. Examples of multiplication algorithms are provided and students are assigned to implement a divide and conquer multiplication algorithm.

Uploaded by

Muhammad Atif
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Lecture 1

(Analysis of Algorithm )
Today’s Agenda
 Objective of the course & Course outline.
 Origin of word: Algorithm
 Teaching Procedure, Material/Resources, Grading.
 Algorithm?
 Data Structure? Algorithmics?
 How do we Analyze?
 Aim of Analysis of Algorithm.
 Hard Problems.
 Examples of some Multiplication Algorithms

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 2


Objective of the course
 Understanding the foundations of algorithms and
use of Data Structures in the development of
application-oriented algorithms.
 Inculcate skills to understand mathematical
notations in algorithms and their simple
mathematical proofs.
 Develop expertise needed for analyzing the
algorithms.
 Gain familiarity with a number of classical
problems that occur frequently in real-world
applications.
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 3
Origin of word: Algorithm
 The word Algorithm comes from the name of the muslim
author Abu Ja’far Mohammad ibn Musa-al-Khowarizmi. He
was born in the eighth century at Khwarizm (Kheva), a
town south of river Oxus in present Uzbekistan. Uzbekistan,
a Muslim country for over a thousand years, was taken over
by the Russians in 1873.
 Much of al-Khwarizmi’s work was written in a book titled al
Kitab al-mukhatasar fi hisab al-jabrwa’l-muqabalah (The
Compendious Book on Calculation by Completion and
Balancing). It is from the titles of these writings and his
name that the words algebra and algorithm are derived. As
a result of his work, al-Khwarizmi is regarded as the most
outstanding mathematician of his time

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 4


Teaching Procedure

 Lectures
 Discussions
 Assignments ( Important )
 Sudden Quizzes
 Mid Term
 Final Exam

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 5


Material / Resources
 Text Book
 “Introductions to Algorithms”, 2nd Edition

by
Thomas H. Cormen
Charles E. Leiserson
Ronald L. Rivest
Clifford Stein

 For other books, view course outline


 WWW
 Any other good book on Algorithm Analysis.
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 6
Grading

 Assignments………………….……………. 05 %
 Quizzes/class participation……………. 10 %
 Project + Presentation ………………… 05 %
 Mid Exam …………………………………… 30 %
 Final Exam …………………………………. 50 %

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 7


What is Algorithm?
 Informally, an algorithm is any well-defined
computational procedure that takes some value
or set of values as input and produce some
value or set of values as output.
or
 We can also view an algorithm as a tool for
solving a well specified computational problem.
or
 We can say algorithm is a sequence of
operations to solve problems correctly.

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 8


Example: Algorithms to sort numbers in
ascending order

Algorithm A

Merge Sort
Unordered List ordered List
Input Output
31,41,59,26,41,58 26,31,41,41,58,59
Insertion Sort

Algorithm B

In above figure the whole set of input numbers are


known as instance of the sorting problem.

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 9


Data Structure
 A Data Structure is a systematic way of
organizing and accessing data with a specific
relationship between the elements, in order to
facilitate access and modifications.

 No single data structure works well for all


purposes, so it is important to be familiar with
pros and cons of several Data Structures.

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 10


Algorithmics
 It is the science that lets designers study and
evaluate the effect of algorithms based on various
factors so that the best algorithm is selected to
meet a particular task in given circumstances.

 It is also the science that tells how to design a


new algorithm for a particular job.

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 11


How do we Analyze?
 Every Algorithm has a parameter N or n that
effects its running time.
 For example, for sorting different numbers the
parameter N is the number of input numbers to
be sorted.

 So for analyzing algorithms our starting point is


to have n or N

N or n shows size of the Input.


December 8, 2021 Instructor:- Mr. Fazl-e-Basit 12
Aim of Analysis of Algorithm
 Primary Concern:
 Time ( i.e. less number of time taken by Algo)
 Space ( i.e. less memory space to be taken)

 Secondary issues:
 Size of instances to be handled
 Type of language to be used for programming

 Type of machine for implementation

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 13


Hard Problems
 Most of the contents of this course are about to
address/discuss algorithms and their efficiency.
Our usual measure of efficiency is speed.

 There are some problems, however, for which no


efficient solution is known.

 We will study few of these kind of problems later


in the course, which are known as NP-Complete
problems.

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 14


PARAMETERS FOR SELECTION OF
AN ALGORITHM
 Priority of Task
 Type of Available Computing Equipment
 Nature of Problem
 Speed of Execution
 Storage Requirement
 Programming Effort
A good choice can save both money and time,
and can successfully solve the problem.
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 15
MULTIPLICATION
(981 x 1234)
981 981
1234 1234
3924 981
2943 1962
1962 2943
981 3924
1210554 1210554
American English
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 16
MULTIPLICATION (981 x 1234)
(a la russe)
981 1234 1234
490 2468
245 4936 4936
122 9872
61 19744 19744
30 39488
15 78976 78976
7 157952 157952
3 315904 315904
1 631808 631808
1210554
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 17
MULTIPLICATION (981 x 1234)
(DIVIDE & CONQUER)
Multiply Shift Result
i) 09 12 4 108 . . . .

ii) 09 34 2 306 . .

iii) 81 12 2 972 . .

iv) 81 34 0 2754

1210554

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 18


MULTIPLICATION (9 x 12)
(DIVIDE & CONQUER)
Multiply Shift Result
i) 0 1 2 0..

ii) 0 2 1 0.

iii) 9 1 1 9.

iv) 9 2 0 18

108

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 19


Assignment No 1
 Implement Multiplication algorithm using
Divide and Conquer approach to multiply any
two integer numbers.

 Use any language or visual language (tool)


of your choice. Due Coming Monday

 Copying assignment is strictly prohibited. If


found, will lead to cancellation of
assignment.
December 8, 2021 Instructor:- Mr. Fazl-e-Basit 20
Thank You ...

December 8, 2021 Instructor:- Mr. Fazl-e-Basit 21

You might also like