Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Consider a function f(x) = cos(x), whose values monotonically decrease from 1 (when x = 0 degrees) to -1 (when x = 180 degrees)

1) Consider a function f(x) = cos(x), whose values monotonically decrease from 1 (when x = 0 degrees) to -1 (when x = 180 degrees) in the range of [0...180] for the angle (in degrees). Your task for this question is to come up with a binary search algorithm to determine the largest value of 'x' ('referred to as the threshold value for x) for which f(x) is greater than a target 't'. The target 't' value can be anywhere in the interval/range (-1, ..., 1). Note that this is a open interval, so the 't' value will be greater than -1, but less than 1. Termination condition: Run the iterations until the difference between the right index and left index is greater than 0.1.

(a) Choose the appropriate initial values for the left index (LI) and right index (RI).

(b) State the invariant property that will be maintained for the LI and RI vis-a-vis the f(x) values for the entire algorithm.

(c) Provide a pseudo code of the binary search algorithm, including the scenarios when you will move the LI and RI (d) Run the algorithm of

(c) for the target 't' value of 0.25 and show the details (LI, RI, middle index: MI and f(MI) values as well as how the LI or RI are adjusted for each iteration) until the termination. (e) What is the theoretically expected number of iterations based on the initial values for LI and RI as well as the termination condition? How does this compare to the number of iterations observed in (d)? You will get a ZERO if you just use a brute force approach

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 19 21 2012 Proceedings Part 3 Lnai 7198

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284922, 978-3642284922

More Books

Students also viewed these Databases questions

Question

1. Write down two or three of your greatest strengths.

Answered: 1 week ago