Lecture topic-BruteForce

Exercise a can you design a faster algorithm than the

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

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

Unformatted text preview: k ∑ ( xi − yi ) 2 i =1 • Efficiency: Θ (n2) Design and Analysis of Algorithms – Chapter 3 34 In-class exercise a Can you design a faster algorithm than the one based on Can the brute-force strategy to solve the closest-pair problem for n points x1, x2, … , xn on the real line? for a What is the time efficiency of your algorithm? What Design and Analysis of Algorithms – Chapter 3 35 In-class exercise a Can you design a faster algorithm than the one based on Can the brute-force strategy to solve the closest-pair problem for n points x1, x2, … , xn on the real line? for a Algorithm: Algorithm: • Step1: Sort the numbers in ascending order, O(nlogn) • Step 2: Compute the differences between adjacent numbers in Step the sorted list, Θ (n) • Step 3: Find the smallest such difference, Θ (n) Step Running time of the entire algorithm: Running O(nlogn) + Θ (n) + Θ (n) = O(nlogn) (n) Design and Analysis of Algorithms – Chapter 3 36 Convex hull problem Convex a Convex hull • Problem: Problem: Find sm...
View Full Document

This note was uploaded on 10/31/2013 for the course RAIK 283 taught by Professor Yinglu during the Fall '12 term at UNL.

Ask a homework question - tutors are online