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

2012-01-03 Thread Anantha Krishnan
be 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 group. To post

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 chukka.swa...@gmail.com 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

Re: [algogeeks] Re: binary tree ques

2011-08-24 Thread Anantha Krishnan
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 having int x,int y. i=1 initally we set the root(i.e arr[i]) x and y = n/2,log

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, rohit raman.u

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 aquarian.thun...@gmail.comwrote

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

2011-08-18 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 macatad...@gmail.com wrote: any suggestion on how to approach

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 macatad...@gmail.com wrote: as per my understanding , you are increasing the minimum value so that it reaches closer

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 macatad...@gmail.com wrote: in the example below , answer shd be 0 , . by your apraoch this is not commig 10,25,35 10,25,30 5

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 ankurga...@gmail.com wrote: Define a data structure , using extra memory/space , such that : Insert(int a) Delete(int a) isPresent(int a) get(int a) All

Re: [algogeeks] Amazon Question

2011-08-18 Thread Anantha Krishnan
Refer here http://ideone.com/X77wm. On Thu, Aug 18, 2011 at 5:36 PM, Ankur Garg ankurga...@gmail.com wrote: Can u provide a bit detail bro !! On Thu, Aug 18, 2011 at 8:04 AM, sagar pareek sagarpar...@gmail.comwrote: Hashing :) On Thu, Aug 18, 2011 at 5:30 PM, Ankur Garg

Re: [algogeeks] AMAZON Q

2011-07-28 Thread Anantha Krishnan
We must use BIThttp://www.topcoder.com/tc?module=Staticd1=tutorialsd2=binaryIndexedTreesto 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 ecstasy.piy...@gmail.comwrote: You

Re: [algogeeks] MS interview:

2011-07-27 Thread Anantha Krishnan
) { _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 27, 2011 at 1:21 PM, geek

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 anuragmsi...@gmail.comwrote: 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

[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 Groups Algorithm Geeks

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 punnu.gino...@gmail.comwrote: n*n! = (n+1)! - n! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

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

2011-07-09 Thread Anantha Krishnan
, if it is negative, find the min value, assume it is X, add by (-X)+1)) Now assume numbers are M, compute the product of the numbers and compute M! and check if they are equal. does it work ? Thanks, Sathaiah On Wed, Jul 6, 2011 at 11:45 AM, Anantha Krishnan

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 duman...@gmail.com 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) --

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

2011-07-06 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]

[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...@googlegroups.com

[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 Geeks group. To post

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

2011-07-04 Thread Anantha Krishnan
http://ideone.com/qYKMW. Thanks Regards Anantha Krishnan On Tue, Jul 5, 2011 at 7:52 AM, Ashish Goel ashg...@gmail.com wrote: convert BST into DLL refer stanford tree recursion problem Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Mon

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 amitthecoo...@gmail.com 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 sandeep6

[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 Algorithm Geeks group

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 sunny816.i...@gmail.comwrote: Take an array of size of the length of the string. fill the array positions with one where

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

2011-07-01 Thread Anantha Krishnan
, 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 and O(1) SC. Regards Anantha Krishnan On Fri, Jul 1, 2011 at 4:13 PM, sunny agrawal sunny816.i...@gmail.comwrote: Take

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 sunny816.i...@gmail.comwrote: 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

Re: [algogeeks] Re: Amazon Telephonic Interview Questions

2011-06-30 Thread Anantha Krishnan
-data;* *} while (root-right == node || root-right == NULL);* *if (root-right != NULL)* *root = root-right;* *}* *}* *return NULL;* *}* Thanks Regards Anantha Krishnan On Thu, Jun 30, 2011 at 2:12 PM, vikas mehta...@gmail.com wrote: for 1 i

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 mittal.nishan...@gmail.comwrote: 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 --

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 sagarpar...@gmail.com wrote: Here is one

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 . jatka.oppimi...@gmail.comwrote: 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

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 sinv...@gmail.com wrote: go through the archives you will definitely

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 chukka.swa...@gmail.com 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) {

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 . jatka.oppimi...@gmail.comwrote: 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

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 . jatka.oppimi...@gmail.comwrote: What I wanted to say that, it's a trivial

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

2011-06-25 Thread Anantha Krishnan
(1024);* Thanks Regards, Anantha Krishnan On Sat, Jun 25, 2011 at 2:16 PM, Adarsh s.adars...@gmail.com wrote: char array[] = hello; char *pointer = hello; array is an array, enough to store sequence of characters and '\0' array will always refer to same storage. Here, pointer is initialized

Re: [algogeeks] Re: output plzz

2011-06-25 Thread Anantha Krishnan
Good. On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV riteshkumar...@gmail.comwrote: 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

Re: [algogeeks] Google Interview

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

Re: [algogeeks] Google Interview

2011-06-24 Thread Anantha Krishnan
for 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 akshatasharm...@gmail.comwrote: @Anantha can you explain

[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] Time Complexity of Merge Sort(Linked list)

2011-06-23 Thread Anantha Krishnan
, 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. For more options

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 . jatka.oppimi...@gmail.comwrote: Sunny, Can but can we modify this code to get the *node X and node Y

[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 group. To post

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 jsinghrath...@gmail.comwrote: I think this solution

[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. For more options

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 sunny816.i...@gmail.comwrote: @Piyush good to start with But i think a recursive O(n) is possible in downward calls pass sum from root to node

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 sunny816.i...@gmail.comwrote: see this * https://ideone.com/1ZtIq* On Tue, Jun 21, 2011 at 10:23 PM, Anantha Krishnan

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

2011-06-09 Thread Anantha Krishnan
)); } Thanks Regards, Anantha Krishnan On Thu, Jun 9, 2011 at 4:54 PM, Navneet Gupta navneetn...@gmail.com wrote: Ohh. Missed out the nlogn condition you mentioned. It will do but in n^2 Sent from my Windows Phone -- From: D.N.Vishwakarma@IITR Sent: Thursday, 9 June