Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Algorithm Complexity Bit Sum Problem.

Similar presentations


Presentation on theme: "Introduction to Algorithm Complexity Bit Sum Problem."— Presentation transcript:

1 Introduction to Algorithm Complexity Bit Sum Problem

2 Rol Exposition Polynomial problem of practice 1 Queues Stacks Hash tables in C++ Representing graphs Representing Trees Transverse a binary tree The role of algorithms in computing ( Cormen) Algorithms as a technology

3 Evaluation Skills 10-15 minutes time exposition 5 minutes questions ( evaluate different groups) When applicable the source of a solution description of the problem Charts and draw support in presentation Presentations and code should be uploaded in claroline

4 Pre-Assignment Read chapter one of the book “Introduction to algorithms” Author: Thomas Cormen.

5 Definition The time complexity of a program (for a given input) is the number of elementary instructions that this program executes. This number is computed with respect to the size n of the input data. Thomas Cormen. Introduction to algorithms

6 Definition The space complexity of a program (for a given input) is the number of elementary objects that this program needs to store during its execution. This number depends on n.

7 Exercise ¿Why do you think is important to understand the time and the space complexity? – Write a little paragraph an examples about that.

8 Importance of complexity analysis The algorithm or the programming language? C++ is faster than Java I don’t care about the programming language Note: An O(nlogn) algorithm in Java will probably be faster than a O(n 2 ) algorithm in C++

9 Problem Definition Count the number of ones in an n-bit string B=b n b n-1 …b 2 b 1

10 Solution c  0 for i=1 to n do if b i = 1 then c  c+1 Number of steps = n Memory Space= 1

11 Is possible going Faster? c  0 While B ≠ 0 do c  c +1 B  B ∧ (B-1) Try 11001000 Time Complexity=? Message Complexity=?

12 Is possible going faster? Divide and conquer – Try 11010001 Time Complexity=? Message Complexity=?

13 Is possible going faster Is possible to get an O(1) time algorithm? – What about the space complexity?

14 Exercises Write formally the definition of time and space complexity Describe a real world example of a problem in which is important to get an optimal algorithm approach to get the solution Implement one of the optimal in time solutions to the bit sum problem.


Download ppt "Introduction to Algorithm Complexity Bit Sum Problem."

Similar presentations


Ads by Google