Let T[1..n] be a sorted array of distinctintegers, some of which may be negative. Give an algorithm that can find an index i such that 1 <= i <= n and T[i] = i, provided such an index exists. Your algorithm should take a time in Big "O" (log n) in worst case.

Solution Summary

This shows how to generate an algorithm to find index.

Please help with these 2 problems in algorithm efficiency. View attached file.
1. Rank the terms of the following function according to their order of growth. Give explanation.
2. Consider the following algorithm where n is a positive integer.
What is the efficiency class of this algorithm? Show your reasoning.

Can you please help me derive the inverse transformation algorithm for generating a random variate?
Derive the inverse transformation algorithm for a generating a random variate from the following distribution (assume a

I need assistance with the attached problem. It requires me to show that a given algorithm generates the geometric distribution.
Please see the attached document for details.
Show that the following algorithm is valid for generating X -- geom(p)
1. Ler i=0.
2. Generate (please see the attached file) independent of any

I have an algorithm called MinDistance that determines the distance between the two closest elements in an array. I need to make it more efficient.
Here is the algorithm, written in pseudocode:
MinDistance(A[0...n-1]
dmin <-- infinity
for i <--- 0 to n - 1 do
for j <--- 0 to n - 1 do
if i does not equal j a

The question of how many ways a committee of 4 people can be selected from a group of 10 is known as a combination. The notation in general for counting the number of ways of selecting r items from a group of n is C(n,r) = n! / r!(n-r)!
Also, given that 0! = 1 by definition, we can show that C(n,0) = 1 = C(n,n)
Also, C(n,r

Trace the algorithm below and track the number of times that the addition operation (+) is executed over the course of the program's run time. Answer the question by giving a formula in terms of n:
for i := 1 to n do
for j := 1 to i do x := x + f(x) od;
x := x + g(x)
od

a. Write a Matlab function newton.m which uses Newton-Raphson algorithm to compute an approximate solution to the equation f(x) = 0 starting from X0 and stopping when the magnitude of f(x) becomes smaller than e. The program should also restrict the maximum number of iterations to N. Your m-file should have a header line functi

Suppose that all edge weights in a graph are integers in the range from 1 to |V|. How fast can you make Kruskal's algorithm run? What if the edge weights are integers in the range from 1 to W for some constant W?