Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Will upvote, JAVA a. Write a pseudocode implementation for the following sorting algorithms: insertion sort, bubble sort, selection sort. b. The following method (below) implements

Will upvote, JAVA

a. Write a pseudocode implementation for the following sorting algorithms: insertion sort, bubble sort, selection sort.

b. The following method (below) implements a search algorithm using binary search. The method contains an error. Denote the error and explain what would need to be changed to make the method work correctly.

image text in transcribed

/* * A method which implements a binary search algorithm on an ordered data set. @param searchkey - type long - the value in the array which is being sought @return curIn - type int - the index position of the value which is being sought * * * * Failure return value: @return nElems - type int - * the number of elements in the array * */ public int find (long searchKey) { int lowerBound = 0; int upperBound = nElems-1; int middle Position = (nElems-1)/2; int curIn; while(true) { curIn = (lowerBound + middle Position ) / 2; if(a[curIn]==searchkey) return curIn; else if (lowerBound > upperBound) return nElems; else { if(a[curIn)

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

Advances In Knowledge Discovery In Databases

Authors: Animesh Adhikari, Jhimli Adhikari

1st Edition

3319132121, 9783319132129

More Books

Students also viewed these Databases questions