Re: [algogeeks] unsorted array problem

2011-08-26 Thread Rahul Verma
@Umesh I really appreciate your solution and thinking to understand the complexity of the program. Actually I don't have that much idea about the "*how to calculate complexity of any program*". So could you please show some light on the evaluation procedure of complexity. Rahul Verma -- You

Re: [algogeeks] unsorted array problem

2011-08-26 Thread tech coder
it can be done in O(N) by using XOR ing the elements 1: Xor all the elemnts since those elemnts that even freq will nullify each other we get number taht will tell in which the two required number differ. 2: divide the array in two sets on the basis of bit in which numbers differ 3:1 element will

Re: [algogeeks] unsorted array problem

2011-08-25 Thread Umesh Jayas
int main() { int arr[]={1,2,5,1,5,1,1,3,2,2,}; int elements = sizeof(arr)/sizeof(arr[0]); int count=1; int num; sort(arr,arr+elements); num=arr[0]; for(int i=1;ihttp://groups.google.com/group/algogeeks?hl=en.