Re: [algogeeks] Re: Median of 2D matrix

2011-11-06 Thread mohit verma
@Gene As i said in my earlier post right to left diagonal partitions the martix into 2 equal number of elements. So now the median must be in this diagonal. Now our focus is on finding median of this diagonal only. I think this works fine. Can u give some test case for which it fails? On Sun, Nov

Re: Re: Re: [algogeeks] Re: Modular arithmetic + Combinatorics

2011-11-05 Thread mohit verma
@ Dave I think your solution wont work for the cases like (MAX_INT) C (MAX_INT-1). On Thu, Nov 3, 2011 at 10:20 PM, vaibhavmitta...@gmail.com wrote: correction: if P is prime VM NSIT, Dwarka On , vaibhavmitta...@gmail.com wrote: Use Lucas Theorem is P is prime. VM NSIT, Dwarka

Re: Re: Re: [algogeeks] Re: Modular arithmetic + Combinatorics

2011-11-05 Thread mohit verma
@ myself Dave's solution works fine. I should have close look at it. On Sat, Nov 5, 2011 at 12:17 PM, mohit verma mohit89m...@gmail.com wrote: @ Dave I think your solution wont work for the cases like (MAX_INT) C (MAX_INT-1). On Thu, Nov 3, 2011 at 10:20 PM, vaibhavmitta...@gmail.com

Re: [algogeeks] Re: Designing Data Structure

2011-11-05 Thread mohit verma
@ Gene : I think your remove() function takes O(n) time in case if all n numbers hash to same bucket. Could you please elaborate on unbiased_hash() function? Can't we do it like this : rand() % TABLE_SIZE coz rand() generates uniformly distribution of numbers. On Fri, Nov 4, 2011 at 1:47 AM,

Re: [algogeeks] Re: Binary tree to BST

2011-11-05 Thread mohit verma
another way is : convert binary tree to link list , sort the list and using divide and conquer approach create the BST. From link list to BST : find mid of sorted link list , make it root node and put left of it to recursive(list,start,mid-prev) and root-right=recursive(list,mid-next,last); Let

[algogeeks] Social graph labeling

2011-11-04 Thread mohit verma
Hi guys, Social sites like facebook or linkedin must be having some vertex labelling techniques. I cant' imagine what labelling they use since there are trillions of nodes in there network ( coz simple integer or alphanumeric labelling will not be efficient enough as far as i think). Can someone

Re: [algogeeks] Re: Median of 2D matrix

2011-11-04 Thread mohit verma
I think this can be done in O(n) time simply by finding the median of elements at DIAGNOL starting from right corner to left corner. Coz as elements are sorted row-wise and column-wise , it implies that elements below this diagonal are all greater than elements on this diagonal and all above this

Re: [algogeeks] Dp solution for this problem?

2011-10-31 Thread mohit verma
need to consider the index of the array as the the vertices and the weigjht as the the value for the movement from the present vertex to it's connecting neighbour .. On 10/31/11, mohit verma mohit89m...@gmail.com wrote: Given a matrix you have to find the shortest path from one point

Re: [algogeeks] Re: Unique partition

2011-10-31 Thread mohit verma
For the array .. And for K=3 Ur algo will give (1 1 1) (1 1 1 ) (3 5 6) On 10/30/11, mohit verma mohit89m...@gmail.com wrote: sort the array : O(nlogn) keep an array/map containing frequency of each element in sorted array : O(n) v[n/k][k] - 2-D array of ints containing final partitions

Re: [algogeeks] Re: Unique partition

2011-10-31 Thread mohit verma
or vertically will fail we need to fill these both horizontally and vertically at the same time depending upon the frequency of elements. On Mon, Oct 31, 2011 at 6:16 PM, mohit verma mohit89m...@gmail.comwrote: Hi SAMM, The above code is not clear enough to understand . Sorry for that. My idea

Re: [algogeeks] Dp solution for this problem?

2011-10-31 Thread mohit verma
that there maybe negative weights then you will need to use bellmann ford which is a DP algo. On Mon, Oct 31, 2011 at 7:40 AM, mohit verma mohit89m...@gmail.comwrote: I knew this could be done using Min Path finding algo. But what about DP for this problem , guys? On Mon, Oct 31, 2011 at 3:49 AM, SAMM

Re: [algogeeks] Re: What Data Structure to use ?

2011-10-31 Thread mohit verma
One (compressed-optional) prefix trie with each course ptrs to students and another prefix tree for students having ptrs to courses. Guaranteed O(m) search time instead of O(n*m) if using hash table where m avg size of word at hand to be compared to n nodes. On Sun, Oct 30, 2011 at 7:31 PM,

Re: [algogeeks] Re: What Data Structure to use ?

2011-10-31 Thread mohit verma
@shashank , i agree. To reduce this overhead , we can implement prefix trie in bit-form or DAWG or lots of compression techniques are there at the cost of complex coding. On Tue, Nov 1, 2011 at 12:35 AM, WgpShashank shashank7andr...@gmail.comwrote: @Mohit Space Overhead Will be more if m,n

Re: [algogeeks] Re: Unique partition

2011-10-30 Thread mohit verma
sort the array : O(nlogn) keep an array/map containing frequency of each element in sorted array : O(n) v[n/k][k] - 2-D array of ints containing final partitions. for i=1 to n/k { int count=0; for(j=0;jn count k;j++) { if( freq(a[i])==0) continue; //say array is used

[algogeeks] Dp solution for this problem?

2011-10-30 Thread mohit verma
Given a matrix you have to find the shortest path from one point to another within the matrix. The cost of path is all the matrix entries on the way. You can move in any direction (up, down, left, right, diagonally) e.g. 5 9 10 1 3 7 4 4 8 2 1 9 So shortest path from (0,0) to (2,2) is

Re: [algogeeks] Re: Modular arithmetic

2011-10-29 Thread mohit verma
You can do something like this: ( n* alpha) * ( m*alpha) *p where 0alpha1 which maps product onto (0,1) interval. You can use golden ration instead. On Sat, Oct 22, 2011 at 9:45 PM, Aamir Khan ak4u2...@gmail.com wrote: On Sat, Oct 22, 2011 at 9:04 PM, Mad Coder

Re: [algogeeks] Re: Find all possible combination of integers for a given sum

2011-10-28 Thread mohit verma
ohh , the number can repeat itself. I dint notice that. On Fri, Oct 28, 2011 at 4:02 PM, mohit verma mohit89m...@gmail.com wrote: something like this : for(int i=0;temp=sum , isum/2;i++) { temp=temp-i; for(int j=i+1;jtemp;j++) couti j temp-j\n; } But there is a problem with code

Re: [algogeeks] Re: Find all possible combination of integers for a given sum

2011-10-28 Thread mohit verma
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. -- *MOHIT VERMA

Re: [algogeeks] Re: Directi Questions - needed answers

2011-10-28 Thread mohit verma
@ankur - Ans-9 how can it be log n. The heap given is Max heap. I think it should be O(n) using array or tree traversal (as heap is implemented) keeping current min at hand. Correct me if m wrong. On Sat, Oct 15, 2011 at 12:14 PM, shady sinv...@gmail.com wrote: already been answered... :-/

Re: [algogeeks] Intersection of arrays

2011-10-27 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Re: Find the later version

2011-10-12 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: MICROSOFT WRITTEN IN VASAVI

2011-09-14 Thread mohit verma
this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Re: Need algorithm asap

2011-09-07 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] MICROSOFT

2011-09-04 Thread mohit verma
this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- 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

Re: [algogeeks] MICROSOFT

2011-09-04 Thread mohit verma
it would be better if we insert values in array in while loop and then outside call makeheapk() and then return topheap(); this will reduce the heap making complexity. On Sun, Sep 4, 2011 at 2:29 PM, mohit verma mohit89m...@gmail.com wrote: int funkth(node *root,int k) { queuenode * q

Re: [algogeeks] Tejas networks

2011-09-04 Thread mohit verma
?hl=en. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: character count in array

2011-09-04 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You

Re: [algogeeks] Re: Need algorithm asap

2011-09-03 Thread mohit verma
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. -- *MOHIT VERMA* -- You received

Re: [algogeeks] Re: Need algorithm asap

2011-09-03 Thread mohit verma
this line is unnecessary if(result[i]==1) continue; I think this algo is good enough. But any improvements? -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
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. -- *MOHIT

Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
Ohh my bad. the complexity should be O(nlogn) + O(mlogm) +O(m) = O(tlogt) where t=max(m,n) On Sat, Sep 3, 2011 at 11:46 PM, mohit verma mohit89m...@gmail.com wrote: create a binary search tree by scanning the whole array and if the value already exists increase count field in that node O(nlogn

Re: [algogeeks] MICROSOFT

2011-09-03 Thread mohit verma
, mohit verma mohit89m...@gmail.comwrote: Ohh my bad. the complexity should be O(nlogn) + O(mlogm) +O(m) = O(tlogt) where t=max(m,n) On Sat, Sep 3, 2011 at 11:46 PM, mohit verma mohit89m...@gmail.comwrote: create a binary search tree by scanning the whole array and if the value already exists

Re: [algogeeks] Amazon - Coding Round-2 Qn

2011-08-31 Thread mohit verma
. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
=O(nlog n) for random k. On Wed, Aug 31, 2011 at 9:15 PM, mohit verma mohit89m...@gmail.com wrote: @ dave- commplexity of radix sort is = O(n log n). so better use heap sort. On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da...@juno.com wrote: @Bharatkumar: You've tacitly assumed

Re: [algogeeks] graph

2011-08-31 Thread mohit verma
. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
: No. Radix sort on a fixed data type is O(n) in time, and uses no data comparisons. Dave On Aug 31, 10:45 am, mohit verma mohit89m...@gmail.com wrote: @ dave- commplexity of radix sort is = O(n log n). so better use heap sort. On Wed, Aug 31, 2011 at 4:07 PM, Dave dave_and_da

Re: [algogeeks] graph

2011-08-31 Thread mohit verma
@mac - yeah you were right. Normally we number the vertices and forget about their co-ordinates in programming :) -- 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

Re: [algogeeks] Re: finding duplicates

2011-08-31 Thread mohit verma
the digits as subscripts. Other than moving the data around, this is the only use the radix sort makes of the sort keys. Dave On Aug 31, 11:06 am, mohit verma mohit89m...@gmail.com wrote: Is anything specific about digits of numbers given in above question? If no then as i said Yeah

Re: [algogeeks] Re: How to save a binary search tree space efficiently

2011-08-28 Thread mohit verma
. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
7 8 2 4 2 1 3 9 Could someone pleases modify this solution to print tree in top-down fashion? On Sun, Aug 28, 2011 at 11:38 PM, Rishabbh A Dua duarish...@gmail.comwrote: mohit, wat if the tree is growing dynamically? On Sun, Aug 28, 2011 at 11:27 PM, mohit verma mohit89m

Re: [algogeeks] Re: Print tree like a tree

2011-08-28 Thread mohit verma
I think for that we need to re-traverse the tree - in first recursion counting the levels and second time printing values and spaces accordingly. On Sun, Aug 28, 2011 at 11:50 PM, mohit verma mohit89m...@gmail.com wrote: i 've already mentioned if number of levels is known. Well for dynamic

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread mohit verma
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. -- *MOHIT VERMA* -- You received

[algogeeks] map problem

2011-08-24 Thread mohit verma
without using extra map? -- *MOHIT VERMA* -- 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

Re: [algogeeks] Re: map problem

2011-08-24 Thread mohit verma
options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- 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

Re: Re: [algogeeks] Re: array question

2011-08-15 Thread mohit verma
from array 1 on array 2? overall complexity : O(nlogn) On 14 August 2011 18:46, mohit verma mohit89m...@gmail.com wrote: example: array 1 :: 1 2 3 4 5 6 7 8 9 10 15 array 2:: 23 34 56 13 15 57 432 348 On Sun, Aug 14, 2011 at 6:44 PM, shady sinv...@gmail.com wrote

[algogeeks] array question

2011-08-14 Thread mohit verma
given two arrays : with all distinct elements but one element in common. Find the common element in optimal time. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] array question

2011-08-14 Thread mohit verma
example: array 1 :: 1 2 3 4 5 6 7 8 9 10 15 array 2:: 23 34 56 13 15 57 432 348 On Sun, Aug 14, 2011 at 6:44 PM, shady sinv...@gmail.com wrote: meaning ? what is a common element ? example ??? On Sun, Aug 14, 2011 at 6:37 PM, mohit verma mohit89m...@gmail.comwrote

Re: [algogeeks] Re: Problems on Linked List

2011-08-11 Thread mohit verma
this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group

Re: [algogeeks] Design a concurrent hash table

2011-08-11 Thread mohit verma
. -- *MOHIT VERMA* -- 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

[algogeeks] Novell questions

2011-08-11 Thread mohit verma
Hey guys, can anyone post some written and interview question asked by Novell? -- *MOHIT VERMA* -- 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

[algogeeks] constness in c++

2011-08-08 Thread mohit verma
? -- *MOHIT VERMA* -- 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

Re: [algogeeks] constness in c++

2011-08-08 Thread mohit verma
to an integer, which I think can be changed. See if the code I suggested still does the same as your version... On 8 August 2011 19:53, mohit verma mohit89m...@gmail.com wrote: In c++ int d=1; const int *const ptr = d; means ptr is const ptr to const object .So neither ptr nor d can be changed

Re: [algogeeks] constness in c++

2011-08-08 Thread mohit verma
got it.. thanks guys On Mon, Aug 8, 2011 at 8:00 PM, mohit verma mohit89m...@gmail.com wrote: No .. in this case it flags error. On Mon, Aug 8, 2011 at 7:58 PM, Dipankar Patro dip10c...@gmail.comwrote: does the answer still remain same if you do the following: const int d=1; const int

Re: [algogeeks] pls help

2011-08-06 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] pls help

2011-08-06 Thread mohit verma
ohh my bad... it is working fine for all cases :) On Sat, Aug 6, 2011 at 11:56 AM, mohit verma mohit89m...@gmail.com wrote: what if the alphabet is {a,b,c,d} and we have to print substrings of length 2 or 3 ? On Sat, Aug 6, 2011 at 11:01 AM, Tushar Bindal tushicom...@gmail.comwrote

Re: [algogeeks] Directi Question

2011-08-06 Thread mohit verma
. 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. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] hash table

2011-08-05 Thread mohit verma
this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- 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

Re: [algogeeks] puzzle

2011-08-04 Thread mohit verma
. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Google Telephonic interview

2011-08-04 Thread mohit verma
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. -- *MOHIT VERMA

Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-04 Thread mohit verma
/algogeeks?hl=en. -- *MOHIT VERMA* -- 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

Re: [algogeeks] Google Telephonic interview

2011-08-04 Thread mohit verma
task with its corresponding running time and associate function. In that case how will find the task which has the closed running time. If you use min heap it would be easy to find the task that has closest runing time in O(1) complexity. On Thu, Aug 4, 2011 at 10:57 AM, mohit verma mohit89m

Re: [algogeeks] My senior's Interview Experience at Microsoft who got selected and offered a 16lacks package

2011-08-04 Thread mohit verma
ohh my bad... the array should be 1-D with N ptrs for each fgets() we put returned ptr to array and after getting loop back N times. On Thu, Aug 4, 2011 at 11:52 PM, mohit verma mohit89m...@gmail.com wrote: How did the microsoft guy write tail without using seek()? one solution

Re: [algogeeks] Re: friend function

2011-08-04 Thread mohit verma
/algogeeks?hl=en. -- *MOHIT VERMA* -- 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

Re: [algogeeks] TLE again

2011-08-02 Thread mohit verma
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. -- *MOHIT VERMA* -- You received this message

[algogeeks] pointer access in c++

2011-07-28 Thread mohit verma
to private members of base class(Or even copy them to derived class memory space in private section). So how can the above program can run successfully? Could someone elaborate on inheritance internals : what is going on in this case? -- *MOHIT VERMA* -- You received this message

Re: [algogeeks] Re: Microsoft Question!

2011-07-21 Thread mohit verma
email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *MOHIT VERMA* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

[algogeeks] how to check a problem p or np complete or incomplete

2010-08-29 Thread mohit verma
hi all, can anyone tell me how can one recognize a given problem whether it is NP complete or incomplete or N complete in some considerable time limit. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to