Question
Java-Algorithms Create an encapsulated private 1D integer array named arr. This is the only global variable allowed. Create a constructor that takes 1 parameter, a
Java-Algorithms
Create an encapsulated private 1D integer array named arr. This is the only global variable allowed.
Create a constructor that takes 1 parameter, a 1D integer array. The constructor initializes arr to have the same length as the parameter & copy all elements of the parameter to the array. Do not assign the reference of the parameter to the instance variable.Then, use the Arrays.sort method to sort the instance variable.(This is an in place method).
Create an instance method named findLeftBoundary that takes an integer parameter x and returns an integer. The method should find the largest value in arr that is <= x. If there is no left boundary value return -1.
This has to be recursive.
It may be helpful to create a private helper method to track value and indices during recursion.
Code should run in O(log n).
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