# The for example the insertion sort with tjj2 again j2

This preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: misleading NCKU IIM NCKU 資料結構 Chapter 2 資料結構 12 Worst-case and Average-case Analysis • Average-case: require probability analysis • Usually, we concentrate on finding only on the Usually, worst-case running time worst • Reason: Reason: – – – It is an upper bound on the running time The worst case occurs fair often The average case is often as bad as the worst case. The For example, the insertion sort with tj=j/2. Again, =j/2. quadratic function although with smaller coefficient. smaller NCKU IIM NCKU 資料結構 Chapter 2 資料結構 13 Order of Growth • In some particular cases, we shall be interested in In average-case, or expected running time of an average or expected running algorithm. (Chap 5) algorithm. • It is the rate of growth, or order of growth, of It rate or order of the running time that really interests us. – – – – Only look at the leading terms (drop lower-order terms) Ignore the constant coefficient in the leading term 2 E.g. insertion sort: Θ(n ) More on this topic will be taught in Chap 3 NCKU IIM NCKU 資料結構 Chapter 2 資料結構 14 2.3 Designing Algorithms 2.3 There are many ways to design algorithms: There • Incremental approach: insertion sort • Divide-and-conque...
View Full Document

## This note was uploaded on 02/08/2013 for the course SCI 399 taught by Professor Bob during the Winter '12 term at Bismarck State College.

Ask a homework question - tutors are online