ics141-lecture12-FunctionGrowth

ics141-lecture12-FunctionGrowth - 12-1ICS 141: Discrete...

Info iconThis preview shows pages 1–8. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 12-1ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiICS141: Discrete Mathematics for Computer Science IDepartment of Information and Computer SciencesUniversity of HawaiiStephen Y. Itoga12-2ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiLecture 12Chapter 3. The Fundamentals3.1 Algorithms3.2 The Growth of Functions12-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 material was done by Prof. Baek12-4ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiSorting AlgorithmsSorting is a common operation in many applications.E.g.spreadsheets and databasesIt is also widely used as a subroutine in other data-processing algorithms.Two sorting algorithms shown in textbook:Bubble sortInsertion sortHowever, these are notvery efficient, and you shouldnot use them on large data sets!Well see some more efficient algorithms later in the course.12-5ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiBubble SortSmaller elements float up to the top of the list, like bubbles in a container of liquid, and the larger elements sink to the bottom.12-6ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiBubble Sort Algorithmprocedurebubble sort (a1, a2, , an: real numbers with n2)fori := 1ton 1forj := 1ton iifajaj+1theninterchange ajand aj+1{a1, a2, , anis in increasing order}Example 4: Use the bubble sort to put 3, 2, 4, 1, 5 into increasing order. (See previous slide)12-7ICS 141: Discrete Mathematics I (Spr 2008)University of HawaiiInsertion Sort AlgorithmEnglish description of algorithm:For each item in the input list,Insert it into the correct place in the sorted output list generated so far. Like so:Use linear or binary search to find the location where the new item should be inserted....
View Full Document

Page1 / 22

ics141-lecture12-FunctionGrowth - 12-1ICS 141: Discrete...

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

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