Question: Working with arrays--Searching and Sorting Algorithms Task 1:Searching an Array Based List--Linear Search Write a function thatsearches if a specific value exists inan array. If
Working with arrays--Searching and Sorting Algorithms
Task 1:Searching an Array Based List--Linear Search
Write a function thatsearches if a specific value exists inan array. If the value is found, the function returns its index. If the value is not in the array, it returns -1. Assume that the data in the array is not sorted.
Note: Swift has a build-in function calledindex(of:)that does the same thing. However, our objective here is to study search algorithms. So we're going to ignore it and write our own function.
Write an algorithm and verify it with an example
Implement it in Swift and test it.
Be ready to demo
Task 2:A More Efficient Search for Sorted Lists
Assume the list stored in the array is sorted in ascending order. How would you change your search algorithm to make more efficient?
Write an algorithm and verify it with an example
Implement it in Swift and test it
pls I need solutions. thanks
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
