ics141-lecture14-Numbers

ics141-lecture14-Numbers - 14-1ICS 141: Discrete...

Info iconThis preview shows pages 1–10. Sign up to view the full content.

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 14-1ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiICS141: Discrete Mathematics for Computer Science IDepartment of Information and Computer SciencesUniversity of HawaiiStephen Y. Itoga14-2ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiLecture 14Chapter 3. The Fundamentals3.3 Complexity of Algorithms3.4 The Integers and Division14-3ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiSome material in these slides were taken/adapted from the slides made by Prof. Michael P. Frank and Prof. Jonathan L. Gross which are provided through the publisher of “Discrete Mathematics and Its Applications” written by Kenneth H. Rosen.Some slides were done by Prof. Baek14-4ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiReview: ComplexityAlgorithmic complexity = costof computation.Focus on timecomplexity for our course.Although space & energy are also important.Characterize complexity as a function of input size: Worst-case, best-case, or average-case.Use orders-of-growth notation to concisely summarize the growth properties of complexity functions.14-5ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiAnalysis of Sorting AlgorithmsCheck out Example 5and Example 6for worst-case time complexity of bubble sort and insertion sort algorithms in terms of the number of comparisons made.14-6ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiBubble Sort Analysisprocedurebubble sort (a1, a2, …, an: real numbers with n≥2)fori := 1ton – 1forj := 1ton – iifajaj+1theninterchange ajand aj+1{a1, a2, …, anis in increasing order}Worst-case complexity in terms of the number of comparisons: Θ(n2)14-7ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiInsertion Sortprocedureinsertion sort (a1, a2, …, an: real numbers with n≥2)forj :=2tonbegini:= 1whileajaii:= i+ 1m := ajfork := toj – i – 1aj-k:= aj-k-1ai:= mend{a1, a2, …, anare sorted in increasing order}Worst-case complexity in terms of the number of comparisons: Θ(n2)14-8ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiCommon Terminology for the Complexity of Algorithms14-9ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiComputer Time ExamplesAssume time = 1 ns (10-9second) per operation, problem size = nbits, and #ops is a function of n, as shown.#ops(n) n=10 n=106 log2n3.3 ns 19.9 ns n10 ns 1 ms nlog2n 33 ns 19.9 ms n2 100 ns 16 m 40 s 2n1.024 μs 10301,004.5n! 3.63 ms Ouch!...
View Full Document

This note was uploaded on 09/12/2008 for the course ICS 141 taught by Professor Idk during the Fall '08 term at Hawaii.

Page1 / 29

ics141-lecture14-Numbers - 14-1ICS 141: Discrete...

This preview shows document pages 1 - 10. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online