10_sort_alg

10_sort_alg - Introduction to Computers and Programming...

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

View Full Document Right Arrow Icon
Introduction to Computers and Programming Prof. I. K. Lundqvist Lecture 10 April 8 2004 2 Today • How to determine Big-O • Compare data structures and algorithms • Sorting algorithms
Background image of page 1

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

View Full DocumentRight Arrow Icon
3 How to determine Big-O • Partition algorithm into known pieces • Identify relationship between pieces – Sequential code (+) – Nested code (*) • Drop constants • Only keep the most dominant factors 4 Does Big-O tell the whole story? •T x (n) = T y (n) = O(lg n) ± ± setup of algorithm -- takes 50 time units read n elements into array -- 3 units/element for i in 1..n loop do operation1 on A[i] -- takes 10 units do operation2 on A[i] -- takes 5 units do operation3 on A[i] -- takes 15 units ± ± setup of algorithm -- takes 200 time units read n elements into array -- 3 units/element for i in 1..n loop do operation1 on A[i] -- takes 10 units do operation2 on A[i] -- takes 5 units T 1 (n)=50+3n+(10+5+15)n = 50+33n T 2 (n)=200+3n+(10+5)n = 200+18n
Background image of page 2
5 F&B BST BST Binary Tree Sorted Array Unsorted Array Sorted L List Unsorted L List Insert Search Traversal Data structure N N N N N N N 6 Searching Linear (sequential) search – Checks every element of a list until a match is found – Can be used to search an unordered list Binary search – Searches a set of sorted data for a particular data – Considerable faster than a linear search – Can be implemented using recursion or iteration
Background image of page 3

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

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

This note was uploaded on 01/28/2012 for the course AERO 16.01 taught by Professor Markdrela during the Fall '05 term at MIT.

Page1 / 15

10_sort_alg - Introduction to Computers and Programming...

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

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