[algogeeks] Best way to rank sentences based on similarity from a set of Documents

2012-01-03 Thread Anantha Krishnan
list of sentences ranked in such a way that sentence with FIRST rank is the most similar sentence in all 5 documents, then 2nd then 3rd... Thanks in advance. Regards, Anantha Krishnan -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" grou

Re: [algogeeks] Does anyone have - "UNIX internals the new frontiers by Uresh Vahalia"

2011-08-31 Thread Anantha Krishnan
http://www.eazyupload.net/ukhyxosa On Wed, Aug 31, 2011 at 7:29 PM, Swathi wrote: > > -- > 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, se

Re: [algogeeks] Tree quuestion

2011-08-24 Thread Anantha Krishnan
int getDistance(Tnode *root,Tnode *node,int dist) { if(root==NULL) return 0; if(root==node) return dist; return getDistance(root->left,node,dist+1)|getDistance(root->right,node,dist+1); } Thanks & Regards, Anantha Krishnan On Thu, Aug 25, 2011 at 2:30 AM, ro

Re: [algogeeks] Re: binary tree ques

2011-08-24 Thread Anantha Krishnan
,0)-1); Thanks & Regards, Anantha Krishnan On Wed, Aug 24, 2011 at 11:10 AM, Dheeraj Sharma < dheerajsharma1...@gmail.com> wrote: > let the nodes are stored in array like > > arr[1] > arr[2] > arr[3] > . > . > . > arr[7]. > > where arr is a structure ha

Re: [algogeeks] convert a vector containing octal representation of a number to decimal number

2011-08-21 Thread Anantha Krishnan
Hi Sarvesh, For this problem this is my solution. A=[1,5,6] n=len(A) Ans=[0,1,1,2,1,2,2,3] count=0 for i in range(0,n): count=count+Ans[A[i]] print count Is there any flaw? Thanks & Regards, Anantha Krishnan On Sun, Aug 21, 2011 at 4:25 PM, sarvesh saran wrote: > Hi Prakash, &

Re: [algogeeks] Amazon Question

2011-08-18 Thread Anantha Krishnan
Refer here . On Thu, Aug 18, 2011 at 5:36 PM, Ankur Garg wrote: > Can u provide a bit detail bro !! > > > On Thu, Aug 18, 2011 at 8:04 AM, sagar pareek wrote: > >> Hashing >> :) >> >> On Thu, Aug 18, 2011 at 5:30 PM, Ankur Garg wrote: >> >>> Define a data structure , us

Re: [algogeeks] Amazon Question

2011-08-18 Thread Anantha Krishnan
We can use hash to do all the operations in O(1) time. Thanks & Regards, Anantha Krishnan On Thu, Aug 18, 2011 at 5:30 PM, Ankur Garg wrote: > Define a data structure , using extra memory/space , such that : > > Insert(int a) > Delete(int a) > isPresent(int a) > ge

Re: [algogeeks] Re: |a-b| + |b-c| + |c-a|

2011-08-18 Thread Anantha Krishnan
Yes with my approach answer will be 0. Please check here <http://ideone.com/Q4ivj>. Thanks & Regards, Anantha Krishnan On Thu, Aug 18, 2011 at 1:33 PM, MAC wrote: > in the example below , answer shd be 0 , . by your apraoch this is not > commig > > > 10,25,35 &g

Re: [algogeeks] Re: |a-b| + |b-c| + |c-a|

2011-08-18 Thread Anantha Krishnan
If we move the maximum then difference will get larger but our aim is to minimize the difference. Thanks & Regards, Anantha Krishnan On Thu, Aug 18, 2011 at 1:01 PM, MAC wrote: > as per my understanding , you are increasing the minimum value so that it > reaches closer to the maxi

Re: [algogeeks] Re: |a-b| + |b-c| + |c-a|

2011-08-17 Thread Anantha Krishnan
minimum element. 7.repeat these steps till end of array is reached for atleast one array. Please let me know if you find some difficulties with my explanation. Thanks & Regards, Anantha Krishnan On Thu, Aug 18, 2011 at 10:42 AM, MAC wrote: > any suggestion on how to approach this

Re: [algogeeks] AMAZON Q

2011-07-28 Thread Anantha Krishnan
We must use BIT<http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=binaryIndexedTrees>to solve this problem with O(nlogn). Here <http://ideone.com/IaU3F> is my implementation. Thanks & Regards Anantha Krishnan On Tue, Jul 26, 2011 at 7:18 PM, Piyush Sinha wro

Re: [algogeeks] MS interview:

2011-07-27 Thread Anantha Krishnan
String file:filelist) { _printTree(root+File.separator+file, depth+1); } return; } return; } public static void printTree(String root) { _printTree(root, 0); }* Thanks & Regards Anantha Krishnan On Wed, Jul 2

Re: [algogeeks] Non-redundant permutations of the string

2011-07-20 Thread Anantha Krishnan
@SkRiPt KiDdIe I got your logic. Nice. Thanks. Regards Anantha Krishnan On Wed, Jul 20, 2011 at 2:04 PM, SkRiPt KiDdIe wrote: > While you are on a state do not change ur state on encountering a specific > character if u have already done so earlier.This check in addition to the &

[algogeeks] Non-redundant permutations of the string

2011-07-19 Thread Anantha Krishnan
Can somebody please help me to print all non-redundant permutations of the string. For ex. If string is "abab" the permutations are {baab, abba, abab, baba, bbaa, aabb} Thanks & Regards Anantha Krishnan -- You received this message because you are subscribed to the Google Grou

Re: [algogeeks] Re: How to find power set of a subset.

2011-07-18 Thread Anantha Krishnan
<http://ideone.com/3C0Ry>: Implementation is based on this<http://www.mathsisfun.com/sets/power-set.html> approach. Thanks & Regards Anantha Krishnan On Mon, Jul 18, 2011 at 8:48 PM, saurabh singh wrote: > Efficient recursive approaches are also welcome. > > &g

Re: [algogeeks] Re: find sol!!

2011-07-10 Thread Anantha Krishnan
For, [ n*n!+(n+1)*(n+1)!+.+(n+m)*(n+m)! ] / (n+m+1)! = 1 - n!/(n+m+1)! On Sun, Jul 10, 2011 at 1:00 PM, Puneet Ginoria wrote: > n*n! = (n+1)! - n! > > > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send

Re: [algogeeks] Re: Sort - Consecutive Array in O(n)

2011-07-09 Thread Anantha Krishnan
gt; > > > does it work ? > > > > Thanks, > > Sathaiah > > > > On Wed, Jul 6, 2011 at 11:45 AM, Anantha Krishnan < > > > > > > > > > > > > > > > > ananthakrishnan@gmail.com> wrote: >

Re: [algogeeks] Improve upon O(m^2)

2011-07-08 Thread Anantha Krishnan
I guess it can be done in O(mlog m) TC with* heap sort* On Fri, Jul 8, 2011 at 1:56 AM, Dumanshu wrote: > given two sorted arrays a[m] b[2*m], each contains m elements only. > You > need to merge those two arrays into second array b[2*m]. > anything better than O(m^2) > > -- > You received

Re: [algogeeks] Sort - Consecutive Array in O(n)

2011-07-05 Thread Anantha Krishnan
Check this *int isconsecutive(int a[], int n) {* *if (n < 1) {* *return 0;* *}* *int max = a[0], min = a[0];* *int i = 0;* * * *int *hash = (int*) calloc(n, sizeof (int));* * * *//find min and max from the array* *for (i = 1; i < n; i++) {* *if (a[i] < m

Re: [algogeeks] Flatten a BST to produce inorder traversal

2011-07-04 Thread Anantha Krishnan
nt->data); current = current->right; } } }} You can find my complete code here <http://ideone.com/qYKMW>. Thanks & Regards Anantha Krishnan On Tue, Jul 5, 2011 at 7:52 AM, Ashish Goel wrote: > convert BST into DLL > > refer stan

[algogeeks] Data Structure for Desktop Search

2011-07-04 Thread Anantha Krishnan
Hi All, I want to know which data structure will be efficient for a desktop search tool similar to Ava Find <http://www2.think-less-do-more.com/avafind/>. Thanks & Regards Anantha Krishnan -- You received this message because you are subscribed to the Google Groups "Algorithm G

[algogeeks] CLRS help

2011-07-04 Thread Anantha Krishnan
lengths. Thanks & Regards Anantha Krishnan -- 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...@go

Re: [algogeeks] find output

2011-07-03 Thread Anantha Krishnan
y=*x++; this line executes like this: y=*x; x=x+1; // post increment Regards Anantha Krishnan On Mon, Jul 4, 2011 at 10:36 AM, amit kumar wrote: > i think d answer sud be 10. > but it comes out to be 5. > xplain plz > > > On Mon, Jul 4, 2011 at 10:30 AM, Sandeep Jain w

Re: [algogeeks] Re: Interview Question

2011-07-03 Thread Anantha Krishnan
I guess this question is similar to anagram. On Mon, Jul 4, 2011 at 1:07 AM, Arpit Sood wrote: > Hey, > what is the solution with XOR, methods mentioned above seem to > fail there any reference ? > > > On Sun, Jul 3, 2011 at 10:39 PM, Deoki Nandan wrote: > >> there is no possibl

Re: [algogeeks] Longest substring 0's & 1's

2011-07-01 Thread Anantha Krishnan
@Sunny Thanks for your algorithm :) It works well. http://ideone.com/MHOtR Thanks & Regards Anantha Krishnan On Fri, Jul 1, 2011 at 4:38 PM, sunny agrawal wrote: > String = 1 0 1 1 0 1 1 1. > 1. make the array = 1 -1 1 1 -1 1 1 1 > 2. after second operation > array = 1 0 1 2

Re: [algogeeks] Longest substring 0's & 1's

2011-07-01 Thread Anantha Krishnan
re did you find these constraints ?? > > > On Fri, Jul 1, 2011 at 4:21 PM, Anantha Krishnan < > ananthakrishnan@gmail.com> wrote: > >> Thanks. >> >> Can you plz explain for input 1 0 1 1 0 1 1 1. >> >> Also I want solution in O(n) TC an

Re: [algogeeks] Longest substring 0's & 1's

2011-07-01 Thread Anantha Krishnan
Thanks. Can you plz explain for input 1 0 1 1 0 1 1 1. Also I want solution in O(n) TC and O(1) SC. Regards Anantha Krishnan On Fri, Jul 1, 2011 at 4:13 PM, sunny agrawal wrote: > Take an array of size of the length of the string. > fill the array positions with one where string cont

[algogeeks] Longest substring 0's & 1's

2011-07-01 Thread Anantha Krishnan
Given a string containing 0's and 1's. One would need to find the longest sub-string such that the count of 0's is equal to the count of 1's in the largest sub string. Regards Anantha Krishnan -- You received this message because you are subscribed to the Google Groups &qu

Re: [algogeeks] Re: Constructing a Binary Search Tree from Post Order traversal-Possible or not

2011-06-30 Thread Anantha Krishnan
Check this http://ideone.com/ARsJ1 On Thu, Jun 30, 2011 at 7:48 PM, oppilas . wrote: > I am unable to find a test case where this particular approach fails( I > hardly thinks it's correct but anyway here it is). > > We make the last element the root of the BST. > And keep inserting each element o

Re: [algogeeks] linked list

2011-06-30 Thread Anantha Krishnan
@sagar pareek If there are more fields in the node like: struct node{ int data; float mark; char ch; struct node *link; }; Here swapping *data* alone will corrupt the list right!! On Thu, Jun 30, 2011 at 4:38 PM, sagar pareek wrote: > Here is one approach which works :) > >

Re: [algogeeks] linked list

2011-06-30 Thread Anantha Krishnan
Check this http://ideone.com/1I40z On Wed, Jun 29, 2011 at 8:04 PM, Nishant Mittal wrote: > segregate even and odd nodes in a singly linked list.Order of even and > odd numbers must be same... > e.g:- > i/p list is 4->1->3->6->12->8->7->NULL > o/p list 4->6->12->8->1->3->7->NULL > > -- > You rec

Re: [algogeeks] Re: Amazon Telephonic Interview Questions

2011-06-30 Thread Anantha Krishnan
if (head == NULL)* *return root;* *root = head->data;* *} while (root->right == node || root->right == NULL);* *if (root->right != NULL)* *root = root->right;* *}* *}* *return NULL;* *}* Tha

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread Anantha Krishnan
http://ideone.com/oEfLE On Thu, Jun 30, 2011 at 12:04 AM, Anantha Krishnan < ananthakrishnan@gmail.com> wrote: > I wish to say that we should not use any inbuilt functions. > > > On Wed, Jun 29, 2011 at 11:43 PM, oppilas . wrote: > >> What I wanted to say that,

Re: [algogeeks] Amazon - ispasswordvalid() implementation

2011-06-29 Thread Anantha Krishnan
I wish to say that we should not use any inbuilt functions. On Wed, Jun 29, 2011 at 11:43 PM, oppilas . wrote: > What I wanted to say that, it's a trivial question for algorithmic point of > view. > You could have just implemented a normal function without worrying about > complexity because the

Re: [algogeeks] BST

2011-06-29 Thread Anantha Krishnan
Check this http://ideone.com/o8gF2 On Wed, Jun 29, 2011 at 10:28 PM, Swathi wrote: > This should be very simple... follow inorder.. > > Inorder(Node* node, int counter, int N) > { > if(node == null)return; > Inorder(node->left, counter, N); > counter++; > if(counter == N) > { > print(node

Re: [algogeeks] GOOGLE QUESTION

2011-06-29 Thread Anantha Krishnan
How we will get phone number of a particular person? Thanks & Regards, Anantha Krishnan On Wed, Jun 29, 2011 at 6:22 PM, sudheer kumar < chigullapallysudh...@gmail.com> wrote: > USE TRIE > > > On Wed, Jun 29, 2011 at 6:10 PM, shady wrote: > >> go through the ar

Re: [algogeeks] Re: output plzz

2011-06-25 Thread Anantha Krishnan
Good. On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV wrote: > sizeof returns size_t values and size_t is "typedef unsigned int > size_t;" > but when you compare it with -1(int) ,d=-1 is converted to unsigned > int > which becomes very large (INT_MAX) > and d (INT_MAX) > 7 so the loop is never

Re: [algogeeks] Re: char *arr and char arr[]

2011-06-25 Thread Anantha Krishnan
dify it like: *char *str=(char *)malloc(1024);* Thanks & Regards, Anantha Krishnan On Sat, Jun 25, 2011 at 2:16 PM, Adarsh wrote: > char array[] = "hello"; > char *pointer = "hello"; > > array is an array, enough to store sequence of characters and '\0'

Re: [algogeeks] Google Interview

2011-06-24 Thread Anantha Krishnan
understanding) B[-1]=-INF A[0]=20 B[0]=10 [not in asc order] A[-1]=-INF B[0]=10 A[0]=20 [in asc order] We got the Kth(4th) smallest element which is 10. Thanks & Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 11:20 PM, Akshata Sharma wrote: > @Anantha > can you explain the logic please

Re: [algogeeks] Google Interview

2011-06-24 Thread Anantha Krishnan
Check this http://ideone.com/C8fQC <http://ideone.com/C8fQC>Thanks & Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 10:18 PM, Decipher wrote: > Can anybody please explain how to solve this question with logarithmic > time complexity ? > > Write the code/algorithm to

Re: [algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Anantha Krishnan
ked list. Reason > >> because it requires only Θ(1) extra space only and generally beats > >> other algorithms like quicksort,heapsort for sorting linked lists. The > >> overall complexity remain O(N log N) even in the worst case > >> > >> On 6/23/11, Anantha Krishna

[algogeeks] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Anantha Krishnan
Hi All, Can someone explain about the time complexity of Merge sort(Linked list with billions of node)? There is no way to find the middle of sub-list without traversing completely. Please clear my doubts. Thanks & Regards, Anantha Krishnan -- You received this message because you

Re: [algogeeks] Binary Tree

2011-06-22 Thread Anantha Krishnan
= new Node(8, NULL, g);* *Node* a = new Node(1, b, c);* *Root = a;* *}* * * and check here <http://ideone.com/YF9qi>. Let me know the result. Thanks & Regards Anantha Krishnan On Thu, Jun 23, 2011 at 2:06 AM, Jitendra singh wrote: > I think this solution is wron

[algogeeks] Binary Tree Diameter

2011-06-22 Thread Anantha Krishnan
Hi All, I have written code for finding diameter of a binary tree here http://ideone.com/WHg9t Is it correct? Do I need to make any changes there? Thanks & Regards Anantha Krishnan -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"

Re: [algogeeks] Binary Tree

2011-06-22 Thread Anantha Krishnan
I modified Sunny's code to get Node X and Node Y. http://ideone.com/YF9qi Can we do better than this? Thanks & Regards, Anantha Krishnan On Wed, Jun 22, 2011 at 11:11 AM, oppilas . wrote: > Sunny, > Can but can we modify this code to get the *node X and node Y*?. > > >

Re: [algogeeks] Binary Tree

2011-06-21 Thread Anantha Krishnan
@sunny agrawal *Thanks a lot.* *Great code. I got the logic now.Thanks again.* * * Thanks & Regards, Anantha Krishnan On Tue, Jun 21, 2011 at 11:52 PM, sunny agrawal wrote: > see this > * > https://ideone.com/1ZtIq* > > > On Tue, Jun 21, 2011 at 10:23 PM, Anantha Krishn

Re: [algogeeks] Binary Tree

2011-06-21 Thread Anantha Krishnan
Thanks. I expect more details in implementation point of view. Thanks & Regards, Anantha Krishnan On Tue, Jun 21, 2011 at 6:41 PM, sunny agrawal wrote: > @Piyush > good to start with > But i think a recursive O(n) is possible > in downward calls pass sum from root to node >

[algogeeks] Binary Tree

2011-06-21 Thread Anantha Krishnan
& Regards Anantha Krishnan -- 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. Fo

Re: [algogeeks] Finding total number of inversions in an array in O(nlogn) complexity .

2011-06-09 Thread Anantha Krishnan
Hello, Here is the code : #include int mergeandcountinversion(int a[],int begin,int middle,int end,int z) { int length=end-begin+1; int tmp[length]; int i1=begin,i2=middle+1,it=0,i=0; for(i=0;imiddle) { for(;i2<=end;i2++) { tmp[it]=a[i2]; it++; } break; } if(i2>end) { for(;i1<=middle;i1++)