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
It is a useful tool for indicating the logical properties of data type. It is a collection of values & a set of operations on those values. Methodically, "a TYPE is a set, & elemen

Draw trace table and determine output from the following flowchart using following data: Number = 45, -2, 20.5


what is far and near procedures in system programming?

1. Apply the variant Breadth-First Search algorithm as shown in Figure 2 to the attached graph. This variant is used for computing the shortest distance to each vertex from the sta

How branching takes place in Instruction pipeline. Explain with suitable examples

Multilist Representation of graph

Example of Area Subdivision Method The procedure will be explained with respect to an illustrative problem, with the image consisting of five objects, namely a triangle (T), qu

A connected graph is a graph wherein path exists among every pair of vertices. A strongly connected graph is a directed graph wherein every pair of distinct vertices is connecte

Elaborate the symbols of abstract data type length(a)-returns the number of characters in symbol a. capitalize(a)-returns the symbol generated from a by making its first cha