Re: [algogeeks] Re: Array , Number Missing or Duplicate ..

2011-03-01 Thread Abhijit K Rao
I can think of 2 methods if Hashing is not allowed. 1. Plain comparison of every element with an other element, which takes O(n2) 2. We can sort the array, and the best we could achieve is O(nlogn) after that use simple comparision, like the code here : http://codepad.org/RtRbnyAN; Overall

Re: [algogeeks] [brain teaser ] 25february

2011-02-26 Thread Abhijit K Rao
The age guy of bus driver is the age of the puzzle solver. Best Regards Abhijit On Sat, Feb 26, 2011 at 1:05 PM, Lavesh Rawat lavesh.ra...@gmail.comwrote: *Bus Driver Problem Solution* ok let's say you're driving a bus and it's empty. At the first stop two(2) people get on. At the second

Re: [algogeeks] Microsoft

2011-02-06 Thread Abhijit K Rao
How about , using a sorting algorithm like Quick sort and return diff of last and the before last element. Best Regards Abhijit On Sun, Feb 6, 2011 at 3:29 PM, Decipher ankurseth...@gmail.com wrote: Algorithm to find the two numbers whose difference is minimum among the set of numbers.

Re: [algogeeks] interview quest..

2011-02-06 Thread Abhijit K Rao
I could not get it for recursively, but iteratively, I coded a solution. If anyone knows recursively, let us know please. #includestdio.h void main() { char s[18]=DGGDBCBHH; int i=0,j=0; int count; while(s[i]!='\0') { if(s[i] == s[i+1]) {

Re: [algogeeks] algo to count the items in a list

2010-10-18 Thread Abhijit K Rao
The most crude method would be to do a comparison in the entire array list and increment as and when we find a match. But this method gives a complexity of O(n2). The same method above can be used , and comparisons can be done from either ends of array, which reduces the complexity to O(n2 / 2)