Design a time algorithm, Data Structure & Algorithms

Q. An, array, A comprises of n unique integers from the range x to y(x and y inclusive where n=y-x). Which means, there is only one member that is not in A. Design an O(n) time algorithm to find that number.       

 

Ans:

The algorithm to find the number that is not array A where n contains n

unique (n = x - y):

find(int A[],n,x,y)

{

int i,missing_num,S[n]; for(i=0, i

{if(S[i] == -999)

{

missing_num = i + x;

break;

}

}

}

Posted Date: 7/10/2012 3:39:56 AM | Location : United States







Related Discussions:- Design a time algorithm, Assignment Help, Ask Question on Design a time algorithm, Get Answer, Expert's Help, Design a time algorithm Discussions

Write discussion on Design a time algorithm
Your posts are moderated
Related Questions
Post-order Traversal This can be done both iteratively and recursively. The iterative solution would need a change of the in-order traversal algorithm.

Define a sparse metrics. A matrix in which number of zero entries are much higher than the number of non zero entries is known as sparse matrix. The natural method of showing m

write short note on algorithms

Q.   Draw the expression tree of the infix expression written below and then  convert it intoPrefix and Postfix expressions. ((a + b) + c * (d + e) + f )* (g + h )

Example 1:  Following are Simple sequence of statements Statement 1;  Statement 2; ... ... Statement k; The entire time can be found out through adding the times for

Implement multiple queues in a single dimensional array. Write algorithms for various queue operations for them.

H o w can you r ot a t e a B i n a r y Tr e e? E x pl a i n r i g h t a n d l eft r ot a tion s by taking an e x a mpl e.   If after

B-trees are special m-ary balanced trees utilized in databases since their structure allows records to be added, deleted & retrieved with guaranteed worst case performance. A B-

A graph is a mathematical structure giving of a set of vertexes (v1, v2, v3) and a group of edges (e1, e2, e3). An edge is a set of vertexes. The two vertexes are named the edge en

If a Dequeue is implemented via arrays, then this will suffer with the similar problems which a linear queue had suffered. Program 8 gives the array implementation of Dequeue.