Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Like this presentation? Why not share!

- Introduction to programming01 by Nadim Ahmed 468 views
- The Burrows-Wheeler Algorithm by Mustafa Salam 317 views
- Intro To Programming Concepts by Jussi Pohjolainen 5391 views
- Lect 1. introduction to programming... by Varun Garg 90645 views
- 1359488656.952program intro flowcharts by rajeshvhadlure01 178 views
- Programming Fundamentals by Hassan293 324 views

No Downloads

Total views

397

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

10

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Introduction to Algorithms By Hanumat Sastry. G
- 2. Two Phases of Programming • A typical programming task can be divided into two phases: • Problem solving phase – produce an ordered sequence of steps that describe solution of problem – this sequence of steps is called an algorithm • Implementation phase – implement the program in some programming language
- 3. 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 3
- 4. Algorithms • 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
- 5. Algorithm Characteristics • Input : Zero or more quantities or externally supplied. • Output: At least one quantity is produced. • Definiteness: Each instruction is clear and unambiguous. • Finiteness: The algorithm should terminate after a finite number of steps. • Effectiveness:
- 6. How to Represent an Algorithm Algorithm can be represented in 3 ways. 1. In Natural Language (English etc…) 2. Pseudo Code. 3. Real Programming Language. Popular representation is Pseudo Code.
- 7. Pseudo Code Convention for Algorithm • Pseudo code consists of keywords and Englishlike phrases which specify the flow control. • Pseudo code representation highlights the Computational aspects by abstracting the implementation details.
- 8. Sum of ‘n’ numbers Algorithm in Natural Language Step 1: Select n number. Step 2: Set sum S to Zero. Step 3: Repeat from first number to nth number i.e S=S+A[i]. Step 4: Return sum (S). Algorithm in Pseudo Code. 1. 2. 3. 4. S<-0 for i<-1 to n S<-S+A[i] return S.
- 9. gcd(m,n) Algorithm-1 while n ≠0 do r ← m mod n m←n n ←r return m Algorithm-2 1. t ← min (m ,n) 2. if m % t = 0 goto 3, else goto 4 3. if n % t = 0 return t, else goto 4 4. t ← t - 1 5. goto 2
- 10. General approaches to algorithm design Divide and conquer Greedy method Dynamic Programming Basic Search and Traversal Technique Graph Theory Linear Programming Approximation Algorithm NP Problem
- 11. Some Applications • Study problems these techniques can be applied to – sorting – data retrieval – network routing – Games – etc
- 12. Computation Models • Turing Machine Model • Random Access Machine (RAM) Model.
- 13. Analysis of Algorithms • The present day algorithms are based on the RAM (Random Access Machine) model. • In RAM model, instructions execute one after another with no, concurrent operations.
- 14. Analysis of Algorithms • Worst Case Complexity • Average Case Complexity • Best Case Complexity
- 15. Worst Case Complexity • The Worst Case Complexity of an algorithm is the function defined by the maximum number of steps taken on any instance size n.
- 16. Best Case Complexity • The best case complexity of the algorithm is the function defined by the minimum number of steps taken on any instance of size n.
- 17. Average Case Complexity • The average case complexity of the algorithm is the function defined by an average number of steps taken on an instance of size n.
- 18. Graphical representation of Worst Case, Average Case and Best Case Complexity
- 19. Exercises • Write an algorithm for product of two matrix • Design an algorithm for finding square of given number • Design an algorithm to find factorial of a number

No public clipboards found for this slide

×
### Save the most important slides with Clipping

Clipping is a handy way to collect and organize the most important slides from a presentation. You can keep your great finds in clipboards organized around topics.

Be the first to comment