Complexity Basics - West Virginia...

145
Outline Complexity Basics K. Subramani 1 1 Lane Department of Computer Science and Electrical Engineering West Virginia University February 2, 2015 Basics Computational Complexity

Transcript of Complexity Basics - West Virginia...

Page 1: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Complexity Basics

K. Subramani1

1Lane Department of Computer Science and Electrical EngineeringWest Virginia University

February 2, 2015

Basics Computational Complexity

Page 2: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Outline

1 Review of concepts

2 Problems and Solutions

3 Time, Space and Scaling

4 Intrinsic Complexity

5 Polynomial Time

Basics Computational Complexity

Page 3: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Outline

1 Review of concepts

2 Problems and Solutions

3 Time, Space and Scaling

4 Intrinsic Complexity

5 Polynomial Time

Basics Computational Complexity

Page 4: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Outline

1 Review of concepts

2 Problems and Solutions

3 Time, Space and Scaling

4 Intrinsic Complexity

5 Polynomial Time

Basics Computational Complexity

Page 5: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Outline

1 Review of concepts

2 Problems and Solutions

3 Time, Space and Scaling

4 Intrinsic Complexity

5 Polynomial Time

Basics Computational Complexity

Page 6: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Outline

Outline

1 Review of concepts

2 Problems and Solutions

3 Time, Space and Scaling

4 Intrinsic Complexity

5 Polynomial Time

Basics Computational Complexity

Page 7: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 8: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 9: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.

2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 10: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.

3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 11: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.

4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 12: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.

5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 13: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.

6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 14: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.

7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 15: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.

8 Problem paradigms.

Basics Computational Complexity

Page 16: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Review

Main concepts

1 Alphabet, strings and languages.2 Problems.3 Connection between problems and languages.4 Asymptotics and caclulus.5 Probability and random variables.6 Abstract Algebra.7 Upper and lower bounds.8 Problem paradigms.

Basics Computational Complexity

Page 17: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 18: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 19: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.

2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 20: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.

3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 21: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.

4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 22: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.

5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 23: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.

6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 24: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.

7 Decision and search problems.

Basics Computational Complexity

Page 25: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Problem

Main points

1 Instance of a problem e.g., Eulerian tour.2 Finiteness of instance.3 The Eulerian path problem.4 The Hamilton circuit problem.5 The Chess problem.6 Infinite set of instances.7 Decision and search problems.

Basics Computational Complexity

Page 26: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Solutions

Main points

1 What is a solution?2 What is an algorithm?3 Algorithms as functions.

Basics Computational Complexity

Page 27: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Solutions

Main points

1 What is a solution?2 What is an algorithm?3 Algorithms as functions.

Basics Computational Complexity

Page 28: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Solutions

Main points

1 What is a solution?

2 What is an algorithm?3 Algorithms as functions.

Basics Computational Complexity

Page 29: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Solutions

Main points

1 What is a solution?2 What is an algorithm?

3 Algorithms as functions.

Basics Computational Complexity

Page 30: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Solutions

Main points

1 What is a solution?2 What is an algorithm?3 Algorithms as functions.

Basics Computational Complexity

Page 31: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 32: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 33: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 34: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 35: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 36: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).

2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 37: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive,

as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 38: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.

3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 39: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) =

gcd(b, a mod b).

Basics Computational Complexity

Page 40: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The GCD problem

Definition

Given two positive numbers (integers) a and b, find their greatest common divisor.

Note

1 This problem is referred to as gcd(a, b).2 It is also well-defined when a and b are not positive, as long as both are not zero.3 Euclid observed that gcd(a, b) = gcd(b, a mod b).

Basics Computational Complexity

Page 41: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Euclidean Algorithm

Algorithm

1: FUNCTION GCD(a, b)2: if (b = 0) then3: return (a)4: else5: return (GCD(b, a mod b)).6: end if

Basics Computational Complexity

Page 42: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Euclidean Algorithm

Algorithm

1: FUNCTION GCD(a, b)2: if (b = 0) then3: return (a)4: else5: return (GCD(b, a mod b)).6: end if

Basics Computational Complexity

Page 43: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.2 Adversary.3 Average-case.4 Other ways.

Basics Computational Complexity

Page 44: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.2 Adversary.3 Average-case.4 Other ways.

Basics Computational Complexity

Page 45: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.

2 Adversary.3 Average-case.4 Other ways.

Basics Computational Complexity

Page 46: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.2 Adversary.

3 Average-case.4 Other ways.

Basics Computational Complexity

Page 47: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.2 Adversary.3 Average-case.

4 Other ways.

Basics Computational Complexity

Page 48: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Types of Analysis

How to analyze

1 Worst-case.2 Adversary.3 Average-case.4 Other ways.

Basics Computational Complexity

Page 49: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.3 Notion of input size.4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 50: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.3 Notion of input size.4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 51: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.

2 Notion of space.3 Notion of input size.4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 52: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.

3 Notion of input size.4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 53: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.3 Notion of input size.

4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 54: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.3 Notion of input size.4 Scaling with respect to input size.

5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 55: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Time, Space and Scaling

Main Parameters

1 Notion of time.2 Notion of space.3 Notion of input size.4 Scaling with respect to input size.5 Analysis of the Euclidean algorithm.

Basics Computational Complexity

Page 56: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Intrinsic Complexity

Definition

The intrinsic complexity of a problem is the complexity of the most efficient algorithmthat solves it.

Basics Computational Complexity

Page 57: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Intrinsic Complexity

Definition

The intrinsic complexity of a problem is the complexity of the most efficient algorithmthat solves it.

Basics Computational Complexity

Page 58: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Intrinsic Complexity

Definition

The intrinsic complexity of a problem is the complexity of the most efficient algorithmthat solves it.

Basics Computational Complexity

Page 59: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The integer multiplication problem

Two integer multiplication

Compute the product of two numbers a and b having n digits each.

Basics Computational Complexity

Page 60: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The integer multiplication problem

Two integer multiplication

Compute the product of two numbers a and b having n digits each.

Basics Computational Complexity

Page 61: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The integer multiplication problem

Two integer multiplication

Compute the product of two numbers a and b having n digits each.

Basics Computational Complexity

Page 62: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrenceT (n) = a · T (

nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a, then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 63: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrenceT (n) = a · T (

nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a, then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 64: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrence

T (n) = a · T (nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a, then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 65: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrenceT (n) = a · T (

nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a, then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 66: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrenceT (n) = a · T (

nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a,

then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 67: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Master Method for solving certain recurrences

The Master theorem

Consider the recurrenceT (n) = a · T (

nb

) + f (n).

If f (n) ∈ O(nc), where c < logb a, then T (n) = Θ(nlogb a).

Basics Computational Complexity

Page 68: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 69: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 70: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.

2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 71: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 72: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 73: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires

Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 74: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and

Θ(n2) additions.

Basics Computational Complexity

Page 75: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The Grade school approach

Grade school algorithm

1 Multiply a with each digit of b performing appropriate shifting.2 Add up the individual products.

Note

The above algorithm requires Θ(n2) multiplications and Θ(n2) additions.

Basics Computational Complexity

Page 76: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 77: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 78: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉,

where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 79: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 80: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 81: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b =

10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 82: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u

+ 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 83: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u)

+ y · v .4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to left

shifting.5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 84: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 85: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 86: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 87: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 88: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) =

Θ(n2).

Basics Computational Complexity

Page 89: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An improved algorithm

A slightly more sophisticated approach

1 Let a = 〈x , y〉 and b = 〈u, v〉, where x and u are the first n2 digits of the numbers

a and b respectively.

2 It follows that a = 10n2 · x + y and b = 10

n2 · u + v .

3 Hence, a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

4 Recall that in the decimal algebra, multiplying by powers of 10 is tantamount to leftshifting.

5 Thus, if T (n) is the time taken to multiply two integers, then

T (n) = 4 · T (n2

) + O(n)

6 Solving the above recurrence gives T (n) = Θ(n2).

Basics Computational Complexity

Page 90: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 91: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v =

x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 92: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 93: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 94: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).

2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 95: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u),

using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 96: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 97: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b =

10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 98: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u

+ 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 99: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u)

+ y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 100: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 101: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) =

3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 102: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) =

O(nlog2 3).

Basics Computational Complexity

Page 103: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

An asymptotically superior algorithm

A neat observation

(x + y) · (u + v)− x · u − y · v = x · v + y · u

New algorithm

1 Compute x · u, y · v and (x + y) · (u + v).2 Now compute (x · v + y · u), using the above observation.

3 Finally, compute a · b = 10n · x · u + 10n2 · (x · v + y · u) + y · v .

Analysis

T (n) = 3 · T (n2

) + O(n)

It follows that T (n) = O(nlog2 3).

Basics Computational Complexity

Page 104: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Polynomial versus Exponential

When is computation infeasible?

1 Difference between Θ(n) and Θ(2n) when n doubles.2 n! when n = 20 is larger than the date of the universe.3 The Vishnu Sharma story.

Basics Computational Complexity

Page 105: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Polynomial versus Exponential

When is computation infeasible?

1 Difference between Θ(n) and Θ(2n) when n doubles.2 n! when n = 20 is larger than the date of the universe.3 The Vishnu Sharma story.

Basics Computational Complexity

Page 106: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Polynomial versus Exponential

When is computation infeasible?

1 Difference between Θ(n) and Θ(2n) when n doubles.

2 n! when n = 20 is larger than the date of the universe.3 The Vishnu Sharma story.

Basics Computational Complexity

Page 107: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Polynomial versus Exponential

When is computation infeasible?

1 Difference between Θ(n) and Θ(2n) when n doubles.2 n! when n = 20 is larger than the date of the universe.

3 The Vishnu Sharma story.

Basics Computational Complexity

Page 108: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Polynomial versus Exponential

When is computation infeasible?

1 Difference between Θ(n) and Θ(2n) when n doubles.2 n! when n = 20 is larger than the date of the universe.3 The Vishnu Sharma story.

Basics Computational Complexity

Page 109: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 110: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 111: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm?

Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 112: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!

2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 113: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?

3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 114: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time.

What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 115: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?

4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 116: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex?

Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 117: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.

5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 118: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.

6 Size of instance.

Basics Computational Complexity

Page 119: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Analyzing Euler’s Algorithm

Details

1 How fast is Euler’s algorithm? Details!2 How many times does the main for loop run?3 Measuring running time. What is an elementary step?4 How much time to measure the degree of a vertex? Representation details.5 Tape storage versus RAM storage.6 Size of instance.

Basics Computational Complexity

Page 120: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 121: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 122: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 123: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 124: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.

2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 125: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...

3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 126: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.

4 In general, TIME(f(n)) is the class of problems for which an algorithm exists thatsolves problems of size n, in time TIME(f(n)).

5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 127: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).

5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 128: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).

6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 129: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?

7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 130: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 131: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

The class P

Definition

P is the class of problems for which an algorithm exists that solves problems of size n,in time O(nc) for some constant c.

Note

1 P is a complexity class.2 A problem is not in P, if . . ...3 We include both decision and search problems.4 In general, TIME(f(n)) is the class of problems for which an algorithm exists that

solves problems of size n, in time TIME(f(n)).5 P = ∪c>oTIME(nc).6 Is TIME(nlog n) ⊆ P?7 Defining TIME(f (n)).

8 The class EXP is defined as TIME(2nc).

Basics Computational Complexity

Page 132: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 133: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 134: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.

2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 135: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.

3 Input formats can change within reason.Binary/unary encoding. Buffing up theinput.

4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 136: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.

4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 137: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 138: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Robustness of P

Why P is such a robust class

1 Elementary steps can change within reason.2 Architecture can change within reason.3 Input formats can change within reason.Binary/unary encoding. Buffing up the

input.4 Implementation details can change within reason.

Note

Being in P is a fundamental property of a problem and not dependent upon howsomebody goes about solving it.

Basics Computational Complexity

Page 139: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?3 How practical is O(n10)?4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 140: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?3 How practical is O(n10)?4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 141: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.

2 Does tractability coincide with P?3 How practical is O(n10)?4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 142: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?

3 How practical is O(n10)?4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 143: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?3 How practical is O(n10)?

4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 144: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?3 How practical is O(n10)?4 Sublinear algorithms.

5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity

Page 145: Complexity Basics - West Virginia Universitycommunity.wvu.edu/~krsubramani/courses/sp15/complexity/lecnotes/basics.pdf6 Abstract Algebra. 7 Upper and lower bounds. 8 Problem paradigms.

Review of conceptsProblems and Solutions

Time, Space and ScalingIntrinsic Complexity

Polynomial Time

Tractability and mathematical insight

What is tractable

1 Definition of tractability.2 Does tractability coincide with P?3 How practical is O(n10)?4 Sublinear algorithms.5 Going from Pc to P gives fundamental insight into the nature of problems.

Basics Computational Complexity