Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
the linked lists has been used, but the key idea is to implement LRU algo so if you use associate a timestamp with each request, and use that for prioritising the the bucket queue, or use a simple front tail mechnism to remove from front and push at the end as soon as a request is made, that will

Re: [algogeeks] Re: graphs again

2010-07-06 Thread Ashish Goel
oops, my warshall algo will simply tell if there exists a path or not!! to find if the path exist between two nodes of length K in O(K) is interesting..i donot understand the logic of this problem, why of length k in O(k), any real problem on this? Best Regards Ashish Goel Think positive and

[algogeeks] Need good hashing implementations in Linux (C/C++)

2010-07-06 Thread Prashanth
Hi all! I need some good hash implementations. I am able to find couple of them but I don't know their quality/performance. Please let me know something which you have used and tested. Thank you, Regards, Prashanth -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Need good hashing implementations in Linux (C/C++)

2010-07-06 Thread Ashish Goel
refer burtleburtle.net Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6, 2010 at 3:28 PM, Prashanth prashanths2...@gmail.com wrote: Hi all! I need some good hash implementations. I am able to find couple of them but I don't know

Re: [algogeeks] ipc

2010-07-06 Thread Ashish Goel
above all shared memory, refer galvin, once memory is shared, it is quite fast whereas for message passing, system calls are required Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6, 2010 at 8:43 AM, sharad kumar

[algogeeks] Re: malloc implementations

2010-07-06 Thread srinivas r
just have a look at http://en.wikipedia.org/wiki/Malloc the article lists most popular implementations of malloc On Jul 5, 5:52 pm, amit amitjaspal...@gmail.com wrote: Hi, can anybody tell me how is malloc implementedany links to tutorials for this will be highly apperciated. -- You

[algogeeks] Need help

2010-07-06 Thread crazysaikat
Hey anyone doing topcoder srm 375, please help me out in medium question, question is.. Rabbits often feel lonely, so one group of rabbits decided to gather together and play a game. The game is played on a horizontal row of N cells (N = 2), numbered 0 to N - 1 from left to right. Each cell is

Re: [algogeeks] Need good hashing implementations in Linux (C/C++)

2010-07-06 Thread Anil C R
I don't get it what's that got to do with hashing? Anil On Tue, Jul 6, 2010 at 4:59 PM, Ashish Goel ashg...@gmail.com wrote: refer burtleburtle.net Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6, 2010 at 3:28 PM, Prashanth

Re: [algogeeks] microsoft interview(numbers)

2010-07-06 Thread Abhirup Ghosh
We can build a wrapper object having two fields one th actual integer in the array and the count o the integer in the given array. Then build an array of those objects. Range of this array can be found easily by finding max and min of the array in O(n) time. We can build the auxiliary array in

Re: [algogeeks] google

2010-07-06 Thread Anand
@Ashish: why do we need to shift array element when we are using FIFO queue. With array also could easily implement FIFO queue with out the overhead of shifting the elements. On Tue, Jul 6, 2010 at 1:29 AM, Ashish Goel ashg...@gmail.com wrote: the linked lists has been used, but the key idea

Re: [algogeeks] Amazon Puzzle

2010-07-06 Thread Jitendra Kushwaha
Seems tough to do as every time we dont know which coins we flipped in the previous move We can perform all the four operation one by one in circular fashion and we will have probabilitty of getting all head up at some time. this is because even if table rotated at random, each of the for step

Re: [algogeeks] ipc

2010-07-06 Thread harit agarwal
shared memory processing is fast but it is not a IPC mechanism... -- 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

Re: [algogeeks] google

2010-07-06 Thread topojoy biswas
@anand very true... i also realized after writing it. Only a hashtable would do. but i have another qs in mind...perfect hash functions are built on an expected probability of collition. Even if we do rehashing, that also does not give an upper bound on the number of times we need to rehash.

Re: [algogeeks] Need help

2010-07-06 Thread Jitendra Kushwaha
can you specify the question name or link of question on topcoder -- Regards Jitendra Kushwaha MNNIT, Allahabad -- 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

Re: [algogeeks] adobe problem---array

2010-07-06 Thread Jitendra Kushwaha
Any boundation on the range of elements?? -- Regards Jitendra Kushwaha MNNIT, Allahabad -- 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

Re: [algogeeks] Need help

2010-07-06 Thread Priyanka Chatterjee
Contest in running and you are posting the 550 points problem? Its unfair. Ask after it gets over. On 6 July 2010 17:30, crazysaikat crazysai...@gmail.com wrote: Hey anyone doing topcoder srm 375, please help me out in medium question, question is.. Rabbits often feel lonely, so one group of

[algogeeks] Plz help with multidimensional array

2010-07-06 Thread mandeep
char name[3][10]={jan,feb,march}; name[0],name[1],name[2] are the elements of an array 'name'. Can we think of name as an array of pointers where each pointer is of type char (*p)[10]? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] Re: median of array

2010-07-06 Thread Jitendra Kushwaha
do quicksort like operation to find the pivot till you get the pivot of n/2 position recursively. Complexity will be O(n) -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

[algogeeks] amazon:-

2010-07-06 Thread sharad kumar
Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that: i) All the intermediate words must be from the dictionary ii) An ‘operation’ is defined as: a) Delete any character from a string ex dog → do b) Insert any character

[algogeeks] microsoft.

2010-07-06 Thread sharad kumar
Given an array of n numbers in which all the members are less than or equal to k (kn). device an algorithm of order O(k) to find the first repeating element -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Longest palindrome in a given str (less than O(n^2) )

2010-07-06 Thread Jitendra Kushwaha
@Ankit Narang Think about your algo it is not a O(n). First of all you wont get solution comparing start of str1 and end of str2 Their is solution in O(n) other than suffix tree Here is the link http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/ --

Re: [algogeeks] ipc

2010-07-06 Thread harit agarwal
pipes -- 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+unsubscr...@googlegroups.com. For more options, visit this group at

Re: [algogeeks] Re: impossible microsoft puzzle

2010-07-06 Thread Sourashis Roy
u can find the solution to this puzzle here... http://gurmeetsingh.wordpress.com/2009/08/21/puzzle-whats-the-number-on-my-hat/ On Mon, Jul 5, 2010 at 11:03 AM, Nikhil Jindal fundoon...@yahoo.co.inwrote: Again for ur soln, if n is 2 and the numbers are : 2,1 None of them is correct. My

Re: [algogeeks] adobe problem---array

2010-07-06 Thread Chonku
Just to clarify, when you say repeating 1 time means 2 occurences. Similarly, repeating 2 times means 3, etc. ? On Mon, Jul 5, 2010 at 7:18 PM, jalaj jaiswal jalaj.jaiswa...@gmail.comwrote: Given an array of integers where some numbers repeat 1 time, some numbers repeat 2 times and only one

Re: [algogeeks] isr

2010-07-06 Thread harit agarwal
when the system is interrupted then before running ISR set a flag and then run ISR and when it returns from ISR unset the flag after 20ms when system is interrupted again check the flag if(flag is set) means ISR is running else ISR run 20ms -- You received this message because you are

Re: [algogeeks] Need good hashing implementations in Linux (C/C++)

2010-07-06 Thread Jitendra Kushwaha
What about STL map I have used it. but for small data.. It is a standard one and should work for bigger set of data also -- Regards Jitendra Kushwaha MNNIT, Allahabad -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group,

Re: [algogeeks] amazon question

2010-07-06 Thread Jitendra Kushwaha
here is the code which take the root and print the tree in serialized format void serialize(tree *tmp) { if(!tmp) return; printf(%d,tmp-data); if(tmp-right || tmp-left) { printf((); if(tmp-left) serialize(tmp-left); if(tmp-right) {

[algogeeks] cycle in Linked List generalised

2010-07-06 Thread amit
Consider the general fast and slow pointer strategy to detect loop in a LL. Now , Suppose we move the slowPtr 'm' nodes at a time and move the fastPtr 'n' nodes at a time. What are the constraints on 'm' and 'n' so that we that we are able to find whether the list is circular or not? -- You

[algogeeks] memory usage

2010-07-06 Thread sharad
Without using sophisticated debuggers, how do you estimate the memory usage in your program? (Stack/Heap) -- 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

Re: [algogeeks] google

2010-07-06 Thread Anand
if we use array Implementation of queue which has a read and write pointer and both pointer get wrap when it touches the end of the array. if the array get overflow at any point, we remove element pointed by read pointer (ie just increment the read pointer (read_pointer + 1)%arr_size). By doing

Re: [algogeeks] cycle in Linked List generalised

2010-07-06 Thread Anand
you increment slow pointer by 1 and fast pointer by 2 to find a loop in Linked list. On Mon, Jul 5, 2010 at 9:02 PM, amit amitjaspal...@gmail.com wrote: Consider the general fast and slow pointer strategy to detect loop in a LL. Now , Suppose we move the slowPtr 'm' nodes at a time and move

[algogeeks] Re: median of array

2010-07-06 Thread Dave
Of course O(n) is the average complexity. The worst-case complexity is O(n^2). There is a divide and conquer algorithm with O(n) worst-case complexity. Dave On Jul 5, 11:54 pm, Jitendra Kushwaha jitendra.th...@gmail.com wrote: do quicksort like operation to find the pivot till you get the pivot

Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
no FIFO here, the request can be random and hence if the array has say 1,2,3,4,5,6,7 with 1 being least recently used and 7 got the timeslice junst now, if someone requests for say 4, the list should become 1,2,4,5,6,7,4 and if the request is for 8 then it would be 2,3,4,5,6,7,8 FIFO is a BAD

[algogeeks] Re: Amazon Puzzle

2010-07-06 Thread Dave
There are 6 cases to consider (we can list them but we don't know which one applies): 1. Initially, all 4 coins are tails. 2. Initially, all 4 coins are heads. 3. Initially, 3 of the coins are heads, 1 is tails. 4. Initially, 3 of the coins are tails, 1 is heads. 5. Initially, 2 diagonal coins are

[algogeeks] Re: cycle in Linked List generalised

2010-07-06 Thread Dave
gcd(m,n) = 1. Dave On Jul 5, 11:02 pm, amit amitjaspal...@gmail.com wrote: Consider the general fast and slow pointer strategy to detect loop in a LL. Now , Suppose we move the slowPtr 'm' nodes at a time and move the fastPtr 'n' nodes at a time. What are the constraints on 'm' and 'n' so

[algogeeks] Re: cycle in Linked List generalised

2010-07-06 Thread Dave
@Anand. You've described one way to do it, and maybe the most efficient way, but not the only way. Dave On Jul 6, 8:42 pm, Anand anandut2...@gmail.com wrote: you increment slow pointer by 1 and fast pointer by 2 to find a loop in Linked list. On Mon, Jul 5, 2010 at 9:02 PM, amit

Re: [algogeeks] isr

2010-07-06 Thread Ashish Goel
as i understand ISR has two parts, critical and deferable, so when the isr comes, keep this critical part small, need to get into Linux 2.6 kernel to understand this how is this handled Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6,

Re: [algogeeks] memory usage

2010-07-06 Thread Ashish Goel
for heap, i would say usage of malloc_hook refer http://www.kernel.org/doc/man-pages/online/pages/man3/malloc_hook.3.html essentially a layer it put above malloc layer for managing memory allocation here the recording on heap can be done for stack size, print the variable address as soon a

Re: [algogeeks] Plz help with multidimensional array

2010-07-06 Thread Ashish Goel
char name[][10] is a auto variable on stack, so no pointers here Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 7, 2010 at 9:10 AM, UMESH KUMAR kumar.umesh...@gmail.comwrote: char name[][10]={jan,feb,march}; Name is a 2-D

Re: [algogeeks] Re: cycle in Linked List generalised

2010-07-06 Thread Nivedita Rajani
Practically speaking, whatever be the value of m and n we can find out the cycle if existing in O(N) time the condition to find the cycle is (m*x) mod N == (n *x) mod N. where x is the number of iterations required, and we can clearly see that whatever be the value of m and n there is always a

Re: [algogeeks] google

2010-07-06 Thread Anand
Since cache can only store the last n requests, Insert the n+1th request in the cache and delete one of the older requests from the cache. To satisfy the third requirement in the question, we need to implement FIFO. why do we need LRU. question does not speak anything about it. On Tue, Jul 6,

Re: [algogeeks] Need algorithm for Hot data identification

2010-07-06 Thread Ashish Goel
you are right refer http://en.wikipedia.org/wiki/Bloom_filter Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6, 2010 at 10:22 AM, Prashanth prashanths2...@gmail.com wrote: Hi all! A disk is divided into large number of blocks and

Re: [algogeeks] google

2010-07-06 Thread Ashish Goel
let me put it this way, say for last n times you made the same request, how should the cache look like? Does the browser keep history as a stack only? simplest design is to use stack and then parse most commonly used sites, but you would like this to be preprocessed rather than finding at run

Re: [algogeeks] microsoft.

2010-07-06 Thread Anil C R
do you need an algorithm which is O(1) in space? if not it's trivial. Anil On Tue, Jul 6, 2010 at 7:29 PM, sharad kumar sharad20073...@gmail.comwrote: Given an array of n numbers in which all the members are less than or equal to k (kn). device an algorithm of order O(k) to find the first

Re: [algogeeks] adobe problem---array

2010-07-06 Thread Ashish Goel
i thought the same way, but in this case 4 is being repeated twice, but is not nullified it is ctually getting nullified, but it is indeed contributing to bit 2 so how do i rule out 4 here? Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On

Re: [algogeeks] microsoft.

2010-07-06 Thread Ashish Goel
have a hash map trace through all the elements to store the count now trace through the array again and return the element whose count is found to be 2 as the first repeating element Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Wed, Jul 7,

[algogeeks] Re: Need help

2010-07-06 Thread crazysaikat
Hey i mean to say, please help after the contest only, i didn't mean to cheat anyway, its only that i have to leave my net early due to some reason thats why i posted it. On Jul 6, 5:03 pm, Priyanka Chatterjee dona.1...@gmail.com wrote: Contest in running and you are posting the 550 points

Re: [algogeeks] ipc

2010-07-06 Thread Ashish Goel
shared memory not an ipc mechanism?? please get your fundamentals correct refer galvin or boveti or comer Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 6, 2010 at 5:29 PM, harit agarwal agarwalha...@gmail.comwrote: shared memory

[algogeeks] Re: Need help

2010-07-06 Thread crazysaikat
Hey, its on a java applet, you can download it from www.topcoder.com/tc, and enter past competition, SRM 375, in it its the medium level problem, i have copied all the text in the post, please help me, i have got no idea how to tackle such type of problem. On Jul 6, 5:20 pm, Jitendra Kushwaha