a. Given the following algorithm, def Linear Search(a, x): for i in range(0, len(a)): if a[i] == x: return i return -1 What will be the result if a = [1,2,5,3] and x = = 2? b. What will be the result if a = [1,4,2,0] and x = 10?

College Algebra
7th Edition
ISBN:9781305115545
Author:James Stewart, Lothar Redlin, Saleem Watson
Publisher:James Stewart, Lothar Redlin, Saleem Watson
Chapter3: Polynomial And Rational Functions
Section: Chapter Questions
Problem 6CC: When we divide a polynomial P(x) by a divisor D(x), the Division Algorithm tells us that we can...
icon
Related questions
Question
a.
Given the following algorithm,
def Linear Search(a, x):
for i in range(0, len(a)):
if a[i] == x:
return i
return -1
What will be the result if a = [1,2,5,3] and x = = 2?
b.
What will be the result if a = [1,4,2,0] and x = 10?
Transcribed Image Text:a. Given the following algorithm, def Linear Search(a, x): for i in range(0, len(a)): if a[i] == x: return i return -1 What will be the result if a = [1,2,5,3] and x = = 2? b. What will be the result if a = [1,4,2,0] and x = 10?
Expert Solution
steps

Step by step

Solved in 1 steps

Blurred answer
Recommended textbooks for you
College Algebra
College Algebra
Algebra
ISBN:
9781305115545
Author:
James Stewart, Lothar Redlin, Saleem Watson
Publisher:
Cengage Learning
Algebra & Trigonometry with Analytic Geometry
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:
9781133382119
Author:
Swokowski
Publisher:
Cengage
Functions and Change: A Modeling Approach to Coll…
Functions and Change: A Modeling Approach to Coll…
Algebra
ISBN:
9781337111348
Author:
Bruce Crauder, Benny Evans, Alan Noell
Publisher:
Cengage Learning
Linear Algebra: A Modern Introduction
Linear Algebra: A Modern Introduction
Algebra
ISBN:
9781285463247
Author:
David Poole
Publisher:
Cengage Learning
College Algebra
College Algebra
Algebra
ISBN:
9781337282291
Author:
Ron Larson
Publisher:
Cengage Learning
Glencoe Algebra 1, Student Edition, 9780079039897…
Glencoe Algebra 1, Student Edition, 9780079039897…
Algebra
ISBN:
9780079039897
Author:
Carter
Publisher:
McGraw Hill