0% found this document useful (0 votes)
62 views41 pages

Advance Theory and Design of Algorithm: Lecture 1: Overview

This document provides an overview of an algorithms course taught by instructor Aqib Perwaiz. The course will cover algorithm basics, analysis of algorithms using asymptotic notation, common data structures, and classical algorithm problems. Students will be evaluated based on exams, assignments, homework and quizzes. The course aims to develop skills in designing correct and efficient algorithms and understanding mathematical proofs of algorithms. Key textbooks are also listed.

Uploaded by

Mubasher Khan
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)
62 views41 pages

Advance Theory and Design of Algorithm: Lecture 1: Overview

This document provides an overview of an algorithms course taught by instructor Aqib Perwaiz. The course will cover algorithm basics, analysis of algorithms using asymptotic notation, common data structures, and classical algorithm problems. Students will be evaluated based on exams, assignments, homework and quizzes. The course aims to develop skills in designing correct and efficient algorithms and understanding mathematical proofs of algorithms. Key textbooks are also listed.

Uploaded by

Mubasher Khan
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/ 41

1

ADVANCE THEORY AND DESIGN


OF ALGORITHM

Lecture 1: Overview
Instructor: Aqib Perwaiz

ABASYN UNIVERSITY
Outline
2

¨  Course Administration

¨  Overview : Algorithm Basics


Administration
3

¨  Instructional E-Mail Addresses


¤  [email protected]

¨  Instructor: Aqib Perwaiz


Administration
4

¨  Grading Policy
Number Activities/ Evaluation Methods Percentages

2 Term Exam 30%


1 Final Exam 25%
6 Assignments & Homework 30%
>=90 A Excellent
80-89 B Very Good
6 Quiz 15% 70-79 C Good
n  Quizzes will be announced in class 60-69 D Passed
<60 F Failed
n  Late Assignment/HW Policy
n  0~24 hrs: -5%
Class participation and
n  24~48 hrs: -10% presentation quality will also
n  >48 hrs: grade = 0 impact final grade
Administration
5

¨  Your Written/Read Responsibilities


¨  Homework
¤  Due at start of class on due date
¤  Emergency arrangements; else hand in early
¨  Term Test;
¨  Final Exam: comprehensive exam.
¨  Course Project and Presentations: student-led reviews/material
integration before exams
¨  Readings from textbooks – read before/after class
Honor Code
6

¨  The Honor Code applies to your conduct in this course. If you have
questions, talk to me
¨  HOMEWORK:
¤  All submitted work must be your own
¤  Do not copy another student’s work
¤  Do discuss material and homework with classmates, professor
¤  If you work with someone, write this on the first page of your
submitted work
¨  EXAMS: Do not give assistance to or receive assistance from anyone
but professor
¨  Violations of this Code are treated seriously
¨  Evidence of cheating, plagiarism, or unauthorized collaboration will
result in a 0 grade for quiz/assignment/exam
¤  May have further consequences
How to get help?
7

¨  Ask questions in class (or after class)


¨  Attend office hours

¨  Email me

¤  Make sure that you put “ College ID number ” in


your subject line
¤  Send it from your offical account
n  It wouldn’t come to my spam folder
¤  State clearly what you need in your email
How to Get an A in this Class?
8

¨  Attendance
¤  Attend class regularly and on time
¤  Ask questions
¤  Work on in-class exercises and labs

¨  Notes
¤  Read over class notes before class
¤  Review class notes after class

¨  Homework
¤  Get started as early as possible
¤  Contact me if you encounter problems
COURSE OBJECTIVES
•  Develop skills needed for designing correct and efficient
algorithms
•  Gain familiarity with a number of classical problems that
occur frequently in real-world applications
•  Inculcate skills to understand mathematical notations in
algorithms and their simple mathematical proofs,
particularly inductive proofs
•  Understand basic data structures and to use them in
algorithms
COURSE OUTLINE
•  Preliminaries : different types of algorithms, notations,
proof techniques, and limits.
•  Elementary Algorithms : problems and instances,
efficiency of algorithms, analysis of algorithms,
examples of algorithms.
•  Asymptotic Notation : different notations and their
graph examples, standard notations and their common
functions.
•  Analysis of Algorithms : analysing control
structures, using barometer instruction, different
examples for analysis and solving recurrences.
COURSE OUTLINE
•  Structures: use of arrays, stacks, queues, records,
pointers, lists, graphs, trees, associate tables, heaps
and binomial heaps.
•  Tree Algorithms: understanding & making trees, and
their algorithms.
•  Heap Algorithms : developing heaps, binomial heaps,
disjoint structures, and their algorithms,
•  Greedy Algorithms : characteristics, minimum
spanning and shortest path algorithms.
Textbooks
Advised:
•  Cormen, Leiserson, Rivest & Stein,
Introduction to Algorithms, 2ndEdition, The MIT
Press, 2001.

•  Brassard & Bratley, Fundamentals of


Algorithmics, Prentice-Hall International, 1999

•  MIT open ware Notes


ALGORITHM
ALGORITHM

A statement of the steps to be followed in


performing a task or solving a problem. In
a computer program the steps of an
algorithm are specified in a specific
computer language. Each step is written
on a new line and stated as briefly as
possible
PHRASES FOR WRITING ALGORITHM
Phrases as mentioned below are used to
link sequences of steps if required:-
(i) if…… then

else
PHRASES FOR WRITING ALGORITHM

(ii) Repeat

until
PHRASES FOR WRITING ALGORITHM

(iii) while …….. do

(iv) do………

while
AN ALGORITHM FOR REPLYING
FRIEND’S LETTER

Read friend’s letter

Decide what to write

Write letter in reply


ALGORITHM TO ACCEPT / REJECT
HOLIDAY
Repeat
Read holiday leaflet
if it is in July
and costs less than Rs 8000
and is at a place not visited before
then Accept the holiday
else Reject the holiday
Until a holiday is accepted
ALGORITHM FOR USING PUBLIC
TELEPHONE
Repeat
Get money ready
Lift receiver
If dialing tone
then Dial number
If number obtainable
and not engaged
then Repeat
wait
Until someone answers
or waited long enough
If answered
then Insert money
ALGORITHM FOR USING PUBLIC
TELEPHONE

If right number
and person you want is available
then Have conversation
Replace receiver
else Replace receiver
Try again later
Until conversation completed
FLOW DIAGRAM SYMBOLS
START or END

process

input or output

decision

connector
FLOWCHART OF REPLYING TO A LETTER
FROM A FRIEND
START

read friend’s letter

decide what to write

write letter in reply

END
START
A
read holiday leaflet

NO
is it in July?
Flowchart
YES
of accepting or
NO
is the cost less rejecting
than RS 8000?

YES
a holiday
YES
has he been
before?

NO

accept holiday Reject holiday

END A
START

get more money


FLOW CHART FOR
USING PUBLIC
try again lift receiver
TELEPHONE
replace receiver NO
dialing tone?

YES
dial number

A
YES Number
unobtainable?
NO
NO
YES
engaged?

wait
is
someone NO
answering? waiting long
enough?
NO
insert money YES
A
continued…… B
A B

NO
right number?

NO is person you
want available?

have conversation

replace receiver

END
TYPE OF ALGORITHMS

•  Probabilistic
•  Approximate
•  Heuristic
PROBABILISITIC ALGORITHM

In this algorithm, chosen values are used


in such a way that the probability of
chosen each value is known and
controlled
For example chosen a number between 1
and 6
APPROXIMATE ALGORITHM

In this algorithm, answer is obtained that


is as précised as required in decimal
notation. In other words it specifies the
error we are willing to accept
For example, two figures accuracy or 8
figures or whatever is required
HEURISTIC ALGORITHM

This type of algorithm is based largely on


optimism and often with minimal
theoretical support. Here error can not be
controlled but may be estimated how
large it is.
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.
CLASSIC MULTIPLICATION ALGORITHMS
(981 x 1234)
981 981
1234 1234

3924 0981
2943 1962
1962 2943

981 3924

1210554 1210554
American English
MULTIPLICATION (981 x 1234)
(a la russe algorithm)
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
MULTIPLICATION (0981 x 1234)
(Divide-and-Conquer Algorithm)

Multiply Shift Result


i) 09 12 4 108….

ii) 09 34 2 306..

iii) 81 12 2 972..

iv) 81 34 0 2754

1210554
MULTIPLICATION (09 x 12)
(Divide-and-Conquer Algorithm)

Multiply Shift Result


i) 0 1 2 0..

ii) 0 2 1 0.

iii) 9 1 1 9.

iv) 9 2 0 18

108
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
NOTATION OF PROGRAMS

• No need of well-structured language


• English phrases are used for simplicity and
clarity
• Mathematical language is used whenever
appropriate
• Algorithm needs effort to transcribe steps
into a computer programming language
NOTATION OF PROGRAMS
• For simplicity:-
– Declarations are omitted
– All variables used in functions or procedures
are implicitly understood as local variable
unless the context makes it clear otherwise
– begin - - - end statements are omitted
– Phrases such if, while, for etc are used to
indent the statements or instructions
– Type of parameters are not declared in
procedures and functions.
NOTATION OF PROGRAMS
– Scalar parameters (treated as local
variable) are passed by value
– Array parameters are passed by
reference
MATHEMATICAL NOTATIONS
Propositional Calculus
(i) Conjunction p Λ q ( p and q)
true if both p & q are true
(ii) Disjunction p V q ( p or q)
true if at least one of p or q is true
(iii) Negation (not p) (¬ p)
true if p is false
(iv) p ⇒ q (if p then q)
(v) p ⇔ q (p = q)
Algorithm for a la russe Method
function russe (m,n)
result 0
repeat
if m is odd then
result result + n
m m÷2
n n+n
until m = 0
return result

You might also like