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.

Successfully reported this slideshow.

Like this presentation? Why not share!

- Time and space complexity by Ankit Katiyar 82567 views
- Complexity of Algorithm by Muhammad Muzammal 39242 views
- 19. Algorithms Complexity and Effic... by Intro C# Book 190096 views
- Always have popsicles the handbook ... by Maria Brown 113 views
- RESUME (1) by mukkala eswar 126 views
- ASJAD_CV_BSCS by Asjad Karim 62 views

No Downloads

Total views

817

On SlideShare

0

From Embeds

0

Number of Embeds

3

Shares

0

Downloads

23

Comments

0

Likes

1

No embeds

No notes for slide

- 1. Computational ComplexityKasun Ranga Wijeweera(Email: krw19870829@gmail.com)
- 2. Background• The running time of a program is proportional to someconstant multiplied by one of these terms plus some smallertermsLeading Term + Smaller Terms (Negligible for larger N)
- 3. Examples• N3 + 5 * N2 – 3 * N + 7N3 is the leading term• N = 1083 * N2 and 2 * N3Constant coefficients can be ignored
- 4. Computational Complexity• Here the worst case performance of algorithms is studied• Constant factors are ignored• Determine the functional dependence of the running time
- 5. Definition of Big-Oh Notation• A function g(N) is said to O(f(N)) if there exists constants c0and N0 such that g(N) is less than c0 * f (N) for all N > N0
- 6. Examples• 7 * N - 27 *N – 2 is O (N)Take c0 = 7, N0 = 1• 3 * N3 + 20 * N2 + 53 * N3 + 20 * N2 + 5 is O (N3)Take c0 = 4, N0 = 21• 3 * log N + 53 * log N +5 is O (log N)Take c0 = 11, N0 = 2
- 7. Problem• 7 * N – 2 < N2Take c0 = 7, N0 = 1?
- 8. Growth Rate• Functions in order of increasing growth rate is as follows 1 log N N N log N N2 N3 2N
- 9. Examples of Algorithm Running Times• Min element of an array: O (N)• Closest points in the plane,i.e. smallest distance pairs: N (N - 1)/2 O (N2)
- 10. Comparing Algorithms Experimentally• Implement each algorithm– Lots of work– Error prone• Run it with sample data• Count the time– Same hardware and software are used
- 11. A Sample C Programvoid main (){clrscr ();clock_t start, end;start = clock ();delay (1000);end = clock();cout << “Time = ” << (end - start);getch();}
- 12. Required Header Files# include <conio.h># include <fstream.h># include <dos.h># include <time.h>
- 13. Reference
- 14. Any Questions?
- 15. Thank You!

No public clipboards found for this slide

Be the first to comment