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
vitfil [10]
4 years ago
9

Suppose we are performing a binary search on a sorted array called numbers initialized as follows: // index 0 1 2 3 4 5 6 7 8 9

10 11 12 13 14 int[] numbers = {-5, -1, 0, 3, 9, 14, 19, 24, 33, 41, 56, 62, 70, 88, 99}; int index = binarySearch(numbers, 18); Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm's code).
Computers and Technology
1 answer:
konstantin123 [22]4 years ago
6 0

Answer:

The indexes of the elements that would be examined by the binary search are

7 11 9

numbers[7] = 39

numbers[11] = 57

numbers[9] = 42

The values that would be returned from the search are    

39 57 42

Explanation:

The complexity of searching a value in an array using binary search is O (log n). It follows divide and conquer principle. First we have to sort the elements in the array. Here in our case the array is already sorted.

   target = (search for the value) =42

numbers[] 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14    

min max

here assign min= 0 (minimum index)

max= 14 (maximum index)    

Instead of searching for the target in a sequential manner we are searching by examining the middle term in the array by using the following formula. middle = ( min + max )/2

step 1) middle = (0 + 14)/2 = 7 numbers[middle]=numbers[7] = 39

compare target value with numbers[middle]

i.e target = 42 > 39 , the target value is greater than the numbers[middle]. so we have to move to upper part of the array.

Then min= middle+1 = 7+1 = 8

max= (unchanged) 14

 

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14    

min max

step 2) middle = (8+ 14)/2 = 11 numbers[middle]=numbers[11] = 57

compare target value with numbers[middle]

i.e target =  42 < 57 ,the target value is lesser than the numbers[middle] .

Then min= (unchanged) 8

max= middle -1 =11-1 =10

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14    

min max

step 3) middle = (8+10)/2 = 9   numbers[middle]=numbers[9] = 42

i.e target =  42 = 42

Here stop the process. In this way we found our target using binary search.

You might be interested in
Your boss asks you to transmit a small file that includes sensitive personnel data to a server on the network. The server is run
mel-nik [20]

Answer:

a. Telnet transmissions are not encrypted.

Explanation:

Indeed, since <em>Telnet transmissions are not encrypted,</em> all the information sent, and even the characters typed in the telnet console are sent in clear text.

This is a security issue, since any other device in the same network will receive a copy of the information (packets) sent. For default, all the devices, except for the server expecting to receive the information, will discard the packets. However it is easy to actively <em>listen </em>and keep those packets, wich will contain the information in plain text and human readable.

4 0
3 years ago
The U.S. continues to become more dependent on the global domain within the information environment consisting of the interdepen
Hoochie [10]

Answer:

"Cyberspace " is the right answer.

Explanation:

  • Cyberspace seems to be an interactive computational environment, unconstrained by distance and perhaps other functional disabilities. William Gibson developed the word for representing a sophisticated augmented reality infrastructure in his story Neuromancer.
  • The virtual space generated over the network through synchronized computing devices.

So that the above would be the correct answer.

4 0
4 years ago
Which statement is true about the elements of the interface of a presentation program? A. The status bar appears at the top of t
Ivan

Answer:

C. Rulers indicate the margins, tabs, and indents in a presentation slide.

Explanation:

6 0
4 years ago
Read 2 more answers
Using emails for time-sensitive messages is an example of:
blagie [28]

Answer:time-sensitive email

5 0
3 years ago
What is a program that translates the information from the web server to a language like HTML into words and pictures that we ca
tresset_1 [31]
The answer is web browser
6 0
3 years ago
Other questions:
  • What are some food project ideas?, its for my technology homework
    10·1 answer
  • Which type of hypervisor does not run on an underlying operating system?
    13·1 answer
  • At which stage should James, a website designer, gather information about the website he wants to create, and at which stage sho
    6·1 answer
  • Which option will Joan use to get a glimpse of how her presentation will look when she presents it to her audience? Joan will us
    14·2 answers
  • Using computers in place of paper to design components, products, and processes is referred to as ______.
    11·1 answer
  • What term identifies the physical interface between a computer and its peripherals?
    5·1 answer
  • Select the true statement from the choices below. Group of answer choices Invalid code may cause browsers to render the pages sl
    11·1 answer
  • Who is a data base administrator
    12·1 answer
  • The block of code below is supposed to display “multiple of 5” if the positive number value is in fact a multiple of 5
    8·1 answer
  • How to create create a database in mysql using clv files
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!