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
VMariaS [17]
3 years ago
6

Let t[1..n] be a sorted array of distinct integers, some of which may be negative. give an algorithm that can find an index i su

ch that 1 i n and t[i] = i
Mathematics
1 answer:
lisabon 2012 [21]3 years ago
8 0
Assuming we need to find i such that 
1 ≤ i ≤ n  and t[i]=i.

If we need to find only the first occurrence, we can do:

for i:1 to n {
    if t[i]=i then return(i)
}

If exhaustive search is required, then put the results (values of i) in an array or a linked list, return the number of values found, and the array (or linked list).


You might be interested in
What is the slope of a line that passes through points (-1, 4) and (4, 9)?
melamori03 [73]

The slope is (difference in 'y') divided by (difference in 'x') .

Difference in 'y' = (9 - 4) = 5

Difference in 'x' = (4 - [-1]) = 5

Slope = 5/5 = 1 .

(I don't think we need the pictures at all.)

 
3 0
3 years ago
Read 2 more answers
Which word best completes the statement below? All parallelograms —————
wolverine [178]
Have two sets of parallel sides
5 0
3 years ago
Read 2 more answers
Hi plz help, if you can ill mark you 5 starz! :)
Inga [223]

Answer:

12 kg, 1200 mm, 1200 ml (twice), 12 m, and 120 mm

5 0
3 years ago
Read 2 more answers
My number has two periods. One 3,0 and 6 in that order the other contains the digits 0,9 and 5 in that order
Vsevolod [243]
3.06, and 0.95 are the numbers.
4 0
3 years ago
At medina middle school 2% of the students ride bikes to school. If 950 students attend Medina middle school how many students r
svet-max [94.6K]
19 students.  950 times 0.02= 19
8 0
3 years ago
Other questions:
  • 1,119.85 is estimate to what number
    8·1 answer
  • What is the equation of a vertical line passing through (-5,-2)
    8·1 answer
  • What are two numbers that have a product of 8.4?
    7·2 answers
  • The following table shows the amount of water leaking from an inflatable pool as a function of time:
    7·2 answers
  • A model airplane is built to a scale of 1 in.:12 ft. If the model plane is 11 inches long, find the length of the actual plane,
    10·1 answer
  • The cost of producing pots is the initial investment, $175, plus $3.50 in materials per pot. Therefore, the function C(p) = 175
    11·2 answers
  • Write an equation in slope-intercept form of the line that passes through the points.
    6·1 answer
  • You have 12 different video games. How many different ways can you arrange the games side by side on a shelf?
    6·1 answer
  • Part B: A triangle has vertices A (-2, 3), B (0, 0), and C (1, 2). What are the coordinates of the vertices if the original tria
    11·1 answer
  • A coffee pot holds 3 quarts of coffee. How much is this in cups?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!