Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fundamentals of Algorithms MCS - 2 Lecture # 1

Similar presentations


Presentation on theme: "Fundamentals of Algorithms MCS - 2 Lecture # 1"— Presentation transcript:

1 Fundamentals of Algorithms MCS - 2 Lecture # 1

2 prerequisites Data Structures Discrete Mathematics

3 Course Resources Compulsory Reading Material
Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest & Clifford Stein (3rd Edition) Recommended Reading Fundamentals of Computer Algorithms by Eillies Horowitz & Sahni Sartaj (1990) Fundamentals of Algorithms by Gilles Brassard & Paul Bratley (1995) Algorithms; Fourth Edition by Robert Sedgewick & Kevin Wayne.

4 The Role of Algorithms in Computing

5 Problem Solving Programming is a process of problem solving
Problem solving techniques Analyze the problem Outline the problem requirements Design steps (algorithm) to solve the problem Algorithm: Step-by-step problem-solving process Solution achieved in finite amount of time

6 Problem Solving Process
Step 1 - Analyze the problem Outline the problem and its requirements Design steps (algorithm) to solve the problem Step 2 - Implement the algorithm Implement the algorithm in code Verify that the algorithm works Step 3 - Maintenance Use and modify the program if the problem domain changes

7 Analyze the Problem Thoroughly understand the problem
Understand problem requirements Does program require user interaction? Does program manipulate data? What is the output? If the problem is complex, divide it into subproblems Analyze each subproblem as above

8 Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) Problems can be in any form Business Allocate manpower to maximize profit Real Life If I go 10 steps forward, I will reach my mailbox. I am hungry. How do I order pizza? Explain how to tie shoelaces to a five year old child

9 Application of algorithm in comp. science areas
Compiler construction Operating system Databases AI Graphics Networking

10 Algorithm & programming
The idea behind the computer program It is a mathematical entity of a program. Stays the same independent of Which kind of hardware it is running on Which programming language it is written in Solves a well-specified problem in a general way Is specified by Describing the set of instances (input) it must work on Describing the desired properties of the output

11 What is an algorithm? (Cont’d)
Before a computer can perform a task, it must have an algorithm that tells it what to do. Informally: “An algorithm is a set of steps that define how a task is performed.” Formally: “An algorithm is an ordered set of unambiguous executable steps, defining a terminating process.” Ordered set of steps: structure! Executable steps: doable! Unambiguous steps: follow the directions! Terminating: must have an end!

12 Good vs. Bad Algorithms All algorithms will have input, perform a process, and produce output. A good algorithm should be: Simple - relative Complete – account for all inputs & cases Correct (Right) should have appropriate levels of Abstraction. – grouping steps into a single module Precise Mnemonic - SCRAP

13 Simplicity Simple can be defined as having no unnecessary steps and no unnecessary complexity. (You may lose points if your algorithm contains unnecessary steps) Each step of a well developed algorithm should carry out one logical step of the process. Avoid something like: “Take 2nd right after you exit at King Street”

14 It has Levels of Abstraction.
Example: Add all the scores then divide the sum by the number of students to get the average.

15 Precision Precision means that there is only one way to interpret the instruction. Unambiguous Words like “maybe”, “sometimes” and “occasionally” have no business in a well developed algorithm. Instead of “maybe”, we can specify the exact circumstances in which an action will be carried out.

16 Algorithm as tool It can be viewed as tool for solving “Computational Problem” The algorithm describes a specific Computational Procedure for achieving that relationship between Input and Output. Input<32,22,45,66,12,44> sorting algorithm returns output<12,22,32,44,45,66> Input instance (Satisfying constraints , compute solution) Correct Algorithm provides correct Output

17 Other algorithm attributes
A good algorithm should be correct. A good algorithm should be complete. “To be correct, an algorithm must produce results that are correct and complete given any and all sets of appropriate data.” And to be correct, an algorithm must proceed through to a conclusion.

18 Important Properties of Algorithms / (Criterion for analyzing algorithms)
Correct always returns the desired output for all legal instances of the problem. Unambiguous Precise Efficient Can be measured in terms of Running Time Memory Space Sometimes tends to be more important

19 Problem solved by Algorithms
The Human Genes Project(HGP); sorting info in database, developing tools for analyzing data).enabling Scientists to accomplish tasks efficiently. Manipulating and managing large volume of data on internet sites with Clever algorithms. Numerical algorithms and number theory is helping E-Commerce to ensure the privacy of personal info. Manufacturing and commercial enterprises use algorithms. For example politician, oil company, airline. Model of Road map(shortest path) Mechanical designs

20 assignment # 1 Write an algorithm to call your friend.
Give a real world example that requires Sorting for its solution? Write an algorithm for searching ‘Algorithm’s text book’ from Library? How does one get to see the film “THREE IDIOTS” in cinema?

21 Good Luck ! ☻


Download ppt "Fundamentals of Algorithms MCS - 2 Lecture # 1"

Similar presentations


Ads by Google