[algogeeks] Discussion on unique-elements-in-an-array

2010-12-19 Thread awesomeandroid
can you please elaborate nature of inputs?? are they partially sorted or may be random. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email

[algogeeks] Discussion on unique-elements-in-an-array

2010-12-18 Thread awesomeandroid
what is the range of numbers.if the array has numbers between 1 to n then there can be o(n) solution. Regards Priyaranjan http://code-forum.blogspot.com/ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Discussion on unique-elements-in-an-array

2010-08-21 Thread 2015
i think this could be done if we use binary search tree for finding the duplicates. 1. take first element in the array as the root. 2. for the next input element(say x) there can be 3 cases: 2.1 x==root : since this is a duplicate we discard this element and move to next no. in the list.

[algogeeks] Discussion on unique-elements-in-an-array

2010-08-02 Thread Avik Mitra
You can refer the following algorithm Let the elements be in the form of an array A[1...N] 1. Sort all the elements of A(This can take at least O(n) time). 2. For i=1 to N, do: while( ( i+1 = N) AND (A[i] == A[i+1]) ) remove A[i+1]. 3. END -- You received this message because you

[algogeeks] Discussion on unique-elements-in-an-array

2010-03-17 Thread Jacko
Remove elements from array and insert into a hash table, ignoring duplicates. O(n). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

[algogeeks] Discussion on unique-elements-in-an-array

2007-11-19 Thread MJ
Heap sort has a function heapify which will build the heap. If you just modify this heapify algorithm to eliminate the repeated elemenst it will work in O(nLogn). Also this will work for any number of repeated elements. you can find this algo in hte Design analysis and algorithms by Corment in

[algogeeks] Discussion on unique-elements-in-an-array

2007-10-29 Thread MD
There can be multiple ways to do this.. obviously sorting gives you o(nlogn). another approach of hashtable gives o(n) and here is another approach: 1. maintaining array of size N, initialized to 0. Say B 2. for(i=0;iN;i++) { B[a[i]]++;} 3. Output all values with B[i] = 1 , which gives unique

[algogeeks] Discussion on unique-elements-in-an-array

2007-05-04 Thread [EMAIL PROTECTED]
You can use a tweak of Merge Sort: Only change while merging of the two lists: Just while merging if two elements are equal you can make one of them equal to some predefined value. --~--~-~--~~~---~--~~ You received this message because you are subscribed to

[algogeeks] Discussion on unique-elements-in-an-array

2007-02-26 Thread joke
bitmap --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more

[algogeeks] Discussion on unique-elements-in-an-array

2007-01-29 Thread cg.yu
using hash table --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL