Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread ankit sambyal
Are the elements of the array in some order, or are they random ?

-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread snehi jain
the elements are random ...

On Tue, Jul 19, 2011 at 12:01 AM, Saket Choudhary sake...@gmail.com wrote:

 Yeah if they are in some order then its possible doing it in O(n) else
 reading should itself take O(n^2) in the worst case.


 On 18 July 2011 23:54, ankit sambyal ankitsamb...@gmail.com wrote:

 Are the elements of the array in some order, or are they random ?

 --
 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.


  --
 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.


-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread ankit sambyal
@Snehi :If the elements are random, then it seems that this problem
can't be solved in O(n) time

-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread snehi jain
can it be solved in less than O(n^2) like O(nlogn ) types..
i cant figure out any solution less than O(n^2).

On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.



-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
what would be the O(n^2) sol. to this ...!!

On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.com wrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.


  --
 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.




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Saket Choudhary
Have a hash Table. Read the elements and push it to the hash table. If it
alraedy exists you are done.

On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.


  --
 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.




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

  --
 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.


-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Saket Choudhary
Ruby Solution for 1d array. The logic for 2d array remains same.

a=[1,2,3,4,5,1]
b=[]
for m in a
  unless b.include?(m)
bm
  else
puts m
break
  end
end

On 19 July 2011 01:05, Saket Choudhary sake...@gmail.com wrote:

 Have a hash Table. Read the elements and push it to the hash table. If it
 alraedy exists you are done.


 On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.


  --
 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.




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

  --
 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.




-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
can we do anything else .. othr than hash tables ...

On Tue, Jul 19, 2011 at 1:05 AM, Saket Choudhary sake...@gmail.com wrote:

 Have a hash Table. Read the elements and push it to the hash table. If it
 alraedy exists you are done.

 On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal 
 ankitsamb...@gmail.comwrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.


  --
 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.




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

  --
 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.


  --
 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.




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Saket Choudhary
Ya. Have an extra array of size(nxn). the one that I have implemented above.

-- 
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.



Re: [algogeeks] is it possible to detect the first repeating number in a 2-D array (n X n) in O(n) time ?

2011-07-18 Thread Shubham Maheshwari
the complexity of this func depends on the .include thing,
and if it were to be coded in C,
time cmplexity wud to to n^2.

On Tue, Jul 19, 2011 at 1:12 AM, Saket Choudhary sake...@gmail.com wrote:

 Ruby Solution for 1d array. The logic for 2d array remains same.

 a=[1,2,3,4,5,1]
 b=[]
 for m in a
   unless b.include?(m)
 bm
   else
 puts m
 break
   end
 end

 On 19 July 2011 01:05, Saket Choudhary sake...@gmail.com wrote:

 Have a hash Table. Read the elements and push it to the hash table. If it
 alraedy exists you are done.


 On 19 July 2011 01:02, Shubham Maheshwari shubham.veloc...@gmail.comwrote:

 what would be the O(n^2) sol. to this ...!!


 On Tue, Jul 19, 2011 at 12:41 AM, snehi jain snehijai...@gmail.comwrote:

 can it be solved in less than O(n^2) like O(nlogn ) types..
 i cant figure out any solution less than O(n^2).


 On Tue, Jul 19, 2011 at 12:37 AM, ankit sambyal ankitsamb...@gmail.com
  wrote:

 @Snehi :If the elements are random, then it seems that this problem
 can't be solved in O(n) time

 --
 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.


  --
 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.




 --
 Shubham Maheshwari
 ShubZz
 O.o o.O

 enJoY ...!!!

  --
 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.



  --
 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.




-- 
Shubham Maheshwari
ShubZz
O.o o.O

enJoY ...!!!

-- 
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.