@piyush : O(n/2) is O(n) ..... your approach is good , it will efficient than linear search.
On Sat, Dec 24, 2011 at 5:48 AM, Piyush Kansal <piyush.kan...@gmail.com>wrote: > Hey Ankur, > > What is the order of time complexity we are looking for in this case. The > option which Dave suggested can give us random node by traversing that many > number of nodes from the head. That will be O(n). > > This can be further reduced to n/2 if we use two pointers, both of which > will traverse two nodes at a time: > 1. one pointing to first node (lets call it odd pointer) > 2. other pointing to second node (lets call it even pointer) > > So, depending on the value returned by random number generator(even or > odd), we can decide which pointer to pick. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/N-5i9YH4AkYJ. > > 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.