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
mixas84 [53]
3 years ago
7

Suppose that you are given a sorted sequence of distinct integers {a1,a2,…,an}. give an o(lgn) algorithm to determine whether th

ere exists an i index such as ai
Mathematics
1 answer:
jasenka [17]3 years ago
3 0
Since the sequence is sorted, you can use the binary search, which is of O(lg2).  You can google binary search, or inspire from the following.
Basically, the algorithm looks like the following:

checkMiddle(ai, a1,n)
if (n==0) return(-1)   // key ai not found
k=(1+n)/2;
if (a_k = ai)  return(k)
else
if (a_k>ai
   checkMiddle(ai,a_1,k)
else
  checkMiddle(ai,a_(k+1),n-k)
endif

You may have to tune and check, but the basic idea is there.

Also, concerning computing algorithms, you are better off with posting it under technology and computers.
You might be interested in
Write the following as a single sine or cosine function of an angle
mezya [45]

Answer:

idk

Step-by-step explanation:

i wish i did

8 0
3 years ago
Read 2 more answers
Please help meeeeeeeee
kiruha [24]

Answer:

24 units²

Step-by-step explanation:

Surface area of a cube = 6a² , where a = the side given

=> 6(2)²

=> 6(4)

=> 24 units²

Hope this helps!

4 0
3 years ago
Read 2 more answers
Blood type AB is found in only 3% of the population.† If 345 people are chosen at random, find the probability of the following.
Anna007 [38]

Answer:

345 times 0.03 = 10.35 but we cant have 0.35 of a person so it is 10 people

Step-by-step explanation:

3 0
3 years ago
11x-8=10x. Find the value of x
marusya05 [52]

Answer: x=8

Step-by-step explanation: Solve for x by simplifying both sides of the equation, then isolating the variable.

Hope this helps you out.

3 0
4 years ago
Read 2 more answers
An ice cream cone has a height of 6 inches and a radius of 2 inches as shown. The ice cream completely fills the cone, as well a
iragen [17]
The cone itself is 25.13, with the half sphere added it’s 41.8 :)
6 0
3 years ago
Other questions:
  • How to do this problem
    12·1 answer
  • What is the slope of this line?<br><br><br> −34<br><br> −3<br><br> 4<br><br> 34
    12·2 answers
  • Mike needs to paint several rooms in his house. He knows that the larger the rooms are, the more paint he will need.
    10·1 answer
  • Find the angle between the given vectors to the nearest tenth of a degree.
    5·2 answers
  • Which measurement is most accurate to describe the length of a ladybug?
    14·1 answer
  • What is a proportion for 15% of 82
    13·1 answer
  • What is 35% of 50?<br> A. 17.5<br> B. 35<br> C. 85<br> D.142
    8·1 answer
  • Solve for m<br> 18 - 4m = 6 - 16m
    13·2 answers
  • 1. What is the slope of a line that is parallel to the line represented by the equation 3x + 4y = 12?
    11·1 answer
  • How many square meters are there in a floor that is 9 meters long by 12 meters wide?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!