Lecture25 - Engineering Analysis ENG 3420 Fall 2009 Dan C...

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

View Full Document Right Arrow Icon
1 Engineering Analysis ENG 3420 Fall 2009 Dan C. Marinescu Office: HEC 439 B Office hours: Tu-Th 11:00-12:00
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Lecture 25 Lecture 25 ± Attention: The last homework HW5 and the last project are due on Tuesday November 24!! ± Last time: ² Cubic splines ± Today ² Searching and sorting ² Numerical integration (chapter 17) ± Next Time ² Numerical integration of functions (chapter 18).
Background image of page 2
3 Search algorithms ± Find an element of a set based upon some search criteria. ± Linear search : ² Compare each element of the set with the “target” ² Requires O(n) operations if the set of n elements is not sorted ± Binary search : ² Can be done only when the list is sorted. ² Requires O(log(n)) comparisons. ² Algorithm: ± Check the middle element. ± If the middle element is equal to the sought value, then the position has been found; ± Otherwise, the upper half or lower half is chosen for search based on whether the element is greater than or less than the middle element.
Background image of page 3

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

View Full DocumentRight Arrow Icon
4 Sorting algorithms ± Algorithms that puts elements of a list in a certain order, e.g., numerical order and lexicographical order. ² Input: a list of n unsorted elements. ² Output: the list sorted in increasing order. ± Bubble sort Æ complexity: average O(n 2 ); )); worst case O(n 2 ). ² Compare each pair of elements; swap them if they are in the wrong order. ² Go again through the list until no swaps are necessary. ± Quick sort Æ complexity: average O(n log(n)); worst case O(n 2 ). ² Pick an element, called a pivot , from the list. ² Reorder the list so that ± all elements which are less than the pivot come before the pivot and ± all elements greater than the pivot come after it (equal values can go either way). After this partitioning, the pivot is in its final position.
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/17/2012 for the course EGN 3420 taught by Professor Staff during the Spring '08 term at University of Central Florida.

Page1 / 21

Lecture25 - Engineering Analysis ENG 3420 Fall 2009 Dan C...

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

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