Lec02_ComplexityBasicConcept_1

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

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

Concept of Basic Time Complexity Problem size (Input size) Time analysis (A-priori analysis)

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

View Full Document
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)
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

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

View Full Document
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
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

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

View Full Document
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
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?

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

View Full Document
The efficiency of an algorithm depends on the quantity of resources it requires Usually we compare algorithms based on their
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
Ask a homework question - tutors are online