Re: [algogeeks] Interview Question

2013-04-26 Thread Krishnan
an useful link http://stackoverflow.com/questions/7338070/finding-an-element-in-an-array-where-every-element-is-repeated-odd-number-of-tim On Fri, Apr 19, 2013 at 11:30 PM, kartik n kartik.car...@gmail.com wrote: Hi Nishant i did not understand the code can u please describe a bit Thanks

[algogeeks] Interview Question

2013-04-19 Thread Krishnan
In an array, some numbers occur only once, some numbers occur twice, only one number occur thrice. Find the number occuring thrice ? Space complexity O(1) Time Complexity O(n). We should not use Hash Maps. Please someone help.. -- You received this message because you are subscribed to the

[algogeeks] Re: A problem in tree

2013-03-12 Thread Krishnan
We need to construct BST not binary tree. On Sun, Mar 3, 2013 at 6:19 PM, Krishnan aariyankrish...@gmail.com wrote: Example: when we have nodes 1,2,3. The Minimum weight is given by, 2-root 1-left 3-right (Min. Weight - 10) or 3-root 2-left 1-left(left of 2) (Min. Weight -10). On Sun

[algogeeks] A problem in tree

2013-03-12 Thread Krishnan
Given a set of numbers, we have to construct a tree such that their WEIGHT is MINIMUM. WEIGHT(node value * height of the node). (Root is at the height 1). we need to print the minimum weight. How to approach this problem ? Pls somebody help -- You received this message because you are

[algogeeks] Re: A problem in tree

2013-03-12 Thread Krishnan
Example: when we have nodes 1,2,3. The Minimum weight is given by, 2-root 1-left 3-right (Min. Weight - 10) or 3-root 2-left 1-left(left of 2) (Min. Weight -10). On Sun, Mar 3, 2013 at 5:46 PM, Krishnan aariyankrish...@gmail.com wrote: Given a set of numbers, we have to construct a tree

[algogeeks] ATHENA Math Coding Contest

2013-01-18 Thread Krishnan
Kurkshetra'13 with GROUPON an International Techno-Management Fest Under the patronage of UNESCO is conducting a Math Coding Contest * **ATHENA.* on 18-Jan-13 9:00 IST (3:30 GMT) . Please participate if anybody is interested. It will be fun http://kurukshetra.org.in/#!/events/athena --

Re: [algogeeks] Inversion problem

2012-07-08 Thread Krishnan
Try like merge sort. http://www.geeksforgeeks.org/archives/3968 -- 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

Re: [algogeeks] SPOJ problem : CANDY

2012-06-20 Thread Krishnan
@mayank: For each testcase sum is not zero make sum=0 inside the for loop -- 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

Re: [algogeeks] spoj problem

2012-05-13 Thread Krishnan
@ashish pant We must compute all the queries in O(n)+O(k). We must have array like counting array. It is not my logic but my friend told about this logic -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] Kurukshetra OPC 2012

2012-01-31 Thread radha krishnan
Contest started. http://www.spoj.pl/KOPC12/problems/main/sort=0,start=0 Top Indians can get internship at SAPLABS india. -- 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

[algogeeks] Kurukshetra 2012 OPC

2012-01-29 Thread radha krishnan
Hi Coderz, We would like to invite you all to participate in Kurukshetra OPC 2012 http://www.spoj.pl/KOPC12(An Individual Contest ), a 4-hour acm-icpc style online programming competition, which is organized as a part ofKurukshetrahttp://www.kurukshetra.org.in2012 , the Technical fest of College

[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] TIC TAC TOE

2011-07-28 Thread radha krishnan
Excuse me MR.balaji :P U got selected for Microsoft Redmond :P still preparing ? :P On Thu, Jul 28, 2011 at 6:01 AM, Balaji S balaji.ceg...@gmail.com wrote: Given a 3X3 matrix , with 1's 0's and -1's ( 1 is player one 0 is player two -1 is none) how ll you find who is the winner / draw in a

[algogeeks] DirectI -Written Test

2011-07-28 Thread radha krishnan
Anyone have an idea about DirectI Written test ? Thanks in Advance ! Radhakrishnan, CEG,AU, Chennai -- 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

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] C ouput

2011-07-23 Thread radha krishnan
same question in MS written :P On Sat, Jul 23, 2011 at 5:49 AM, Manish Kumar manish.monu...@gmail.com wrote: @Akshata: Whenever you increase any variable then it increases according to its type. Here the address of array 'a' is being increased.(  a+1 ). so the address of 'a' will temporarily

Re: [algogeeks] register storage class

2011-07-23 Thread radha krishnan
Ok ! ppl started asking about books and send it to me :P stop this thread :P On Sat, Jul 23, 2011 at 8:56 AM, Arshad Alam alam3...@gmail.com wrote: @Prabhu.. I don't have Let Us C solution..if you have soft copy.. can you please send.. On Sat, Jul 23, 2011 at 9:12 PM, prabhu J

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] How to design Elevator Control system ?

2011-07-19 Thread radha krishnan
i think we should not use the answer from otherr ppl for these type of questions ! This is design ! we have to think of ur own :P -- 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: [algogeeks] MICROSOFT

2011-07-18 Thread radha krishnan
Really MS asking garbage collection questions ? :P 2) if the DLL is not sorted then it takes O(n lgn ) to build the BST but the code looks so bloated if we write the code On Mon, Jul 18, 2011 at 4:59 AM, Balaji S balaji.ceg...@gmail.com wrote: Convert a binary tree to binary search tree

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
just hash it On Fri, Jul 15, 2011 at 6:28 PM, Anand Shastri anand.shastr...@gmail.com wrote: Given a file containing 4,300,000,000  integers, how can you find one that appears at least twice -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
if number is (131) -1 u declare a 2GB array ? On Fri, Jul 15, 2011 at 6:59 PM, Anand Shastri anand.shastr...@gmail.com wrote: file any way contains integers why do we need hash those integers? why not use the same integers to index an array. On Fri, Jul 15, 2011 at 6:36 PM, radha krishnan

Re: [algogeeks] Google interview question

2011-07-15 Thread radha krishnan
, Anand Shastri anand.shastr...@gmail.com wrote: File has 4,300,000,000 integers if you hash it will create a distinct hash for 4,300,000,000 integers. On Fri, Jul 15, 2011 at 7:09 PM, radha krishnan radhakrishnance...@gmail.com wrote: if number is (131) -1  u declare a 2GB array ? On Fri, Jul

Re: [algogeeks] Test Mail - Plz ignore

2011-07-14 Thread radha krishnan
successfully ignored :P On Thu, Jul 14, 2011 at 6:57 AM, Navneet Gupta navneetn...@gmail.com wrote: Sending a test mail after re-joining the group. Please ignore. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

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

[algogeeks] C DEBUGGING

2011-07-10 Thread radha krishnan
#includestdio.h void main(){ signed x; unsigned y; x = 10 +- 10u + 10u +- 10; y = x; if(x==y) printf(%d %d,x,y); else if(x!=y) printf(%u %u,x,y); } OUTPUT? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

[algogeeks] find sol!!

2011-07-09 Thread Sriganesh Krishnan
(1*1!+2*2!+3*3!+4*4!+10*10!)/11! . is there any shortcut methods to solve such problems? find the odd one out... 13700, 1597, 326, 65, 16 , 6 , 2 and i have no clue to how to solve the second question -- You received this message because you are subscribed to the Google

[algogeeks] any tough aptitude questions!!!!

2011-07-09 Thread Sriganesh Krishnan
hey guys, do you know any website that offers really good aptitude questions...like interview aptitude questions!!! i think those are really tough than anything that we find in books -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

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) --

[algogeeks] array or matrix problems...anyone?

2011-07-08 Thread Sriganesh Krishnan
can anybody suggest some good array or matrix related problems! -- 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

Re: [algogeeks] array or matrix problems...anyone?

2011-07-08 Thread Sriganesh Krishnan
it :P On Fri, Jul 8, 2011 at 9:40 PM, Sriganesh Krishnan 2448...@gmail.comwrote: can anybody suggest some good array or matrix related problems! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

[algogeeks] Merging Sorted Arrays

2011-07-07 Thread radha krishnan
:Given two sorted arrays a[]={1,3,77,78,90} and b[]={2,5,79,81}. Merge these two arrays, no extra spaces are allowed. Output has to be a[]={1,2,3,5,77} and b[]={78,79,81,90}. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Merging Sorted Arrays

2011-07-07 Thread radha krishnan
--;      }      for(k=0;ksizeof(a)/sizeof(a[0]);k++)            printf(%d ,a[k]);      puts(\n);      for(k=0;ksizeof(b)/sizeof(b[0]);k++)            printf(%d ,b[k]);      puts(\n);      system(pause); } On 7/8/11, radha krishnan radhakrishnance...@gmail.com wrote: :Given two sorted arrays

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]

Re: [algogeeks] puzzle

2011-07-06 Thread Sriganesh Krishnan
i think this puzzle follows arithmetic progression...i'm not sure though...does anybody have a clean explanation for this? On Wed, Jul 6, 2011 at 10:35 PM, shiv narayan narayan.shiv...@gmail.comwrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard

Re: [algogeeks] puzzle

2011-07-06 Thread Sriganesh Krishnan
@tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile

Re: [algogeeks] DP or DFS

2011-07-06 Thread radha krishnan
nothing :P BFS :P On Wed, Jul 6, 2011 at 1:23 PM, KK kunalkapadi...@gmail.com wrote: https://www.spoj.pl/problems/SHOP/ Anybody plzz post a solution to the above problem... i tried with dp but it failed... How to implement with DFS or if possible with DP??? -- You received this message

Re: [algogeeks] Bipartite Matching?

2011-07-05 Thread radha krishnan
This is a gud question thougth the answer is not bipartitie matching If the graph has a cycle then answer is impossible The next question is whether the graph is connected ? say 1)when the graph is connected then it should be a tree to get split into two groups easily by assigning some colors /

Re: [algogeeks] Bipartite Matching?

2011-07-05 Thread radha krishnan
never mind am wrong ! :P :P On Tue, Jul 5, 2011 at 12:07 PM, radha krishnan radhakrishnance...@gmail.com wrote: This is a gud question  thougth the answer is not bipartitie matching If the graph has a cycle then answer is impossible The next question is whether the graph is connected ? say 1

[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 Interview

2011-06-30 Thread Sriganesh Krishnan
,leftb,midb-1); elseif(a[mida]bmidb]) kthlargest(a[],b[],lefta,mida-1,midb+1,rightb,); else return a[mida]; } On 6/25/11, Anantha Krishnan ananthakrishnan@gmail.com wrote: Idea is like this since both the arrays may not be of same length lets divide (k-1) smallest elements

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] Office Suite

2011-06-27 Thread radha krishnan
You asked the Most Efficient dude On Mon, Jun 27, 2011 at 10:29 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha: hw abt using a fixed size circular list? On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan radhakrishnance...@gmail.com wrote: simple!!  Stack:P On Sat, Jun 25

Re: [algogeeks] Anyone have The google resume book

2011-06-27 Thread radha krishnan
+1 :P On Tue, Jun 28, 2011 at 12:27 AM, hary rathor harry.rat...@gmail.com wrote: very funny ! every one know this site swathi -- 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: [algogeeks] Sorting Array

2011-06-26 Thread radha krishnan
Yes ! Count Sort !! On Sun, Jun 26, 2011 at 1:44 PM, ross jagadish1...@gmail.com wrote: Given a sequence of numbers in the range of 1-N^2, what is the most efficient way to sort the numbers (better than NlgN).. Can counting sort be used here? Is an O(N) solution possible.. -- You received

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] Office Suite

2011-06-25 Thread radha krishnan
simple!! Stack:P On Sat, Jun 25, 2011 at 8:11 PM, rShetty rajeevr...@gmail.com wrote: Suggest the most efficient Data Structures and algorithms to implement Undo and Redo operations in any of the Office Suites ? -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Algorithmic Pioneers

2011-06-24 Thread radha krishnan
Include Euler !!! On Fri, Jun 24, 2011 at 12:11 PM, Vishnutej Mylavarapu mylavarapu.vishnu...@gmail.com wrote: You can add AC Rush too.. On Fri, Jun 24, 2011 at 11:27 AM, rajeev bharshetty rajeevr...@gmail.comwrote: @ankit Thanks for the suggestion , I ahve Updated to include petr

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

Re: [algogeeks] Re: strings

2011-06-23 Thread Sriganesh Krishnan
[]=abcdaabcdefe; int buff[256]={0}; for(int i=0;istrlen(inp);i++) buff[inp[i]]++; for(int j=0;j256;j++) while(buff[j]--) cout(char)j; On Wed, Jun 22, 2011 at 10:27 AM, Sriganesh Krishnan 2448...@gmail.comwrote: Input will be a string. We need to o/p a string

Re: [algogeeks] Re: strings

2011-06-23 Thread Sriganesh Krishnan
oh...an array of constant length signify's constant memorywhy dint i see that...thanks guys!!! regards ---sriji!! On Thu, Jun 23, 2011 at 6:35 PM, Sriganesh Krishnan 2448...@gmail.comwrote: ya i needed the same thing! On Wed, Jun 22, 2011 at 3:04 PM, saurabh singh saurab

[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] O(n) Time is the problem. ..

2011-06-23 Thread Sriganesh Krishnan
can you explain mewhat the logic is...behind the xor operation?...is it like inversion or encryption? On Thu, Jun 23, 2011 at 11:59 AM, sunny agrawal sunny816.i...@gmail.comwrote: initially compute xor of all the values from 0 to n in a variable Temp so temp = 0^1^2^n let result

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

2011-06-23 Thread Anantha Krishnan
Krishnan On Fri, Jun 24, 2011 at 12:58 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote: Also u can refer http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html On 6/24/11, Piyush Sinha ecstasy.piy...@gmail.com wrote: I googled a better explaination for this and found

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

Re: [algogeeks] Amazon - Longest palindrome in a string in O(n)

2011-06-22 Thread radha krishnan
@balaji : i think u understand the question in wrong way !! The solution is to use Manchar Algorithm !! But thats hard to implement On Wed, Jun 22, 2011 at 12:05 AM, Balaji S balaji.ceg...@gmail.com wrote: LCS(string,reverse(string)) ?? but this is not O(n) ryt.. -- With Regards,

[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] Minimum draws for correct labels

2011-06-21 Thread Sriganesh Krishnan
nice!! On Tue, Jun 21, 2011 at 10:47 PM, Nitish Garg nitishgarg1...@gmail.comwrote: The answer is 1 only as stated in the above posts. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit

Re: [algogeeks] sort the array

2011-06-21 Thread Sriganesh Krishnan
ya...we can do it in O(n) n time!!! nice question! On Tue, Jun 21, 2011 at 11:01 PM, himanshu kansal himanshukansal...@gmail.com wrote: @anika: yar merge sort vl tk nlogn timeinstead u cn do dt maintain two ptrs one at the beginning and one intitially pointing to middle of the array...

[algogeeks] strings

2011-06-21 Thread Sriganesh Krishnan
Input will be a string. We need to o/p a string with the order of characters same as the input but with same characters grouped together. I/P: abcdacde O/P: aabccdde I/P: kapilrajadurga O/P: kpilrrjdug I/P: 1232 O/P: 1223 …….. O(n) time……….. O(1) space…. how can you approach these

Re: [algogeeks] Intuitive Understanding of XOR Operation

2011-06-14 Thread radha krishnan
Another use of XOR is to generate some random numbers And XOR is extensively used in the field of CryptoGraphy !!! -- 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] Million Numbers

2011-06-09 Thread radha krishnan
Ma approach is to xor the given number with all numbers in the file !! This takes O(n) I think we cant achieve a complexity O(n) we have to scan the file at least once Or move to this problem Instead of a file with numbers you have a stream of numbers Create a Trie and insert every number from

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

Re: [algogeeks] MS question

2011-06-02 Thread radha krishnan
@balaji :) This is a question But don tell this is a MS quesiton :P :P :P On Thu, Jun 2, 2011 at 11:40 PM, Balaji S balaji.ceg...@gmail.com wrote: how s that output obtained?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

Re: [algogeeks] for intelligent people

2011-05-28 Thread radha krishnan
Can u please leave this Group ? ?? ? On Sat, May 28, 2011 at 1:12 PM, sunny sunny31031...@gmail.com wrote: hi all of you you all can earn 2000+ money from internet by just spending sometime.i have done this and it's awesome really . .so i am sharing the link .so

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
sort :) On Fri, May 27, 2011 at 6:57 PM, ross jagadish1...@gmail.com wrote: Hi all, Given an array of elements find the largest possible number that can be formed by using the elements of the array. eg: 10 9 ans: 910 2 3 5 78 ans: 78532 100 9 ans: 9100 -- You received this

Re: [algogeeks] Google Interview Question

2011-05-27 Thread radha krishnan
Haha !! Any counter case against sort ? ?? ? :P On Fri, May 27, 2011 at 7:02 PM, adityasir...@gmail.com wrote: are you kidding me. Just simple sort wont work. On Fri, May 27, 2011 at 9:31 AM, radha krishnan radhakrishnance...@gmail.com wrote: sort :) On Fri, May 27, 2011 at 6:57 PM

Re: [algogeeks] Admin of Group

2011-05-26 Thread radha krishnan
+100 On Thu, May 26, 2011 at 9:26 PM, pacific :-) pacific4...@gmail.com wrote: +1 On Wed, May 25, 2011 at 11:48 PM, anuj agarwal coolbuddy...@gmail.comwrote: Hi, Are there any admins on this group? I recently joined this group and i liked the discussions going on here. But there is a

  1   2   >