{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lect15-handout

# Lect15-handout - 15-453 TIME COMPLEXITY OF ALGORITHMS...

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY 15-453 Read sections 7.1 – 7.3 of the book for next time TIME COMPLEXITY OF ALGORITHMS (Chapter 7 in the textbook) COMPLEXITY THEORY Studies what can and can’t be computed under limited resources such as time, space, etc. Today: Time complexity MEASURING TIME COMPLEXITY We measure time complexity by counting the elementary steps required for a machine to halt Consider the language A = { 0 k 1 k | k 0 } 1. Scan across the tape and reject if the string is not of the form 0 m 1 n 2. Repeat the following if both 0s and 1s remain on the tape: Scan across the tape, crossing off a single 0 and a single 1 3. If 0s remain after all 1s have been crossed off, or vice-versa, reject. Otherwise accept. 2k 2k 2 2k

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

View Full Document
The number of steps that an algorithm uses on a particular input may depend on several parameters. For instance, if the input is a graph, then the number of steps may depend on the number of nodes, the number of edges, et cetera . For simplicity, we compute the running time purely as a function of the length of the input string and don’t consider any other parameters. Let M be a TM that halts on all inputs. Assume we compute the running time purely as a function of the length of the input string. Definition: The running time or time-complexity function of M is the function f : N N such that f(n) is the maximum number of steps that M uses on any input of length n. ASYMPTOTIC ANALYSIS 5n 3 + 2n 2 + 22n + 6 = O(n 3 ) Big-O notation has been discussed in previous classes. We will briefly review it. Let f and g be two functions f, g : N R + . We say that f(n) = O(g(n)) if positive integers c and n 0 exist so that for every integer n n 0 f(n) cg(n) When f(n) = O(g(n)), we say that g(n) is an asymptotic upper bound for f(n) BIG- O 5n 3 + 2n 2 + 22n + 6 = O(n 3 ) If c = 6 and n 0 = 10, then 5n 3 + 2n 2 + 22n + 6 cn 3
3n log 2 n + 5n log 2 log 2 n 2n 4.1 + 200283n 4 + 2 n log 10 n 78 = O(n 4.1 ) = O(n log 2 n) = O(n log 10 n) log 10 n = log 2 n / log 2 10 O(n log 2 n) = O(n log 10 n) = O(n log n) Definition: TIME(t(n)) is the set of languages decidable in O(t(n)) time by a Turing Machine.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}