Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. (45 pts) Implement search as specified below in two ways: using for loops, and using while(true) loops that are terminated when accessing the array

image text in transcribed
1. (45 pts) Implement search as specified below in two ways: using for loops, and using while(true) loops that are terminated when accessing the array raises IndexOutOfBoundsException. // REQUIRES: a is sorted 77 EFFECTS: If a is null throws NullPointerException; else if x is not 77 in a, throws NotFoundException; else returns i such that a l -=x. public static int search (int[] a, int x) throws NullPointerException, NotFoundException Which implementation is better? Discuss. Note: For this question, besides the source code that you submit along with the homework solution, you also need to create a "homework4" folder in your cs.uco.edu account and put the source code there. Implement the two static methods with names "searchForLoop" and searchwhileLoop". respectively, in a class named "Searches". You may also need to define new exception types for the implementation

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

Relational Database And Transact SQL

Authors: Lucy Scott

1st Edition

1974679985, 978-1974679980

Students also viewed these Databases questions