Lecture topic-BruteForce

The firm has two identical gadgets to experiment with

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: act on the gadget’s can ’s functionality. The firm has two identical gadgets to experiment with. Design an algorithm in the best efficiency class you can to solve this problem. Design and Analysis of Algorithms – Chapter 3 21 Brute force polynomial evaluation a Problem: Find the value of polynomial Problem: 1 p(x) = anxn + an-1xn--1 +… + a1x1 + a0 +… at a point x = x0 Design and Analysis of Algorithms – Chapter 3 22 Brute force polynomial evaluation a Problem: Find the value of polynomial Problem: 1 p(x) = anxn + an-1xn--1 +… + a1x1 + a0 +… at a point x = x0 a Algorithm: Algorithm: a Efficiency: x := x0 := p := 0.0 for i := n down to 0 do for power := 1 power for j := 1 to i do power := power * x power p := p + a[i] * power power return p Design and Analysis of Algorithms – Chapter 3 23 Brute force polynomial evaluation a Problem: Find the value of polynomial Problem: 1 p(x) = anxn + an-1xn--1 +… + a1x1 + a0 +… at a point x = x0 a Algorithm: Algorithm: a x := x0 := p := 0.0 for i := n down to 0 do for power := 1 power for j := 1 to i do power := power * x power p := p + a[i] * power power return p Efficiency: Θ (n2) Efficiency: Design and Analysis of Algorithms – Chapter 3 24 Brute force polynomial evaluation a Problem: Find the value of polynomial Problem: 1 p(x) = anxn + an-1xn--1 +… + a1x1 + a0 +… at a poi...
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