// Among indexes first...last, return index of the target. // If target is not present then return -1. // precondition: the elements of array are in descending order. static int find(int [] array, int first, int last, int target) if (first > last) { // one very short line } if (first == last) { // one line, using the conditional operator } int mid = (first+last+1)/2; if (target <= array[mid]) { // one line, involving a recursive call } // one line, involving a recursive call

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 13RQ: How is an array stored in main memory? How is a linked list stored in main memory? What are their...
icon
Related questions
Question

In java

if i have this pseudo code that tries to explain how a method will work using recursion how can i turn this into working java code

// Among indexes first...last, return index of the target.
// If target is not present then return -1.
// precondition: the elements of array are in descending order.
static int find(int [] array, int first, int last, int target)
if (first > last) {
// one very short line
}
if (first == last) {
// one line, using the conditional operator
}
int mid = (first+last+1)/2;
if (target <= array[mid]) {
// one line, involving a recursive call
}
// one line, involving a recursive call
Transcribed Image Text:// Among indexes first...last, return index of the target. // If target is not present then return -1. // precondition: the elements of array are in descending order. static int find(int [] array, int first, int last, int target) if (first > last) { // one very short line } if (first == last) { // one line, using the conditional operator } int mid = (first+last+1)/2; if (target <= array[mid]) { // one line, involving a recursive call } // one line, involving a recursive call
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning