doing xor of all elements in array[][] should work. you start from a[0] [0] to a[0][n] then a[1][0] .. when the xor value bcomz 0 then the corresponding value in arr[i][j] is the first repeated element in the array. though this code will have two loops and seem as O(n2) it will terminate once it finds the first repeated no. hope my algo works. comments plz
On Jul 19, 2:14 am, Dumanshu <duman...@gmail.com> wrote: > You have to use parallel computing to find the first repeating number > in O(n) time if theres nothing special about the 2-D array > Use n +1 processes, n processes to scan each row and 1 process to scan > the rows last and next rows first element to check for repetition. > Each process uses hash table to find the first non repeating number. > When we have the results from all the processes, do O(n) scanning, and > output the result for minimum row which wud be the first repetition. > > On Jul 18, 10:42 pm, snehi jain <snehijai...@gmail.com> wrote: > > > > > > > > > this question was asked in an interview. > > > Regards > > Snehi -- 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 algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.