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
Kaylis [27]
2 years ago
15

An array similar to a phone book has 1000 names arranged as names [0], names[1]....names[999]. Nancy wants to search a name X in

this array. Which of the following preconditions must she ensure to perform a binary search?
a. The list has a large number of names.
b. The name X is present in the list.

In addition to the two statements above, which of the following is correct?

a. There should be no duplicates in the list.
b. The names in the list should be alphabetical order.
c. The name X should occur near the middle of the list.
Computers and Technology
1 answer:
sammy [17]2 years ago
5 0

Answer:

b. The names in the list should be in alphabetical order.

Explanation:

A binary search is an algorithm used for searching for an item in a list or array. The algorithm first sorts the data structure into order and then divides it into halves. If the searched item is less than the middle item in the list, then the algorithm searches for the target in the first half, else, in the second half. This reduces the time complexity of the search.

You might be interested in
Print "Censored" if userInput contains the word "darn", else print userInput. End with newline. Ex: If userInput is "That darn c
barxatty [35]

Answer:

#include <string>

#include <iostream>

using namespace std;

int main() {

string userInput;

getline(cin, userInput);

// Here, an integer variable is declared to find that the user entered string consist of word darn or not

int isPresent = userInput.find("darn");

if (isPresent > 0){

cout << "Censored" << endl;

// Solution starts here

else

{

cout << userInput << endl;

}

// End of solution

return 0;

}

// End of Program

The proposed solution added an else statement to the code

This will enable the program to print the userInput if userInput doesn't contain the word darn

6 0
3 years ago
Write a generator function named count_seq that doesn't take any parameters and generates a sequence that starts like this: 2, 1
-BARSIC- [3]

Answer:

#required generator function

def count_seq():

   #starting with number 2. using string instead of integers for easy manipulation

   n='2'

   #looping indefinitely

   while True:

       #yielding the integer value of current n

       yield int(n)

       #initializing an empty string

       next_value=''

       #looping until n is an empty string

       while len(n)>0:

           #extracting first digit (as char)

           first=n[0]

           #consecutive count of this digit

           count=0

           #looping as long as n is non empty and first digit of n is same as first

           while len(n)>0 and n[0]==first:

               #incrementing count

               count+=1

               #removing first digit from n

               n=n[1:]

           #now appending count and first digit to next_value

           next_value+='{}{}'.format(count,first)

       #replacing n with next_value

       n=next_value

#testing, remove if you don't need this

if __name__ == '__main__':

   #creating a generator from count_seq()

   gen=count_seq()

   #looping for 10 times, printing next value

   for i in range(10):

       print(next(gen))

Explanation:

6 0
3 years ago
1. The process of creating workable systems in a very short period of time is called
12345 [234]

Answer:

okay i know only 1st question and answer

answer:rapid application development

6 0
3 years ago
What key is used to create spaces between lines within a document?
Naily [24]

I guess the correct answer is the Enter key

Οn cοmputеr kеybοards, thе еntеr kеy in mοst casеs causеs a cοmmand linе, windοw fοrm, οr dialοg bοx tο οpеratе its dеfault functiοn. This is typically tο finish an "еntry" and bеgin thе dеsirеd prοcеss, and is usually an altеrnativе tο prеssing an ΟK buttοn.

4 0
3 years ago
What kind of block do you need to check whether a sprite is touching another sprite?
Mila [183]

A event block i know this im i have been in technology for 5 months

7 0
2 years ago
Other questions:
  • Explique si en la pc que se usa para hacer las tareas escolares se puede ver un video juego de los llamados “pesados”
    13·1 answer
  • Explain what occurs when you synchronize computer and mobile devices.
    5·1 answer
  • 3. What are the first steps that you should take if you are unable to get onto the Internet? (1 point)
    15·1 answer
  • Physical activity such as sports or even a brisk walk can help reduce
    7·2 answers
  • What kind of battery does a dji spark have?
    12·1 answer
  • After adjusting your seat, your _____ should be as close as possible to the backrest
    7·2 answers
  • I need neveahbowe to see this.
    10·1 answer
  • (20 points). Some matrixes have very special patterns, for example, in the following matrix, the numbers in the first row are eq
    14·1 answer
  • Hello everyone! can anybody help me? i need help with computing.
    10·1 answer
  • Apply the Fill - Teal, Accent 4, Soft Bevel text effect (the 5th
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!