[algogeeks] finding duplicates

2011-08-30 Thread Kamakshii Aggarwal
develop an algorithm to find duplicates in a list of numbers without using a binary tree..if there are n distinct numbers in the list ,how many times must two numbers be compared for equality in your algorithm?what if all numbers are equal? -- Regards, Kamakshi kamakshi...@gmail.com -- You rece

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-03 Thread jalaj jaiswal
@above sort the array using any inplace algorithm and then chk adjacent for duplicates... this seems to me only inplace solution for chking duplicates On Sat, Jul 3, 2010 at 5:57 PM, Vikas Jayaprakash < vikas.jayaprak...@gmail.com> wrote: > I dint understand answer to rotation question. > > Also

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-03 Thread Vikas Jayaprakash
I dint understand answer to rotation question. Also is there any way of identifying duplicates in an array without using any extra memory (like creating hash table takes extra memory). Any reference w.r.t book (or google book) to seek the concept behind two questions? Please let me know. Regard

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-03 Thread jalaj jaiswal
int findPivot(int arr[], int low, int high) { int mid = (low + high)/2; /*low + (high - low)/2;*/ if(arr[mid] > arr[mid + 1]) return mid; if(arr[low] > arr[mid]) return findPivot(arr, low, mid-1); else return findPivot(arr, mid + 1, high); } int pivotedBinarySearch(i

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-03 Thread Abhirup Ghosh
How can you find smallest element in the array in O(logn) time? Can you please elaborate? -Abhirup On Fri, Jul 2, 2010 at 3:44 PM, jalaj jaiswal wrote: > second question can be done in O(logn) > do a modified binary search to find the starting index of the rotated array > i.e the smallest elem

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-02 Thread jalaj jaiswal
second question can be done in O(logn) do a modified binary search to find the starting index of the rotated array i.e the smallest element. after that you have two sorted arrays.. for eg 789 1236 (your modified binary search should return index of 1) now check if the elemnent you are searching in

Re: [algogeeks] Finding Duplicates in Random Array

2010-07-02 Thread Abhirup Ghosh
1. (1) Maintain a hash table and insert the elements in the table when passing through the array. And if there is a collision then that element is a duplicate element in the array.Time - O(n) and the space is O(n). (2) Duplicate is detected by the above process. Then it can be easily removed. I ca

[algogeeks] Finding Duplicates in Random Array

2010-07-01 Thread Vikas Jayaprakash
Hi AlgoGeeks, Can anyone provide me answers for the below. 1. given an array of random integers write a program to (1) detect duplicate (2) remove duplicate (array should not get hampered at any cost!). 2 - In a sorted array some of the elements say N are rotated. for example initially 1 2 3 6