1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
zloy xaker [14]
3 years ago
12

When using the BinarySearch() method of an array or list type, what value is returned when the element is not found? How can we

decode this value and make use of it?
Computers and Technology
1 answer:
Step2247 [10]3 years ago
5 0

Answer:

When the element is not found we return -1.

Explanation:

When we use binary search we use BinarySearch() method of an array or list type when the element is found we return the index of the element if found if the element is not found we return -1.

We can decode this value since it is less than 0 and the indexing of arrays and lists starts with 0 upto the size-1.So -1 index is not present in the array or list.We have to check if the index is < 0 then the element is not present in the array or list.

for ex:-

if(index<0)

{

    System.out.println("Element is not present in the array");

}

You might be interested in
Greedy Algorithm Design
Alik [6]

Answer:

The algorithm is as follows:

1. Start

2. Get the number of items (n)

3. Get the current price of the n items (a1, a2..... an)

4. Get the possible hiked price of the n items (b1, b2..... bn)

5. Calculate the difference between the current and hiked prices for each item i.e. d_i = b_i - a_i

6. Sort the differences in descending order (i.e. from the greatest to the least)

7. Buy items in this order of difference

8. Stop

Explanation:

The algorithm is self-explanatory; however, what it does is that:

It takes a list of the current price of items (say list a)

E.g: a = [100, 150, 160]

Then take a list of the hiked price of the items (say list b)

E.g: b = [110, 180, 165]

Next, it calculates the difference (d) between corresponding prices d_i = b_i - a_i

d = [(110 - 100),(180-150),(165-160)]

d = [10,30,5]

Sort the difference from greatest to lowest (as the difference is sorted, lists a and b are also sorted)

d = [30,10,5]

a = [150, 100, 160]

b = [180, 110, 165]

If there is no hike up to item k, the couple would have saved (i = 1 to d[k-1])

Assume k = 3

The couple would have saved for 2 item

Savings = d[1] + d[2]

Savings = 30 +10

Savings = 40

The saved amount will then be added to the kth item in list a i.e. a[k](in this case k = 3) in order to buy b[k]

Using the assumed value of k

a[k] = a[3]

a[3] = 160

b[3] = 165

Add the saved amount (40) to a[3]

New\ Amount = 40 + 160

New\ Amount = 200

This new amount can then be used to buy b[3] i.e. 165, then they save the change for subsequent items

8 0
3 years ago
Why is image compression an important part of vidoetechnology?
OLEGan [10]

Answer: Image compression is the technique which is responsible for the reduction in the size of the image according to the need of the video technology. Image compression is done because of the following reasons:-

  • Makes more space for the storage and creates space.
  • It also reduces the time that is used up for the uploading of the video through internet.
  • Text, labels etc might also be needed to inserted along with the image .

4 0
3 years ago
A1 = 10, A2 = 23. Write the formula you would use in Excel to add these two cells together. Is the formula 10 + 23? I don't know
Reptile [31]
=a1=a2 Hope this helps

6 0
3 years ago
What cultural characteristics does the Chicano mural movement reflect? Check all that apply.
Nataliya [291]

Answer: i believe it is family, religion, history, music and arts, and folklore.

Explanation:

8 0
3 years ago
In a three-tier client/server design, a middle layer processes the client requests and translates them into data access commands
kipiarov [429]

Answer: Software Application

Explanation: Application software is a group of programs that is designed for end users. While system software is made up of low-level programs that interact with computers at a basic level, application software is above system software and it includes applications like word processors and spreadsheets.

7 0
3 years ago
Other questions:
  • Under what conditions might the Justice Department approve a merger between two companies that operate in an industry with a pos
    14·1 answer
  • Please answer this correctly the underline drop down menu in the font group contains options to underline
    13·1 answer
  • Many large IT departments use a(n) _____ team that reviews and tests all applications and systems changes to verify specificatio
    6·1 answer
  • Which of the following IS true about usnig the Hatch command ?
    15·1 answer
  • Difference between a software package and Integrated software and why users would choose one over the other
    8·1 answer
  • What is a computer OPERATING SYSTEM?
    5·1 answer
  • You complete your database, and the company begins using it. Shortly afterwards, two GearUp buyers, Cora and Owen, work together
    9·1 answer
  • You would like to narrow your search on this topic.
    15·2 answers
  • If you want to transfer information transform STM to LTM, it is essential that you make the information ______________________.
    9·1 answer
  • If 200.123.4.6 is a classful internet protocol (ip) address, what class is it in?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!