Lec02_ComplexityBasicConcept_1

Lec02_ComplexityBasi - Concept of Basic Time Complexity Problem size(Input size Time analysis(A-priori analysis Problem instances An instance is

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Concept of Basic Time Complexity Problem size (Input size) Time analysis (A-priori analysis)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Problem instances An instance is the actual data for which the problem needs to be solved. In this class we use the terms instance and input interchangeably. Problem: Sort list of records. Instances: (1, 10, 5) (20, -40) (1, 2,3,4, 1000, -27)
Background image of page 2
Instance Size Formally: Size = number of (binary) bits needed to represent the instance on a computer. We will usually be much less formal For sort we assume that the size of a record is a constant number of bits c Formally the size of an input with n records is nc , we use n
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Size Examples Search and sort: Size = n number of records in the list. For search ignore search key Graphs problems: Size = (|V| + |E|) number nodes |V| plus number edges in graph |E|. Matrix problems: Size = r*c number of rows r multiplied by number of columns c
Background image of page 4
Number problems Problems where input numbers can become increasingly large. Examples: Factorial of 10, 10 6 , 10 15 Fibonacci Number operation (e.g., Multiplying, adding) For these problems we should use the formal definition
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Example 1 : addition Add two n-word numbers Algorithm uses n word additions Size = n and algorithm is O(n) 0111 0101 0111 7*8 2 +5*8+7 = 495 0001 0010 0001 1*8 2 +2*8+1 = 81 + 0001 0000 0000 1*8 3 +1*8 2 = 576 0001
Background image of page 6
Example 2: Factorial Compute factorial of an n bit number v . Its value is 2 n - 1 v <2 n v ! = v * v -1 *… * 3 * 2 *1 Algorithm does O( v ) multiplications Size of input = n Example: n = 100 bits (first bit is 1) 2 99 v <2 100 v > 0.6* 10 30 How many multiplications are needed?
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The efficiency of an algorithm depends on the quantity of resources it requires Usually we compare algorithms based on their
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 01/04/2010.

Page1 / 28

Lec02_ComplexityBasi - Concept of Basic Time Complexity Problem size(Input size Time analysis(A-priori analysis Problem instances An instance is

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online