[algogeeks] Interview Question

2013-07-27 Thread enchantress
Given m*n matrix and k students how can they be placed such that cheatig is minimised. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [algogeeks] Appropriate data structure

2012-07-15 Thread enchantress
It says K days if you keep heap the order of values gets disturbed. How are last k values accessed then? On Sunday, 15 July 2012 12:46:02 UTC+5:30, adarsh kumar wrote: Min or max heap accordingly. This will do the job in O(log n) time. On Sun, Jul 15, 2012 at 1:25 AM, Navin Kumar

[algogeeks] Re: Secure computation of Intersection of two sets

2012-07-09 Thread enchantress
Give the first first number and set of cosecutive diffrence. On Sunday, 8 July 2012 10:55:55 UTC+5:30, Sairam wrote: How do you find the intersection of two sets in a secured way? Which means imagine a situation where there is a client who has got a set S1={1,2,3}, and there is a server

[algogeeks] Most compatible people

2012-07-05 Thread enchantress
Given a list of people and music bands they like, two people are compatible if they have at least 2 bands in common. The compatibility of two people is directly proportional to the number of bands they like in common. Find the two most compatible people that is having maximum number of bands

[algogeeks] Re: Reverse Queue

2012-06-20 Thread enchantress
Queues are basically linked lists with head and tail pointers. It is possible to reverse the list by change of pointers in O(n) time n O(1) space. PS: Not considering queue ADT with enqueue dequeue operations. On Wednesday, 20 June 2012 18:34:46 UTC+5:30, Navin Kumar wrote: How to reverse a

[algogeeks] Re: Microsoft question

2012-06-18 Thread enchantress
Hi all, A variation of selection sort can be used which takes O(nk) time. for i 1 to k min_index = i for j i+1 to n if a[j] a[min_index] min_index = j swap(a[i],a[min_index]) required element : a[k] On Sunday, 17 June 2012 08:13:18 UTC+5:30, Prem Nagarajan wrote: Give

Re: [algogeeks] Find the Max from each sub-array of size k

2012-06-17 Thread enchantress
Your algo is good but i don get the part where A[i] (current element) is less than the first element? Do we enqueue it? And if yes, when the front element is popped out , how is the next max found in front of the queue? If you could give an example with the growing queue. On Friday, 2

[algogeeks] Precedence or Associativity

2012-06-17 Thread enchantress
Consider the following code: int i=0,j=0,k=0; int x = ++i || ++j ++k; O/P: x=1,i=1,j=0,k=0 Now, the logic operators are evaluated left to right and if the output is determined by left hand side expression right hand side is not evaluated. But the precedence of || hence ++j++k should be

[algogeeks] Re: Amazon Interview Question

2012-06-16 Thread enchantress
Store each of the words in array in a trie and mark the end of the word by its corresponding entry in the second array. Now if u are searching for a word it'll take O(length of word) if there is a mismatch at any point you know the word is not present in array1 and add it to the trie or else

[algogeeks] Re: Amazon Interview Question

2012-06-15 Thread enchantress
You can use a trie with end of word marked by its corresponding entry in array. On Thursday, 14 June 2012 13:01:00 UTC+5:30, Mohit Rathi wrote: Hi, *There are two arrays of length 100 each. Each of these has initially n (n=100) elements. First array contains names and the second array

[algogeeks] Re: No of tri-angles

2012-06-15 Thread enchantress
@amol True, but the question suggests they are . If they arent then it'll require sorting the array and then binary search for largest index for which a[index] a[i]+a[j] .. Then required triangles are index-j for looped values i and j. On Friday, 15 June 2012 20:15:26 UTC+5:30, Amol Sharma

[algogeeks] Re: No of tri-angles

2012-06-14 Thread enchantress
Use two loops: num_triangles = 0 for i:1 to (N-1)/2 for j:i+1 to i+jN num_triangles += N-(i+j) This gives values in increasing order such that cba (c,b,a being lengths of sides of the triangle) and sum of any two sides is greater than the third. Consider :

[algogeeks] Re: No of tri-angles

2012-06-14 Thread enchantress
My bad.. it should be this: num_triangles = 0 for i:2 to N-2 for j:i+1 to N-1 num_triangles += i+j=N ? i-1:N-j This gives values in increasing order such that cba (c,b,a being lengths of sides of the triangle) and sum of any two sides is greater than the third.