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
Example which cause problems for some hidden-surface algorithms Some special cases, which cause problems for some hidden-surface algorithms, are penetrating faces and cyclic ov

Implementation of Stack :- Stacks can be executed in the 2 ways: a)  Arrays b)  Linked List

Q. Develop a representation for a list where insertions and deletions can be done at either end. Such a structure is known as a Deque (Double ended queue). Write functions for inse

Prepare a GUI called Hotplate GUI that holds a central panel that draws a rectangular grid that represents Element objects which should be held in a 2-dimensional array. The applic

Searching is the procedure of looking for something. Searching a list containing 100000 elements is not the similar as searching a list containing 10 elements. We discussed two sea

Develop a program that accepts the car registration( hint: LEA 43242010)

Explain the representations of graph. The different ways of representing a graph is: Adjacency list representation : This representation of graph having of an array Adj of


Example: (Single rotation into AVL tree, while a new node is inserted into the AVL tree (LL Rotation)) Figure: LL Rotation The rectangles marked A, B & C are trees

draw a flowchart which prints all the even numbers between 1-50