New here? Take 25% off your first assignment Claim my discount

Describe the time complexity of the binary search algorithm in terms of number of comparisons used (ignore the time required to compute m = b(i + j)/2c in each iteration of the loop in the algorithm).

any problem at the beginning of the collaboration process.
1. [10 points] Describe the time complexity of the this linear search algorithm. Choose the tightest asymptotic
representation, from T, O, or ?, and argue why that is the tightest bound.
LINEAR-SEARCH(x, A)
1 i = 1 //Arrays in the text begin at 1 in all but one case this semester
2 while i = n and x 6= A[i]
3 i = i + 1
4 if i = n
5 location = i
6 else location = 0
7 return location
2. [15 points] Consider this binary search algorithm. This algorithm is different than the algorithm on page 799
of the CLRS text. Array A is a sorted list of elements. x may or may not be in A.
BINARY-SEARCH(x, A)
1 i = 1 //Arrays in the text begin at 1 in all but one case this semester
2 j = n
3 while i
4 m = b(i + j)/2c
5 if x > A[m]
6 i = m + 1
7 else j = m
8 if x = A[i]
9 location = i
10 else location = 0
11 return location
(a) [10 points] Describe the time complexity of the binary search algorithm in terms of number of comparisons
used (ignore the time required to compute m = b(i + j)/2c in each iteration of the loop in the algorithm).
Choose the tightest asymptotic representation, from T, O, or ?, and argue why that is the tightest bound.
(b) [5 points] Make one small change to the algorithm above to improve its runtime, and give the revised
tightest asymptotic representation, from T, O, or ?. Show your change using proper pseudocode. If the
asymptotic representation changed from your answer to 2a, argue why it is different.nment. For chapter 2,

  • Section 2.2: Analyzing Algorithms has been recommended and for Chapter 3,
      • Section 3.1: Asymptotic Notation has been recommended
  • </listyle=”font-family:>
find the cost of your paper

The post Describe the time complexity of the binary search algorithm in terms of number of comparisons used (ignore the time required to compute m = b(i + j)/2c in each iteration of the loop in the algorithm). appeared first on Best Custom Essay Writing Services | EssayBureau.com.

admin
admin

Academic writer and editor at EssayLink โ€“ Expert Homework Help & Academic Writing Services.

Short on time? Let an expert help.

Original papers written to your instructions, on time, from $10/page.

Order now
From$10/page
Get my price

๐ŸŽ Get 25% OFF Your Assignment Today!
โœ… 100% Human-Written | ๐Ÿ“„ Free Turnitin Report | ๐Ÿ’ฌ Live Expert Support

Close Welcome Bar