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!

683 views

Published on

201

No Downloads

Total views

683

On SlideShare

0

From Embeds

0

Number of Embeds

2

Shares

0

Downloads

19

Comments

0

Likes

1

No embeds

No notes for slide

- 1. ALGORITHMwww.eshikshak.
- 2. Introduction to Algorithm● An algorithm is finite set of steps defining the solution of a particular problem.● It can be expressed in English like language, called pseudocode, in programming language or in the form of flowchart. www.eshikshak.co.in
- 3. Characteristics● Input – There are zero or more values which are externally supplied.● Output – At least one value is produced● Definiteness – Each step must be clear and unambiguous● Finiteness – If we trace the steps of an algorithm, then for all cases, the algorithm must terminate after a finite number of steps● Effectiveness – Each step must be sufficiently basic that it can in principal be carried out by a person using only paper and pencil www.eshikshak.co.in
- 4. Algorithm Complexity● There are basically two aspects of computer programming. ○ Data Organization (i.e Data & structure) ○ Algorithm● The choice of a particular algorithm depends on the following consideration : ○ Time Complexity (Performance Requirements) ○ Space Complexity (Memory Requirements) www.eshikshak.co.in
- 5. Space Complexity● It means the amount of memory, algorithm or program needs to run to completion.● Some of the reasons for studying space complexity are ○ If a multi user system ○ Sufficient memory is available to run the program www.eshikshak.co.in
- 6. Space Complexity (Cont.)● The space needed by a program consists of the following components. ○ Instruction Space : Space needed to store the executable version of the program ○ Data Space : Space needed to store all constants, variable values and has further following components ■ Constants, variables, structured variables like array and structure ■ Dynamically allocated space www.eshikshak.co.in
- 7. Space Complexity (Cont.)● Environmental Stack Space : Space needed to store the information needed to resume the suspended functions. ○ Return Address ○ Values of all local variables and the values of formal parameters in the function being involved. www.eshikshak.co.in
- 8. Time Complexity● It means the amount of time it needs to run to completion● Reasons for studying time complexity ○ Interested to know in advance that whether a program will provide a satisfactory real time response ○ There may be several possible solutions with different time requirements www.eshikshak.co.in
- 9. Expressing Space and TimeComplexity● The space and/or time complexity is usually expressed in form of the function f(n) ○ Where n is the input size for a given instance of the problem being solved.● Expressing space and/ or time complexity as a function has following reasons ○ We may be interested to predict the rate of growth of complexity as the size of problem increases. ○ To Compare the complexities of two or more algorithm ○ Since in modern computers, the memory is not a sence constraint, therefore, our analysis of www.eshikshak.co.in algorithms will be on the basis of time complexity.
- 10. Big ‘O’ Notation● Big O is a characterization scheme that allows to measure properties of algorithms such time and space complexity.● It is useful to set the prerequisites of algorithms and to develop and design efficient algorithms in terms of time and space complexity. www.eshikshak.co.in
- 11. Categories of Algorithm● Based on Big O notation, the algorithm can be categorized as follows ○ Constant time O(1) ○ Logarithmic time O(log n) ○ Linear time O(n) ○ Polynomial time O(nk) (for k > 1) ○ Exponentail time O(kn) for k > 1 www.eshikshak.co.in
- 12. Algorithm Analysis● Different ways or algorithms to solve a problem.● Hence, some of the algorithm may be more efficient than the others● There are different types of time complexities which can be analyzed for an algorithm ○ Best Case Time Analysis ○ Average Case Time Analysis ○ Worst Case Time Analysis www.eshikshak.co.in
- 13. Best Case Time Complexity● It is a measure of the minimum time that the algorithm will require for an input of size ‘n’.● The running time of many algorithms varies not only for the inputs of different sizes but also for the different inputs of same size ○ Example : Sorting or Searching www.eshikshak.co.in
- 14. Worst Case Time Complexity● The worst case time complexity of an algorithm is a measure of the maximum time that the algorithm will require for an input of size ‘n’.● Example : If ‘n’ input data items are supplied in reverse order for any sorting algorithm, the algorithm will require n2 operations to perform the sort. www.eshikshak.co.in
- 15. Average Case Time Complexity● The time that an algorithm will require to execute a typical input data of size ‘n’ is known as average case time complexity. www.eshikshak.co.in

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