Answered step by step
Verified Expert Solution
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.
/* * 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started