Ask Question
8 December, 10:06

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 such that 1 i n and t[i] = i

+1
Answers (1)
  1. 8 December, 13:23
    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).
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 such that ...” in 📘 Mathematics if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers