- 1984 Vitter Faster Random Sampling
- HW5 Solutions
- Chapter 1 Quiz_ CET501f13 Applied Networking I
- Mat516 Computational-techniques Th 1.00 Ac18
- Closest Pair
- Big O.pdf
- Quiz Progress Test Answers
- Ada
- RF1902B46
- Discrete Math explained
- wireless networks quiz
- chp4_q16
- Oral quiz questions and answers
- Lecture 1asd`a
- Analysisda
- MELJUN CORTES Midterm Exam ITC16
- Flow-After-flow Tests for Gas Wells
- Howto Sorting
- shellsort
- test
- 230_MAP6_sol (1)
- Recurrence Tree
- CS502QuizSolvedForFinalTermPreparation (1)
- Stack
- C2 09 Jun Mark Scheme
- 6675_01_que_20080618.pdf
- DS Lab Manual[1]
- Log Probs
- file c++
- Growth Chondrostoma Regium
- Advanced MFC
- Microsoft Foundation Classes 3
- Advanced Edge Detection Techniques-b
- 3_f05_mfc_appwin
- 06 Introduction to Mfc

(how fast does an algorithm grow with respect to N) (Note: Best recollection is that a good bit of this document comes from C++ For You++, by Litvin & Litvin) The time efficiency of almost all of the algorithms we have discussed can be characterized by only a few growth rate functions: I.

O(l) - constant time

This means that the algorithm requires the same fixed number of steps regardless of the size of the task. Examples (assuming a reasonable implementation of the task): A. Push and Pop operations for a stack (containing n elements); B. Insert and Remove operations for a queue.

II.

O(n) - linear time

This means that the algorithm requires a number of steps proportional to the size of the task. Examples (assuming a reasonable implementation of the task): A. B. C. D. Traversal of a list (a linked list or an array) with n elements; Finding the maximum or minimum element in a list, or sequential search in an unsorted list of n elements; Traversal of a tree with n nodes; Calculating iteratively n-factorial; finding iteratively the n th Fibonacci number.

III.

O(n2) - quadratic time

The number of operations is proportional to the size of the task squared. Examples: A. B. C. Some more simplistic sorting algorithms, for instance a selection sort of n elements; Comparing two two-dimensional arrays of size n by n; Finding duplicates in an unsorted list of n elements (implemented with two nested loops).

IV.

**O(log n) - logarithmic time
**

Examples: A. B. C. Binary search in a sorted list of n elements; Insert and Find operations for a binary search tree with n nodes; Insert and Remove operations for a heap with n nodes.

V.

**O(n log n) - "n log n " time
**

Examples: A. More advanced sorting algorithms - quicksort, mergesort

VI.

O(an) (a > 1) - exponential time

Examples: A. B. C. Recursive Fibonacci implementation Towers of Hanoi Generating all permutations of n symbols

The best time in the above list is obviously constant time, and the worst is exponential time which, as we have seen, quickly overwhelms even the fastest computers even for relatively small n. Polynomial growth (linear, quadratic, cubic, etc.) is considered manageable as compared to exponential growth. Order of asymptotic behavior of the functions from the above list: Using the "<" sign informally, we can say that

**O(l) < O(log n) < O(n) < O(n log n) < O(n2) < O(n3) < O(an) A word about O(log n) growth:
**

As we know from the Change of Base Theorem, for any a, b > 0, and a, b

≠1

log b n =

log a n log a b

Therefore, log a n = C log b n where C is a constant equal to loga b. Since functions that differ only by a constant factor have the same order of growth, O(log 2 n) is the same as O(log n). Therefore, when we talk about logarithmic growth, the base of the logarithm is not important, and we can say simply O(log n).

**A word about Big-O when a function is the sum of several terms:
**

If a function (which describes the order of growth of an algorithm) is a sum of several terms, its order of growth is determined by the fastest growing term. In particular, if we have a polynomial

**p(n) = aknk + ak-1nk-1 + … + a1n + a0
**

its growth is of the order n k:

p(n) = O(nk)

Example: {perform any statement S1} for (i=0; i < n; i++) { {perform any statement(s) S2} {run through another loop n times} } O(1)

O(n) O(n2)

Total Execution Time:

1 + n + n2

therefore,

O(n2)

- 1984 Vitter Faster Random SamplingUploaded byDiego Alejandro Guzman Bass
- HW5 SolutionsUploaded byPelin Sawdcxcf
- Chapter 1 Quiz_ CET501f13 Applied Networking IUploaded byamolas22
- Mat516 Computational-techniques Th 1.00 Ac18Uploaded byRanjith M Kumar
- Closest PairUploaded byRichard Siwady Gabrie
- Big O.pdfUploaded byomonda_nii
- Quiz Progress Test AnswersUploaded byBryan Avilés
- AdaUploaded byrao001
- RF1902B46Uploaded byDewank Saini
- Discrete Math explainedUploaded bydjpsychoscientz
- wireless networks quizUploaded byAitha Satish
- chp4_q16Uploaded bySaad Malik
- Oral quiz questions and answersUploaded bydarren.yc.ng
- Lecture 1asd`aUploaded byTheAkHolic
- AnalysisdaUploaded byAlejandro Alligatoro
- MELJUN CORTES Midterm Exam ITC16Uploaded byMELJUN CORTES, MBA,MPA
- Flow-After-flow Tests for Gas WellsUploaded byTino Nassel
- Howto SortingUploaded byRanu Games
- shellsortUploaded byapi-3859693
- testUploaded byFrOzen HeArt
- 230_MAP6_sol (1)Uploaded byConrad Liu
- Recurrence TreeUploaded byamukhopadhyay
- CS502QuizSolvedForFinalTermPreparation (1)Uploaded byMaaz Bin Rizwan
- StackUploaded byakram
- C2 09 Jun Mark SchemeUploaded byCollinAllen
- 6675_01_que_20080618.pdfUploaded byboho14
- DS Lab Manual[1]Uploaded bysathyaaaaa1
- Log ProbsUploaded byNick Schleyer
- file c++Uploaded bySwapnil Yadav
- Growth Chondrostoma RegiumUploaded byrmanuelc