[algogeeks] Openings in Amazon
Multiple openings for SDE-2 position in Hyderabad/Gurgaon location. Interested ones revert back with updated CV. -- Aman A. Amazon.com | Software Development Engineer | TAM - Technology एकम् सत्, विप्राः बहुधा वदन्ति -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] SDE-1 openings in Amazon
Hi, We also have some openings in Hyderabad For SDE-1 and SDE-2 position for Amazon. Interested people can forward CV on neshuagarwal1...@gmail.com. Regards, Aman On Tue, Dec 2, 2014 at 4:07 PM, sourabh jain sourabhjain...@gmail.com wrote: Location? Thank You Have a Nice Day :) Regards Sourabh Kumar Jain Computer Science Corporation(CSC) Hyderabad, Telangana. MOB.-+91916049 +919993878717 On 2 December 2014 at 15:44, Bhanu Kishore bhanukishor...@gmail.com wrote: Hi, We have 4 SDE-1 openings in our team at Amazon Hyderabad. If any of you are interested, you can forward your resume to bhanukishor...@gmail.com -- Thank Regards, Bhanu Kishore Diddi. Software Development Engineer, Amazon India Development Center(Hyderabad). Mobile :- 9704253365 Email:- kisho...@amazon.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- Aman A. Amazon.com | Software Development Engineer | TAM - Technology एकम् सत्, विप्राः बहुधा वदन्ति -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] amazon f2f round question ..
In a connected and acyclic graph,that is a tree, we can apply this approach 1. apply *dfs *on any random node and find the longest distant node from this node.Let us say this node i*s u*. 2. from this no*de u*, again apply* dfs* to find longest distant node from this node.Let us say that node is v. (u,v) is the required pair of nodes. On Sat, May 11, 2013 at 7:16 PM, MAC macatad...@gmail.com wrote: Given an acyclic graph. Give an algorithm to find the pair of nodes which has the maximum distance between them, i.e. the maximum number of edges in between them any suggestion ? thanks --mac -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] Horrible Queries on spoj
Here in this code given below, Horrible is solved using 2 BIT(binary indexed trees) Can Someone please explain the Logic of the program or suggest other way to do the same ques using BIT problem here coming is here range query and range updation both simultaneously which is difficult with BIT. #include cstdio #include cstring using namespace std; long long bit1[12],bit2[12]; void update(long long bit[], int idx, long long val){ for(int x = idx;x = 11;x += x -x) bit[x] += val; } long long query(long long bit[], int idx){ long long ret = 0; for(int x = idx;x 0;x -= x -x) ret += bit[x]; return ret; } int main(){ int T,N,Q; scanf(%d,T); while(T--){ scanf(%d %d,N,Q); memset(bit1,0,sizeof bit1); memset(bit2,0,sizeof bit2); for(int i = 0,op,l,r,v;i Q;++i){ scanf(%d %d %d,op,l,r); if(op == 0){ scanf(%d,v); update(bit1,l,v); update(bit1,r + 1,-v); update(bit2,l,-(long long)v * (l - 1)); update(bit2,r + 1,(long long)v * r); }else{ printf(%lld\n,query(bit1,r) * r + query(bit2,r) - query(bit1,l - 1) * (l - 1) - query(bit2,l - 1)); } } } return 0; } On Tue, Feb 26, 2013 at 3:13 PM, dheeraj hasija dheerajhasija1...@gmail.com wrote: you can have this code for better understanding #includestdio.h long long v[50]; long long a[50]; inline long long getvalue( int index, int low, int high) { return a[index] + (high-low+1)*v[index]; } long long update( long long index, long long down, long long up, long long low, long long high,long long value) { long long mid = (low+high)/2; if( down = low high = up) {v[index] += value; return 0; } if(low up || high down) return 0; v[2*index] += v[index]; v[2*index+1] += v[index]; v[index] = 0; update( 2*index, down,up, low,mid,value); update(2*index+1 , down,up, mid+1, high,value); a[index] = getvalue(2*index, low, mid) + getvalue(2*index+1 , mid+1,high); return 0; } long long query( long long index, long long down, long long up, long long low, long long high) { //printf(%lld %lld %lld %lld,low,high,up,down); long long mid; mid = (low+high)/2; if( down = low high=up) return a[index] + v[index]*( high-low+1); if( low up || high down) return 0; v[2*index] += v[index]; v[2*index+1] += v[index]; a[index] = getvalue(2*index, low, mid) + getvalue(2*index+1 , mid+1,high); v[index] =0; return query( 2*index,down,up, low, mid)+query(2*index+1, down,up, mid+1, high); } int main() { long long t,n,p,quer,vr,val,i,q; scanf(%lld,t); while(t--) { scanf(%lld%lld,n,quer); for(i=0;i=4*n;i++) a[i] =0,v[i] =0; while(quer--) { // for(i=1;i8;i++) //printf(%lld ,a[i]); //printf(\n); scanf(%lld%lld%lld,vr,p,q); if(!vr) {scanf(%lld,val); update( 1,p,q,1,n,val); } else printf(%lld\n,query( 1, p, q, 1, n)); } //printf(bye); } return 0; } On Tue, Feb 26, 2013 at 12:24 PM, emmy foramlakh...@gmail.com wrote: Problem statement http://www.spoj.com/problems/HORRIBLE/ Here http://ideone.com/NhDuYo is my code. I am using segment trees + Lazy propagation. Please help me figure out my mistake. I am getting a WA Note: invariant : l = p =q = r l and r are the limits of that node p and q is the query range. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- *Dheeraj Hasija* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: [algogeeks] Codeforces Problem
see in this problem if a=1 then the no. of tiles will be b*c so now if u increase a in steps then no. of tiles will increase by c+b-1 so ans is b*c + (a-1)*(c+b-1) -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: [Amazon] : constructing fully binary tree
in one special case of binary tree where each internal node has 2 children; we can construct binary tree from these pre and postorder traversals. On Wed, Aug 8, 2012 at 12:11 PM, Navin Kumar algorithm.i...@gmail.comwrote: @shiv narayan: we are not going to create exact tree as original. You have to build full binary tree where as original tree may / may not be full binary tree. On Wed, Aug 8, 2012 at 2:31 AM, shiv narayan narayan.shiv...@gmail.comwrote: Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: Given Preorder and postorder traversals of a tree. Device an algorithm to constuct a fully binary tree from these traversals. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/xaHfTySoo58J. 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Amazon interview question
array of bits? if the current integer is present set the bit if else make it zero, searching, insertion and deletion all in O(1) time. On Thu, May 24, 2012 at 4:15 PM, rishabh shukla rockrishabh.mn...@gmail.com wrote: Suggest a data structure for storing million trillion numbers efficiently in very less space. Means space complexity should be as less as possible -- Rishabh Shukla B.Tech Final Year MNNIT Allahabad -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] finding anagrams in a list of words
use trie trees, and for every word sort the word and store the sorted word in the trie tree and also keep the index of that word in leaf of trie tree..after traversing the whole list of words you'll have all the indices of a anagrams of a particular word in its leaf nodes. On Fri, May 11, 2012 at 5:24 PM, mayur mayursa...@gmail.com wrote: Hi all, I am stuck with a question for a long time...can someone provide the best algorithm for this.. Question).. find all the anagrams in a list of words. The algorithm should be efficient as the list can be very large. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/c4cSIMcBYLEJ. 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] finding anagrams in a list of words
if asking me..yes !! On Fri, May 11, 2012 at 5:27 PM, Raghavendhra Chowdary MV raghavendhra20061...@gmail.com wrote: Is this amazon question buddy?? On Fri, May 11, 2012 at 5:24 PM, mayur mayursa...@gmail.com wrote: Hi all, I am stuck with a question for a long time...can someone provide the best algorithm for this.. Question).. find all the anagrams in a list of words. The algorithm should be efficient as the list can be very large. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/c4cSIMcBYLEJ. 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. -- Thanks Regards, M.V.Raghavendhra Chowdary. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] How many games you will conduct to decide a winner for N players. Visualize in terms of a Data Structure.
Ya tournament tree is fine, you can even check it on http://www.geeksforgeeks.org/archives/11556 To decide a winner among N people, ( n-1 ) people should loose. So N-1 games will decide. On Mon, Apr 9, 2012 at 12:45 AM, SAMM somnath.nit...@gmail.com wrote: This can be done using Tournament Tree ... PLzz refer wiki or http://www.geeksforgeeks.org/archives/11556 ... This will surely help .. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Modified binary search
how can there be multiple spikes and valleys?? say 1 2 3 4 5 6 7 if you rotate it once with rotation index 3 4 5 6 7 1 2 3 then again with index 2 6 7 1 2 3 4 5 So the multiple times rotation just means that the index of rotation is more then 1. On Fri, Apr 6, 2012 at 7:02 AM, Ashish Goel ashg...@gmail.com wrote: code needed… not ble to visualize what to do if there are too many spikes and valleys in the multiple times rotated array, is that possible?? On Sep 28, 2011, at 1:36 AM, Gene wrote: Indeed you must be given that all the array elements are unique or at least that there are no more than floor(n/2) repeats). Otherwise this is impossible. The simplest way to think about it is first to search for i such that a[i] a[i+1]. At that point you know there are two sorted ranges a[0]..a[i] and a[i+1] to a[n-1], so you can use regular binary search on each of these pieces. So how to find i? This is itself a binary search. At each stage, check whether a[0] a[mid] and a[mid] a[n-1]. The half that passes this test contains i. So throw away the other. On Sep 27, 10:01 am, Decipher ankurseth...@gmail.com wrote: A given sorted array is rotated unknown number of times , write a C/C++ code to find an element in the sorted array in O(log n) time . I know the solution to this problem is through binary search , but don't know the exact solution . Please help !! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Given an array A[1..n] of log n bit integers, sort them in-place in O(n) time
Can you please explain the question again. As what I understood according to me the question is size of array : n and the range of the elements present at each location is log n. On Wed, Apr 4, 2012 at 2:57 AM, Doom duman...@gmail.com wrote: Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/aGzMcjTFcAYJ. 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] [URGENNT] : naukri.com paper pattern
10 multiple choice questions on C : very easy , Kanetkar will suffice. Aptitude : subjective , with mostly mathematical puzzles . Lengthy due to time consuming problems. Focus on accuracy .Series completion, Time speed distance,permutation and combination is what i can recall in the aptitude paper. On Tue, Mar 27, 2012 at 8:07 PM, aditya gupta g.aditya.i...@gmail.comwrote: Hi all, nauri.com is visiting at my friend's college , can someone plz tell the pattern of its paper?? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] networking
Hii to all how to make a call of class's method(function) from client side to server in java? please replyit's urgent -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Vertical Sum in a given Binary Tree
Vertical sum is sum of all the nodes that are present in same horizontal distance from the root. In the example quoted by you the root 1 is at 0 Horizontal distance from root, while its children are both -1 and +1 distance from root. Now take the case of 1,5 and 6, 1 being the root is at 0 horizontal distance, 5 being the right child of 2 ( which is at -1 distance ) is again at -1 + 1=0 horizontal distance, similarly 6 will be at +1-1 =0 Horizontal distance. Hope that helps. Thanks and regards, Aman Raj On Sat, Mar 17, 2012 at 3:29 PM, rahul sharma rahul23111...@gmail.comwrote: what is vertical sum in binayr tree...i dnt need the algo for this..just need the concept...that what is vertical sum??? Given a Binary Tree, find vertical sum of the nodes that are in same vertical line. Print all sums through different vertical lines. Examples: 1 / \ 2 3 / \/ \ 4 5 6 7 The tree has 5 vertical lines Vertical-Line-1 has only one node 4 = vertical sum is 4 Vertical-Line-2: has only one node 2= vertical sum is 2 Vertical-Line-3: has three nodes: 1,5,6 = vertical sum is 1+5+6 = 12 Vertical-Line-4: has only one node 3 = vertical sum is 3 Vertical-Line-5: has only one node 7 = vertical sum is 7 So expected output is 4, 2, 12, 3 and 7 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] difference b/w static global variables and global variables
Hi , Is there any difference b/w static global variables and global variables ??? (apart from that static variables will be limited to that file only and global variables will be visible for other files also.) Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] whats the o/p of the code snippet
Hi, int main() { int i; int*p=malloc(4); *p=2; printf(%d\n,*p); free(p); *p=5; printf(%d\n,*p); scanf(%d,i); return 0; } Even though I have freed the memory using free(p) when I am dereferencing it I dont get any seg fault. Can anybody explain me why??? Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Function Name Mismatch
Thanx for reply can you provide some code snippet here? or some link for it. On Tue, Feb 7, 2012 at 11:30 PM, Prem Krishna Chettri hprem...@gmail.comwrote: This is a simple implementation to Factory Design Pattern. What you have to do is make an arbitrary class (Your Adapter) and always call this. However, the implementation of this class should be smart enough to route your call accordingly. As suggested by DON , its the c++ implementation of Factory Class. However , if you are designing in any other language, It is alwasyz advisable to have a sample implementation of Factory design pattern. On Tue, Feb 7, 2012 at 11:23 PM, Don dondod...@gmail.com wrote: Provide an interface class for the client to access. The client needs to know the name of the method in the interface, but only the interface needs to know the name of the function in the server. Don On Feb 7, 8:38 am, Aman Kumar amanas...@gmail.com wrote: Hii to all If client want to make a function call to a server(vice versa), but it doesn't know exact name . so we need a adapter. for this i have to design a adapter (middleware) so that client can make a call and adapter make that call to exact match. please help me for same. how to design adapter? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Function Name Mismatch
Hii to all If client want to make a function call to a server(vice versa), but it doesn't know exact name . so we need a adapter. for this i have to design a adapter (middleware) so that client can make a call and adapter make that call to exact match. please help me for same. how to design adapter? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A binary tree question
Hi, Suppose we have a binary search tree as 15,12,18,17,21,11,14 then O/P will be 15 12 18 21 17 14 11. so the successor of 15 is 12 the successor of 12 is 18 and so on. I hope now its clear. Regards, Aman. On Sun, Dec 11, 2011 at 6:26 PM, WgpShashank shashank7andr...@gmail.comwrote: @atul zig-zag mean spiral traversal of tree e.g. alternate the level while traversing , if previous traversal is left to right , then next level will be right to left . @aman .quest has little ambiguity its says successor but ebvery nodes can have we can ore-order , inorder ,postorder successor isn't it ?? but i am assuming u r interesting in pre-order succesor so then 1st find the per-order successor of each node then set it , finally traverse it ? correct me if i am wrong ? Thanks Shashank Mani Computer Science BIT Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/b51VObaoMZIJ. 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. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A binary tree question
Hi, Yes. Regards, Aman. On Sun, Dec 11, 2011 at 12:54 PM, atul anand atul.87fri...@gmail.comwrote: by zig-zag order means level order traversal ??? On Sun, Dec 11, 2011 at 6:22 AM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Given a tree, in addition to the left and right pointer, it has a third pointer, that is set to NULL. Set the third pointer to a node, which will be the successor of the current node, when the tree is traversed in the zig-zag order. In other words, if we traverse the tree using this third pointer alone, then we will be traversing the tree in the zig-zag order. Regards, Aman -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] A bst problem
Hi, Construct a BST where each node has 3 pointers instead of 2. the structure is struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; } write a code to add nodes in a binary search tree . inordersuccessor pointing to inorder successor. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A bst problem
Hi Piyush, I tried with the following data 15,13,18,22,21. I think your code is not giving proper inorder succ of node 18. Please check it. Regards, Aman. On Sat, Dec 10, 2011 at 6:30 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: insertNode(node *head, int value){ node *new; if(head == null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = new-inoredrsucc = null; head = new; }else{ node *root = head; node *l, *r; while(root != null){ if(root-data value){ l = root; r = null; root = root-left; }else{ r = root; l = null; root = root-right; } } //endwhile if(l != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = l; l-left = new; }else if(r != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = r-inordersucc; r-inordersucc = new; r-right = new; } } } On Sat, Dec 10, 2011 at 4:04 PM, sayan nayak sayanna...@gmail.com wrote: @dheeraj: I have one doubt... during implementation I assumed that inordersuccessor already exists for each node. So there's no need to track inodersuccessor. Just finding the position is ok.Then u can do the needful to change the inordersuccessor for the parent and the added node. Pls correct me If I'm wrong On Sat, Dec 10, 2011 at 3:43 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: My algorithm is like: 1.Take two pointers. one pointer track..where the node should be inserted..and other..to keep track of inorder successor. first pointer=root; second pointer=null; 2.if the first pointer moves to the left of a particular node(which becomes its parent)..then the set the value of second pointer=parent. else if the first pointer moves to the right of particular node (which becomes its parent)..the let the value of second pointer as it is.. finally when the node has been inserted at leaf..set the inorder successor of the node=second pointer value Correct me if am wrong On Sat, Dec 10, 2011 at 3:38 PM, sayan nayak sayanna...@gmail.comwrote: hi, here is the code: == struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; }; struct node *createnode(int info){ struct node* temp; temp-data=info; temp-left=temp-right=temp-inordersuccessor=NULL; return temp; }; struct node *addNode(struct node *node,int info){ struct node* temp=Createnode(info); if(node==NULL){ node=(struct node*)malloc(sizeof(struct node); if (node==NULL) fatalerror(Out of space); else { node-data=info; node-left=node-right=node-inordersuccessor=NULL; } } if (node-left==NULL info(node-data)){ node-left=temp; temp-inordersuccessor=node; } else if (node-right==NULL info(node-data)){ node-right=temp; temp-inordersuccessor=node-inordersuccessor; node-inordersuccessor=temp; } else { if (info(node-data)) node-left=addnode(node-left,info); else node-right=addnode(node-right,info); } return node; } I have run a few test cases..It's working.Pls let me know in case of any failure test cases. I'm also checking. Regards, Sayan On Sat, Dec 10, 2011 at 1:33 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Construct a BST where each node has 3 pointers instead of 2. the structure is struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; } write a code to add nodes in a binary search tree . inordersuccessor pointing to inorder successor. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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] A bst problem
Hi, After 22 you add 21 so 21-left=22-right=null 22-left=21 21-inorder=22. but here if you draw the diagram you will see that inorder successor of 18 will now be 21 not 22. I think you have not taken that into consideration. Please correct me if I am wrong. Regards, Aman, On Sat, Dec 10, 2011 at 7:37 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: I don't think so. First you added 15. 15-left = null=15-right=15-succ; add 13. (13 15) so 13-left = 13-right = null; 13-succ = 15; 15-left = 13; add 18 (18 15) so 18-left = 18-right = null; 18-succ = 15-succ = null; 15-right = 15-succ = 18 add 22 (22 15) go to 15-right (22 18) go to 18- right 22-left = 22-right = null; 22-succ = 18-succ = null; 18-right = 18-succ = 22; and so on... On Sat, Dec 10, 2011 at 6:49 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi Piyush, I tried with the following data 15,13,18,22,21. I think your code is not giving proper inorder succ of node 18. Please check it. Regards, Aman. On Sat, Dec 10, 2011 at 6:30 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: insertNode(node *head, int value){ node *new; if(head == null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = new-inoredrsucc = null; head = new; }else{ node *root = head; node *l, *r; while(root != null){ if(root-data value){ l = root; r = null; root = root-left; }else{ r = root; l = null; root = root-right; } } //endwhile if(l != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = l; l-left = new; }else if(r != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = r-inordersucc; r-inordersucc = new; r-right = new; } } } On Sat, Dec 10, 2011 at 4:04 PM, sayan nayak sayanna...@gmail.comwrote: @dheeraj: I have one doubt... during implementation I assumed that inordersuccessor already exists for each node. So there's no need to track inodersuccessor. Just finding the position is ok.Then u can do the needful to change the inordersuccessor for the parent and the added node. Pls correct me If I'm wrong On Sat, Dec 10, 2011 at 3:43 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: My algorithm is like: 1.Take two pointers. one pointer track..where the node should be inserted..and other..to keep track of inorder successor. first pointer=root; second pointer=null; 2.if the first pointer moves to the left of a particular node(which becomes its parent)..then the set the value of second pointer=parent. else if the first pointer moves to the right of particular node (which becomes its parent)..the let the value of second pointer as it is.. finally when the node has been inserted at leaf..set the inorder successor of the node=second pointer value Correct me if am wrong On Sat, Dec 10, 2011 at 3:38 PM, sayan nayak sayanna...@gmail.comwrote: hi, here is the code: == struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; }; struct node *createnode(int info){ struct node* temp; temp-data=info; temp-left=temp-right=temp-inordersuccessor=NULL; return temp; }; struct node *addNode(struct node *node,int info){ struct node* temp=Createnode(info); if(node==NULL){ node=(struct node*)malloc(sizeof(struct node); if (node==NULL) fatalerror(Out of space); else { node-data=info; node-left=node-right=node-inordersuccessor=NULL; } } if (node-left==NULL info(node-data)){ node-left=temp; temp-inordersuccessor=node; } else if (node-right==NULL info(node-data)){ node-right=temp; temp-inordersuccessor=node-inordersuccessor; node-inordersuccessor=temp; } else { if (info(node-data)) node-left=addnode(node-left,info); else node-right=addnode(node-right,info); } return node; } I have run a few test cases..It's working.Pls let me know in case of any failure test cases. I'm also checking. Regards, Sayan On Sat, Dec 10, 2011 at 1:33 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Construct a BST where each node has 3 pointers instead of 2. the structure is struct node { int data; struct node *left; struct node *right; struct node
Re: [algogeeks] A bst problem
Hi. So can you please tell me the modifications required so it works correctly. Regards, Aman. On Sat, Dec 10, 2011 at 8:22 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: yup, you are right.. On Sat, Dec 10, 2011 at 8:09 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, After 22 you add 21 so 21-left=22-right=null 22-left=21 21-inorder=22. but here if you draw the diagram you will see that inorder successor of 18 will now be 21 not 22. I think you have not taken that into consideration. Please correct me if I am wrong. Regards, Aman, On Sat, Dec 10, 2011 at 7:37 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: I don't think so. First you added 15. 15-left = null=15-right=15-succ; add 13. (13 15) so 13-left = 13-right = null; 13-succ = 15; 15-left = 13; add 18 (18 15) so 18-left = 18-right = null; 18-succ = 15-succ = null; 15-right = 15-succ = 18 add 22 (22 15) go to 15-right (22 18) go to 18- right 22-left = 22-right = null; 22-succ = 18-succ = null; 18-right = 18-succ = 22; and so on... On Sat, Dec 10, 2011 at 6:49 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi Piyush, I tried with the following data 15,13,18,22,21. I think your code is not giving proper inorder succ of node 18. Please check it. Regards, Aman. On Sat, Dec 10, 2011 at 6:30 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: insertNode(node *head, int value){ node *new; if(head == null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = new-inoredrsucc = null; head = new; }else{ node *root = head; node *l, *r; while(root != null){ if(root-data value){ l = root; r = null; root = root-left; }else{ r = root; l = null; root = root-right; } } //endwhile if(l != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = l; l-left = new; }else if(r != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = r-inordersucc; r-inordersucc = new; r-right = new; } } } On Sat, Dec 10, 2011 at 4:04 PM, sayan nayak sayanna...@gmail.comwrote: @dheeraj: I have one doubt... during implementation I assumed that inordersuccessor already exists for each node. So there's no need to track inodersuccessor. Just finding the position is ok.Then u can do the needful to change the inordersuccessor for the parent and the added node. Pls correct me If I'm wrong On Sat, Dec 10, 2011 at 3:43 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: My algorithm is like: 1.Take two pointers. one pointer track..where the node should be inserted..and other..to keep track of inorder successor. first pointer=root; second pointer=null; 2.if the first pointer moves to the left of a particular node(which becomes its parent)..then the set the value of second pointer=parent. else if the first pointer moves to the right of particular node (which becomes its parent)..the let the value of second pointer as it is.. finally when the node has been inserted at leaf..set the inorder successor of the node=second pointer value Correct me if am wrong On Sat, Dec 10, 2011 at 3:38 PM, sayan nayak sayanna...@gmail.comwrote: hi, here is the code: == struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; }; struct node *createnode(int info){ struct node* temp; temp-data=info; temp-left=temp-right=temp-inordersuccessor=NULL; return temp; }; struct node *addNode(struct node *node,int info){ struct node* temp=Createnode(info); if(node==NULL){ node=(struct node*)malloc(sizeof(struct node); if (node==NULL) fatalerror(Out of space); else { node-data=info; node-left=node-right=node-inordersuccessor=NULL; } } if (node-left==NULL info(node-data)){ node-left=temp; temp-inordersuccessor=node; } else if (node-right==NULL info(node-data)){ node-right=temp; temp-inordersuccessor=node-inordersuccessor; node-inordersuccessor=temp; } else { if (info(node-data)) node-left=addnode(node-left,info); else node-right=addnode(node-right,info); } return node; } I have run a few test cases..It's working.Pls let me know in case of any failure test
[algogeeks] A BST question
Hi, Given a Binary tree where nodes may have positive or negative value, store the sum of the left and right subtree in the nodes. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] A bst problem
Hi Piyush, Thanx. On Sat, Dec 10, 2011 at 11:09 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: Hi Aman Here is the working algo. I forgot to consider the case you mentioned. So whenever a new node is getting added in the tree we need to modify the inordersucc of the predecessor of the current node. Here is the link: you can try out different cases also: http://www.ideone.com/MOxdl -Piyush On Sat, Dec 10, 2011 at 8:28 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi. So can you please tell me the modifications required so it works correctly. Regards, Aman. On Sat, Dec 10, 2011 at 8:22 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: yup, you are right.. On Sat, Dec 10, 2011 at 8:09 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, After 22 you add 21 so 21-left=22-right=null 22-left=21 21-inorder=22. but here if you draw the diagram you will see that inorder successor of 18 will now be 21 not 22. I think you have not taken that into consideration. Please correct me if I am wrong. Regards, Aman, On Sat, Dec 10, 2011 at 7:37 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: I don't think so. First you added 15. 15-left = null=15-right=15-succ; add 13. (13 15) so 13-left = 13-right = null; 13-succ = 15; 15-left = 13; add 18 (18 15) so 18-left = 18-right = null; 18-succ = 15-succ = null; 15-right = 15-succ = 18 add 22 (22 15) go to 15-right (22 18) go to 18- right 22-left = 22-right = null; 22-succ = 18-succ = null; 18-right = 18-succ = 22; and so on... On Sat, Dec 10, 2011 at 6:49 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi Piyush, I tried with the following data 15,13,18,22,21. I think your code is not giving proper inorder succ of node 18. Please check it. Regards, Aman. On Sat, Dec 10, 2011 at 6:30 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: insertNode(node *head, int value){ node *new; if(head == null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = new-inoredrsucc = null; head = new; }else{ node *root = head; node *l, *r; while(root != null){ if(root-data value){ l = root; r = null; root = root-left; }else{ r = root; l = null; root = root-right; } } //endwhile if(l != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = l; l-left = new; }else if(r != null){ new = (node*)malloc(sizeof(node)); new-data = value; new-left = new-right = null; new-inordersucc = r-inordersucc; r-inordersucc = new; r-right = new; } } } On Sat, Dec 10, 2011 at 4:04 PM, sayan nayak sayanna...@gmail.comwrote: @dheeraj: I have one doubt... during implementation I assumed that inordersuccessor already exists for each node. So there's no need to track inodersuccessor. Just finding the position is ok.Then u can do the needful to change the inordersuccessor for the parent and the added node. Pls correct me If I'm wrong On Sat, Dec 10, 2011 at 3:43 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: My algorithm is like: 1.Take two pointers. one pointer track..where the node should be inserted..and other..to keep track of inorder successor. first pointer=root; second pointer=null; 2.if the first pointer moves to the left of a particular node(which becomes its parent)..then the set the value of second pointer=parent. else if the first pointer moves to the right of particular node (which becomes its parent)..the let the value of second pointer as it is.. finally when the node has been inserted at leaf..set the inorder successor of the node=second pointer value Correct me if am wrong On Sat, Dec 10, 2011 at 3:38 PM, sayan nayak sayanna...@gmail.com wrote: hi, here is the code: == struct node { int data; struct node *left; struct node *right; struct node *inordersuccessor; }; struct node *createnode(int info){ struct node* temp; temp-data=info; temp-left=temp-right=temp-inordersuccessor=NULL; return temp; }; struct node *addNode(struct node *node,int info){ struct node* temp=Createnode(info); if(node==NULL){ node=(struct node*)malloc(sizeof(struct node); if (node==NULL) fatalerror(Out of space); else { node-data=info; node-left=node-right=node-inordersuccessor=NULL; } } if (node-left==NULL info(node
[algogeeks] A binary tree question
Hi, Given a tree, in addition to the left and right pointer, it has a third pointer, that is set to NULL. Set the third pointer to a node, which will be the successor of the current node, when the tree is traversed in the zig-zag order. In other words, if we traverse the tree using this third pointer alone, then we will be traversing the tree in the zig-zag order. Regards, Aman -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks]convert a sorted DLL to bst
Hi, WAP to convert a sorted DLL to a balanced BST. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] LCA of a Binary tree not a binary search tree
Hi, I think it matters whether its a bst or normal tree. In BST left node is smaller and the right node is greater than the root node, but no such constraint is applicable for a binary tree. Regards, Aman. On Mon, Nov 14, 2011 at 10:12 AM, sumit mahamuni sumit143smail...@gmail.com wrote: Hi, On Mon, Nov 14, 2011 at 1:52 AM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Please tell me the solution of this question. write a program which find LCA of a binary tree. It is not a BST Does it matter its a BST or binary tree? the algo will be same for the BST or binary tree. Regards, Aman, -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks and Regards, Sumit Mahamuni. -- Slow code that scales better can be faster than fast code that doesn't scale! -- Tough times never lasts, but tough people do. -- I love deadlines. I like the whooshing sound they make as they fly by. - D. Adams -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] LCA of a Binary tree not a binary search tree
Hi, Please tell me the solution of this question. write a program which find LCA of a binary tree. It is not a BST Regards, Aman, -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Final Year Project
Hiii if anybody has project on Component Based Software Engineering , please reply on this thread asap thank you. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] BST question
Hi All, Please give me the solution of this problem. A binary tree and a number X is given. Find all the paths(not necessarily starting from root) such that the sum equals X. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re-entrant and thread safe
Hi All, Please explain the difference between thread safe functions and re-entrant functions with example. Regards, Aman. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] virtual memory
Hii what happen if size of main memory is greater than size of virtual memory? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] urgent C o/p
#includestdio.h int main() { float a=3.2; printf(%d\n\n,a);//line 1 printf(%d,*(int *)a); //line 2 } o/p(gcc comppiler) = -1610612736 1078774989 i am not getting why and how these /p r coming . what is difference between line 1 and line 2? reply asap -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] CSMA/CD in switched
Hiii I have one confusion thatCSMA/CD is protocol is still used in switched base LAN? How is full duplex transmission occured in switched. please clear this and provide a link for same -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] character count in array
Hiii if array is given like this arr[]=aabcabbcdeadef convert this array into like arr[]=a4b3c2d2e2f1 how can we do this can we do it with space complexity O(1). reply asap -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] dictionary
Hii Which data structures can be used for implementation for dictionary? which is best/good among them? provide good link for that. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] pattern matching
Hiii Friends ,if pattern matching question is asked in the interview , we should answer brute force(with some optimization) approach or use ADVANCED algorithm like KMP? I am very much confused regarding this because in on blog i have read that we should not use advanced data structure in interview. help me out. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Apti
ans is 12, but instead of counting i am looking for some better solution. On Tue, Aug 23, 2011 at 10:48 PM, manish patel manispatel...@gmail.comwrote: (24,33),(12,66),(8,99),(6,132),(4,198),(3,254),(2,396),(1,792),(792,1),(72,11),(264,3),(33,24) On Tue, Aug 23, 2011 at 10:18 PM, Aman Goyal aman.goya...@gmail.comwrote: Let a natural number N be such that N = a × b where a and b are the factors of N. How many such sets of (a, b) can be formed in which the selection of the two numbers a and b is distinctly different if N = 24 × 33? Please explain your solution also. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards Manish Patel BTech 3rd Year Computer Science And Engineering National Institute of Technology -Allahabad -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] threads
Hiii Tell me that what should i answer in interview of question like 1.thread synchronization 2.context switch of threads please give detail answer. any good link for same? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] mutex
can we use mutex for synchronization? if yes why? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] realloc and malloc
Hiii tell me how to implement own realloc and malloc and free function? any link for this?? If anybody is implemented it,give code ? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] n-ary tree
Can anyone suggests a good data structure for n-ary tree.. where n is the input by the user... -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: n-ary tree
thanks, by no means we can add the child nodes dynamically to the father node?? On Sat, Aug 6, 2011 at 5:33 PM, rohit q.ro...@gmail.com wrote: use a linked list to store child nodes, a tree node will hold pointer to next sibling and a pointer to its first child. typedef struct TreeNode{ struct TreeNode * nextSibling; struct TreeNode * fistChild; //rest things } On Aug 6, 4:10 pm, Aman Goyal aman.goya...@gmail.com wrote: Can anyone suggests a good data structure for n-ary tree.. where n is the input by the user... -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] inorder
.. pseudo code for finding inorder successor of a node without parent field.. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] pls help
as an eg. let ab be the string, and 3 characters length string is wht is expected.. a - - b - - a a - a b - b a - b b - a a a a a b a b a a b b b a a b a b b b a b b b On Fri, Aug 5, 2011 at 12:49 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: The basic idea is that for every position of the string, you fill it with all possible alphabets in your set of allowed alphabets, let the set be called alphabet. Now, you can do this recursively. backtrack(s,l) denotes, a string s has been formed, and is of length l. Now we need to add more letters to it. If l is equal to the maximum length, then you just print the string s, and return. Otherwise, append the characters available to you. For example, if in the current scenario, the call is backtrack(po,2), and alphabet = {'o','p'} and maxlen=3, then we can append 'o' and 'p' to the string po, and hence call backtrack(poo,3) and backtrack(pop,3). You start the process by calling backtrack(,0), and setting maxlen and alphabet to the appropriate values. On Fri, Aug 5, 2011 at 12:42 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: @gaurav:i could not understand ur sol.can u explain it again.. On Fri, Aug 5, 2011 at 12:32 PM, Gaurav Menghani gaurav.mengh...@gmail.com wrote: On Fri, Aug 5, 2011 at 12:20 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: given a set of letters and a length N, produce all possible output.(Not permutation). For example, give the letter (p,o) and length of 3, produce the following output(in any order you want, not just my example order) ppp ppo poo pop opp opo oop ooo another example would be given (a,b) and length 2 answer: ab aa bb ba -- Regards, Kamakshi kamakshi...@gmail.com This can be done easily by backtracking void backtrack(string s, int l) { if(l == maxlen) { coutsendl; return; } s.push_back('-'); for(int i=0;ialphabet.size();i++) { s[l]=alphabet[i]; backtrack(s,l+1); } } -- Gaurav Menghani -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Printf
physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote: What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base address of the memory iii. Physical address iv. Logical address -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] simple doubt
1st is right, n when you do pa++, it will jump by size of 1st one-D array(in case array is of more than one dimension), even in this case, it'll jump by the whole array size(6). On 5 August 2011 23:20, Amol Sharma amolsharm...@gmail.com wrote: both are wrong.run and see that warning will be displayed !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Fri, Aug 5, 2011 at 10:17 PM, pankaj kumar pancsen...@gmail.comwrote: first one is right and second is wrong.because dp will store address of pointer and here you are storing address of int array. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Normal Form
yeah bcnf On Thu, Aug 4, 2011 at 1:06 PM, ankit sambyal ankitsamb...@gmail.comwrote: BCNF -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Aman Jain M.Tech(Information System) Final Year Placement Coordinator Delhi Technological University (Formerly Delhi College of Engineering) -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Largest Bst in a binary tree.
How to find the largest BST in a binary tree. 15 / \ 10__ 20 / \ 5 _7 / \ 2_ __5 / \/ 0 8 3 The largest BST (may or may not include all of its descendants) from the above example should be: 15 / \ _10 20 / 5 Please do not post working code, logic/algorithm or link would be preferred. I know it will be through recursion , still the logic part of recursion is not clear.. would be thankful if anyone could help. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Data Structure to design logn LCA
* Nearest Common Ancestor* Given a rooted tree of size * n *. You receive a series of online queries : * Give nearest common ancestor of u,v *. Your objective is to preprocess the tree in * O(n) * time to get a data structure of size * O(n) * so that you can answer any such query in * O(log n) * time. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Largest Bst in a binary tree.
while dequing a node from the queue, how will u check whether a bst property is sattisfied or not ?.. On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.com wrote: I have some upto this much currently. Modify the Breadth First traversal (BFT) a bit. maintain two queues, one is for original traversal. Start from root, BFT. when you dequeue a node, check if it satisfies the condition for BST. if yes add the the node to auxiliary queue, if not, leave it and add it's original children to the original queue in both cases. Some further modifications can the done to have multiple auxiliary queues and keep track of their heights. What say? On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote: Yes, that can be a liable case definitely!!! On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote: The question is a bit tricky. Is it possible that the largest BST is somewhere in deeper depth, i.e. it is not necessarily consisting of the root? On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote: How to find the largest BST in a binary tree. 15 / \ 10__ 20 / \ 5 _7 / \ 2_ __5 / \/ 0 8 3 The largest BST (may or may not include all of its descendants) from the above example should be: 15 / \ _10 20 / 5 Please do not post working code, logic/algorithm or link would be preferred. I know it will be through recursion , still the logic part of recursion is not clear.. would be thankful if anyone could help. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Largest Bst in a binary tree.
@sagar : I m confused of how that can be done.. could u elaborate On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.com wrote: while dequing a node from the queue, how will u check whether a bst property is sattisfied or not ?.. On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote: I have some upto this much currently. Modify the Breadth First traversal (BFT) a bit. maintain two queues, one is for original traversal. Start from root, BFT. when you dequeue a node, check if it satisfies the condition for BST. if yes add the the node to auxiliary queue, if not, leave it and add it's original children to the original queue in both cases. Some further modifications can the done to have multiple auxiliary queues and keep track of their heights. What say? On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote: Yes, that can be a liable case definitely!!! On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote: The question is a bit tricky. Is it possible that the largest BST is somewhere in deeper depth, i.e. it is not necessarily consisting of the root? On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote: How to find the largest BST in a binary tree. 15 / \ 10__ 20 / \ 5 _7 / \ 2_ __5 / \/ 0 8 3 The largest BST (may or may not include all of its descendants) from the above example should be: 15 / \ _10 20 / 5 Please do not post working code, logic/algorithm or link would be preferred. I know it will be through recursion , still the logic part of recursion is not clear.. would be thankful if anyone could help. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Largest Bst in a binary tree.
@siddharam: nice approach, just a query increasing inorder traversal of a tree is a sufficient condition to check for a BST ? On Fri, Aug 5, 2011 at 10:05 AM, siddharam suresh siddharam@gmail.comwrote: my idea is go for inorder traversal find the longest sorted sequence in traversal thats the *'largest BST in a binary tree.'* Thank you, Siddharam On Fri, Aug 5, 2011 at 10:00 AM, Aman Goyal aman.goya...@gmail.comwrote: while dequing a node from the queue, how will u check whether a bst property is sattisfied or not ?.. On Fri, Aug 5, 2011 at 9:49 AM, Dipankar Patro dip10c...@gmail.comwrote: I have some upto this much currently. Modify the Breadth First traversal (BFT) a bit. maintain two queues, one is for original traversal. Start from root, BFT. when you dequeue a node, check if it satisfies the condition for BST. if yes add the the node to auxiliary queue, if not, leave it and add it's original children to the original queue in both cases. Some further modifications can the done to have multiple auxiliary queues and keep track of their heights. What say? On 5 August 2011 09:40, Aman Goyal aman.goya...@gmail.com wrote: Yes, that can be a liable case definitely!!! On Fri, Aug 5, 2011 at 9:35 AM, Dipankar Patro dip10c...@gmail.comwrote: The question is a bit tricky. Is it possible that the largest BST is somewhere in deeper depth, i.e. it is not necessarily consisting of the root? On 5 August 2011 08:46, Aman Goyal aman.goya...@gmail.com wrote: How to find the largest BST in a binary tree. 15 / \ 10__ 20 / \ 5 _7 / \ 2_ __5 / \/ 0 8 3 The largest BST (may or may not include all of its descendants) from the above example should be: 15 / \ _10 20 / 5 Please do not post working code, logic/algorithm or link would be preferred. I know it will be through recursion , still the logic part of recursion is not clear.. would be thankful if anyone could help. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] merging trees
You are given two height balanced binary search trees T and T', storing m and n elements respectively. Every element of tree T is smaller than every element of tree T'. Every node u also stores height of the subtree rooted at it. Using this extra information how can you merge the two trees in time O(log m + log n) (preserving both the height balance and the order)? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Data Structure to design logn LCA
thanks gaurav ! On Fri, Aug 5, 2011 at 9:45 AM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: On Fri, Aug 5, 2011 at 9:41 AM, Aman Goyal aman.goya...@gmail.com wrote: You receive a series of online queries : Give nearest common ancestor of u,v . Your objective is to preprocess the tree in O(n) time to get a data structure of size O(n) so that you can answer any such query in O(log n) time. Segment tree [0] is what you are looking for. [0] http://www.topcoder.com/tc?module=Staticd1=tutorialsd2=lowestCommonAncestor -- Gaurav Menghani -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Data structure question!!!!!!!
Hi, Convert a BST to max heap without using extra memory and in as optimum time as possible. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Data structure question!!!!!!!
Can you please suggest me your approch. Plaese give a code snippet for your approach. On Wed, Aug 3, 2011 at 12:13 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote: nlogn ? On Wed, Aug 3, 2011 at 12:10 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, Convert a BST to max heap without using extra memory and in as optimum time as possible. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Data structure question!!!!
Hi, Convert a min heap to BST without changing its structure and of course no extra space. Please post a code snippet also. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] feedback of the book
Hi, Please give me the feedback for the book Algorithms for interviews. by Adnan Aziz. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] sorting in O(n) time
Hi, How can we sort one unsorted int array with O(n). Unsorted : {4,2,6,1,5,5,1,2,45,444,44,45,4,1} Sorted : {1,1,1,2,2,4,4,5,5,6,44,45,45,444} Is there any sorting method which gives us O(n) time complexity??? Please tell the algo if anybody knows it. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Feedback of the book!!!!!!!
Hi, I am planning to buy a book cracking the coding interview by Gayle Laakmann. Please give your feedbacks. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Feedback of the book!!!!!!!
Does it also contains the solutions of the questions??? Is it worth buying. ??? On Mon, Aug 1, 2011 at 12:36 PM, rajeev bharshetty rajeevr...@gmail.comwrote: Awesome Book ,for interviews : Covers wide range of interview questions . On Mon, Aug 1, 2011 at 12:23 PM, AMAN AGARWAL mnnit.a...@gmail.comwrote: Hi, I am planning to buy a book cracking the coding interview by Gayle Laakmann. Please give your feedbacks. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc *Winners Don't do Different things , they do things Differently* -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Direct - i ques
Think in terms of vector(C++, STL) :P On Mon, Aug 1, 2011 at 11:01 AM, ankit sablok ankit4...@gmail.com wrote: finding min will not take O(1) time in a stack i guess On Mon, Aug 1, 2011 at 10:32 AM, kartik sachan kartik.sac...@gmail.comwrote: I think its stack where deletion insertion and finding min (as we will cal min at the time of insertion only by taking min val ) will take O(1) time correct me if i am worng...! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Aman Agarwal Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Implementation of trie data structure
Hi, Can somebody please give me code snippet for implementing trie data structure??? -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Programming Puzzle!!!!!!!
Can you please explain the logic behind this algo in detail... On Fri, Jul 29, 2011 at 11:32 AM, ankit sambyal ankitsamb...@gmail.comwrote: Let S be the exact amount for which minimum coins are to found. And denom[] be the array which contains different denominations. Let N be the size of the denom[] array. Algo: 1. int memo[S] 2. initialize all its elements to infinite 3.for i=1 to S for j=0 to N-1 if(denom[j] imemo[i-denom[j]] +1 memo[i]) memo[i]=memo[i-denom[j]] +1 4. return memo[S] -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] longest common string!!!!!
please give the solution for this problem... Give an algorithm to find the Longest common string of strings with lengths m,n respectively and also analyse their time complexities -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Programming Puzzle!!!!!!!
what do you mean when u say initialize all its elements to infinite. i am not able to get this logic. memo[i-denom[j]] +1 memo[i] can you please explain??? On Fri, Jul 29, 2011 at 11:32 AM, ankit sambyal ankitsamb...@gmail.comwrote: Let S be the exact amount for which minimum coins are to found. And denom[] be the array which contains different denominations. Let N be the size of the denom[] array. Algo: 1. int memo[S] 2. initialize all its elements to infinite 3.for i=1 to S for j=0 to N-1 if(denom[j] imemo[i-denom[j]] +1 memo[i]) memo[i]=memo[i-denom[j]] +1 4. return memo[S] -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Programming Puzzle!!!!!!!
what do u mean by memo[i]=memo[i-denom[j]] +1 memo[i] will be containing infinite value. memo[i-denom[j]] will also contain infinite value On Fri, Jul 29, 2011 at 11:32 AM, ankit sambyal ankitsamb...@gmail.comwrote: Let S be the exact amount for which minimum coins are to found. And denom[] be the array which contains different denominations. Let N be the size of the denom[] array. Algo: 1. int memo[S] 2. initialize all its elements to infinite 3.for i=1 to S for j=0 to N-1 if(denom[j] imemo[i-denom[j]] +1 memo[i]) memo[i]=memo[i-denom[j]] +1 4. return memo[S] -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] C output
#include‹stdio.h› main() { struct xx { int x; struct yy { char s; struct xx *p; }; struct yy *q; }; } ouput: compiler error. Any logical reasons? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] direct i ..ques
c(n,2) * c(n,2) On Wed, Jul 27, 2011 at 11:07 PM, siva viknesh sivavikne...@gmail.comwrote: No. rectangles in NxN matrix ... is it n^2 + (n-2) ?? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] self referential struct. Contd.
yes this will be the case. On Wed, Jul 27, 2011 at 11:35 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: @nikhil:So what u mean is that if i have: struct{ int a; char b[5]; }; the size of this struct's node will be 12 not 9.., to make it a multiple of 4?? On 7/26/11, Nikhil Gupta nikhilgupta2...@gmail.com wrote: Padding is not a topic of self referential structure. Padding means that extra spaces of memory are used by the compiler to allocate memory. This is done to have the memory address as a multiple of the size of the variable. This speeds up the processing of these variables by the compiler. On Tue, Jul 26, 2011 at 8:09 PM, Puneet Gautam puneet.nsi...@gmail.comwrote: what is meant by padding in self_referenced structure? Is it always necessary? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, 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 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: direct i ..ques
(C(n+1,2))* (C(n+1,2)) choosing any two rows from n+1 rows, and any two columns from n+1 columns will yield a rectangle . So solution is the no of possible combinations. On Wed, Jul 27, 2011 at 11:23 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote: It will be (1+2+3+,,,+n)^2.u can verify it for a chess board hich will have 1296 rectangles for n=8 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/Yka7s3mbdwAJ. 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Puzzle!!!!!
Can some tell me the solution of this question?? 5. Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array. Eg. i) 3 2 7 10 should return 13 (sum of 3 and 10) ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7) -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Puzzle!!!!!
can you please send me the code snippet to get a better understanding. On Fri, Jul 29, 2011 at 9:51 AM, ankit sambyal ankitsamb...@gmail.comwrote: use the following recursive equation : S{i]=max(S[i-2]+a[i],S[i-1]) S[0]=a[0] S[1]=max(a[0],a[1]) S[size-1]is the required answer -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Programming Puzzle!!!!!!!
Please tell me the solution of this puzzle.. You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Puzzle!!!!!
thanks ankit. On Fri, Jul 29, 2011 at 9:59 AM, ankit sambyal ankitsamb...@gmail.comwrote: 1. Make an array S equal to the length of the given array where S[0] = a[0] and S[1] = max(a[0],a[1]) 2. for i:2 to n-1 S[i] = max(S[i-2]+a[i], S[i-1]) 3. return S[n-1] -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] binary search tree question!!!!
Please tell the solution of this question Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can’t pass the value k to any function also -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C - pre post increment
I think it is kind of illegal to use it, cos i tried this code on gcc compiler oof ubuntu(code b) and the result is infinite loop, which doesnt go with our logic at all. On Thu, Jul 21, 2011 at 5:45 PM, karthiga m karthichandr...@gmail.comwrote: no it is legal only... its working On 7/21/11, Reynald Suz reynaldsus...@gmail.com wrote: I tried in Dev C++,code-B executes infinitely. Why? On Thu, Jul 21, 2011 at 4:13 PM, Gaurav Popli abeygau...@gmail.com wrote: dont you think it is illegal using x=x-- or x=--x;?? On Thu, Jul 21, 2011 at 2:56 PM, karthiga m karthichandr...@gmail.com wrote: in code A using pr e- decrement therefore i gets decremented when checking while condition so it will print as 9 8 7 6 5 4 3 2 1 . in code B using post-decrement it will prints like 9 8 7 6 5 4 3 2 1 0 here why zero printing means while checking while condition x-- have previous value..therefore at tht time x-- is 1 so while condition executing and prints x value as zero. On 7/21/11, Reynald reynaldsus...@gmail.com wrote: Code: A int main() { int x = 10; while ( x = --x) printf( %d , x); getchar(); } Code: B int main() { int x = 10; while ( x = x--) printf( %d , x); getchar(); } Does Code-A and Code-B work similar? Justify. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - 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 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Shooters in a circle
they start shooting the person standing next to their neighbour On Thu, Jul 21, 2011 at 4:38 PM, Vivek Srivastava srivastava.vivek1...@gmail.com wrote: No,That is not the sequence?As I said 'I' will kill '3' as 3 is next to i's neighbour. On Thu, Jul 21, 2011 at 4:16 PM, SAMMM somnath.nit...@gmail.com wrote: Consider this Example:- 1 2 3 4 5 6 7 1 In CIrcle 1 kills 2 3 kills 4 5 kills 6 7 kills 1 Remaining ppl :- 3 5 7 3 kills 5 7 kills 3 Remain- 7 This is the sequence .. i guess Isit -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MS: Testing
Please specify the format of the date..! On Thu, Jul 21, 2011 at 3:28 PM, Radhika Renganathan radi.coo...@gmail.comwrote: Write test cases for a program which finds the next palindromic date given a date. -- radhika .. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C - pre post increment
My mistake, i forgot to initiate x. Sorry for the mistake. But for devc it is infinite, then should we ignore that? On Thu, Jul 21, 2011 at 7:40 PM, poised dip10c...@gmail.com wrote: Both the codes work perfectly on Ubuntu 11.04. (gcc) first code gives 0 in output. second one doesn't give 0 in output. both work as intended. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/yPBntEpz6gIJ. 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. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Microsoft Question!
@ankit gupta: superb solutn On Thu, Jul 21, 2011 at 8:09 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: To get complete 32 bit inverse : x=((x1)0x) | ((x1)0x); x=((x2)0x) | ((x2)0x); x=((x4)0x0F0F0F0F) | ((x4)0xF0F0F0F0); x=((x8)0x00FF00FF) | ((x8)0xFF00FF00); x=((x16)0x) | ((x16)0x); -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] BIT MANIPULATION
Solutn: 1101000 Start from rightmost bit-leftmost bit Find the starting and ending 1’s positions, here 3 and 7 If any 0 bw them… while traversing.. (bitwise r-l).. make it 1 and other adjacent right ” 1” as “0”. And this is your new no. here 111 If you find no “0” in bw ( eg for 00) Then ,a bit will be increased. Make first bit from left 1 and set the lower order (total_set_bits-1) bits.. this will be the new no. Here : 1000111. On Sat, Jul 9, 2011 at 2:53 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: I found a good question to try for bit manipulation.Try it... :) Given an integer x, find out the smallest integer which has same number of set bits as x and is greater than x. For example if the input integer is 12 (1100) then your function should return 17(10001). If the input integer is 3(11) then your function should return 5(101) -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
210 for the last one you posted On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Google Question
may be by checking the server logs !! On Fri, Jul 8, 2011 at 11:48 AM, Vishal Thanki vishaltha...@gmail.comwrote: google this question!! On Fri, Jul 8, 2011 at 11:47 AM, priyanshu priyanshuro...@gmail.com wrote: How to find the number users connected to the web?? -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Merging Sorted Arrays
Algo: 1 3 77 78 90 2 5 79 81 compare 1 2 =1 compare 3 2 =2 and call binary search on 2nd array widot 2 to identify a proper position for 3 and place it there. now arrays 1 2 77 78 90 3 5 79 81 3 and 77= swap + binary compare 3 and 77, swap them find position of 77 in second array and place there. using binary search 1 2 3 78 90 5 77 79 81 78 and 5 = swap + binary search 1 2 3 5 90 77 78 79 81 90 and 77= swap+ binary 1 2 3 5 77 78 79 81 90 ans found O(nlogn) binary search is O(logn) . On Fri, Jul 8, 2011 at 8:29 AM, durgesh kumar durgesh1...@gmail.com wrote: @dumanshu ok ! i got a O(n lgn) finally i don know exact complexity Let N = size of first array Find the first N smallest elements using one pointer in each array now swap the list of elements from index 0 to second-pointer in second array to first array with first_poiner+1 to N in first Array now,after swapnig we need to sort both array so complexity= n + n log n+ m log m (n is the size of of first array and m is the size of second array) . . . O(n) = (n log n ) or (m log m) thanks Durgesh -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] puzzle
Now let x be the answer we want, the number of drops required. So if the first egg breaks maximum we can have x-1 drops and so we must always put the first egg from height x. So we have determined that for a given x we must drop the first ball from x height. And now if the first drop of the first egg doesn’t breaks we can have x-2 drops for the second egg if the first egg breaks in the second drop. Taking an example, lets say 16 is my answer. That I need 16 drops to find out the answer. Lets see whether we can find out the height in 16 drops. First we drop from height 16,and if it breaks we try all floors from 1 to 15.If the egg don’t break then we have left 15 drops, so we will drop it from 16+15+1 =32nd floor. The reason being if it breaks at 32nd floor we can try all the floors from 17 to 31 in 14 drops (total of 16 drops). Now if it did not break then we have left 13 drops. and we can figure out whether we can find out whether we can figure out the floor in 16 drops. Lets take the case with 16 as the answer 1 + 15 16 if breaks at 16 checks from 1 to 15 in 15 drops 1 + 14 31 if breaks at 31 checks from 17 to 30 in 14 drops 1 + 13 45 . 1 + 12 58 1 + 11 70 1 + 10 81 1 + 9 91 1 + 8 100 We can easily do in the end as we have enough drops to accomplish the task Now finding out the optimal one we can see that we could have done it in either 15 or 14 drops only but how can we find the optimal one. From the above table we can see that the optimal one will be needing 0 linear trials in the last step. So we could write it as (1+p) + (1+(p-1))+ (1+(p-2)) + .+ (1+0) = 100. Let 1+p=q which is the answer we are looking for q (q+1)/2 =100 Solving for 100 you get q=14. So the answer is: 14 Drop first orb from floors 14, 27, 39, 50, 60, 69, 77, 84, 90, 95, 99, 100... (i.e. move up 14 then 13, then 12 floors, etc) until it breaks (or doesn't at 100). On Fri, Jul 8, 2011 at 1:07 AM, Sumit chauhan sumitchauhan...@gmail.comwrote: @sunny dude i got so excited after finding this solution i did not bother to check for 14 -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Merging Sorted Arrays
i dint get you.. one loop to access the first array elements and compare with second array, and one logn (for) loop to binary search the second array , thts it.. O(mlogn) is what i am able to understand. On Fri, Jul 8, 2011 at 5:52 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: @aman: Let size of *first array be m* and that of the *second array be* *n*. For m elements in first array you perform binary search therefore time O(mlogn) And for those some elements of the first array you perform shifting in array two...in the worst case for all the elements of first array you might have to perform shifting in second array and also you might just have to shift all the present (n-1) elements each time...so again in worst case this whole procedure will take O(mn) time so total coplexity of your idea is: O(mlogn) + O(mn) And if m is of the O(n) then this will take O(n^2) time in worst case. On Fri, Jul 8, 2011 at 2:40 PM, Aman Goyal aman.goya...@gmail.com wrote: Algo: 1 3 77 78 90 2 5 79 81 compare 1 2 =1 compare 3 2 =2 and call binary search on 2nd array widot 2 to identify a proper position for 3 and place it there. now arrays 1 2 77 78 90 3 5 79 81 3 and 77= swap + binary compare 3 and 77, swap them find position of 77 in second array and place there. using binary search 1 2 3 78 90 5 77 79 81 78 and 5 = swap + binary search 1 2 3 5 90 77 78 79 81 90 and 77= swap+ binary 1 2 3 5 77 78 79 81 90 ans found O(nlogn) binary search is O(logn) . On Fri, Jul 8, 2011 at 8:29 AM, durgesh kumar durgesh1...@gmail.comwrote: @dumanshu ok ! i got a O(n lgn) finally i don know exact complexity Let N = size of first array Find the first N smallest elements using one pointer in each array now swap the list of elements from index 0 to second-pointer in second array to first array with first_poiner+1 to N in first Array now,after swapnig we need to sort both array so complexity= n + n log n+ m log m (n is the size of of first array and m is the size of second array) . . . O(n) = (n log n ) or (m log m) thanks Durgesh -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- regards Apoorve Mohan -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Interview Questions ebook
Go for crack the interview. On Fri, Jul 1, 2011 at 9:06 AM, Antony Kotre antonyko...@gmail.com wrote: please suggest me or mail me a good interview questions ebook thanks -- 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 this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Aman (neshu) Agarwal wants to chat
--- Aman (neshu) Agarwal wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit: http://mail.google.com/mail/b-b44710bddc-6a8c132f56-rQdKCSY2nabAxzXd7j0SkQwzBZI You'll need to click this link to be able to chat with Aman (neshu) Agarwal. To get Gmail - a free email account from Google with over 2,800 megabytes of storage - and chat with Aman (neshu) Agarwal, visit: http://mail.google.com/mail/a-b44710bddc-6a8c132f56-rQdKCSY2nabAxzXd7j0SkQwzBZI Gmail offers: - Instant messaging right inside Gmail - Powerful spam protection - Built-in search for finding your messages and a helpful way of organizing emails into conversations - No pop-up ads or untargeted banners - just text ads and related information that are relevant to the content of your messages All this, and its yours for free. But wait, there's more! By opening a Gmail account, you also get access to Google Talk, Google's instant messaging service: http://www.google.com/talk/ Google Talk offers: - Web-based chat that you can use anywhere, without a download - A contact list that's synchronized with your Gmail account - Free, high quality PC-to-PC voice calls when you download the Google Talk client We're working hard to add new features and make improvements, so we might also ask for your comments and suggestions periodically. We appreciate your help in making our products even better! Thanks, The Google Team To learn more about Gmail and Google Talk, visit: http://mail.google.com/mail/help/about.html http://www.google.com/talk/about.html (If clicking the URLs in this message does not work, copy and paste them into the address bar of your browser). -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] EOF in Python for SPOJ
for line in sys.stdin: print line, print eof -- Aman Agarwal -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] EOF in Python for SPOJ
do not forget to import sys import sys for line in sys.stdin: print line, print eof On Wed, May 25, 2011 at 9:12 PM, Aman (neshu) Agarwal neshuagarwal1...@gmail.com wrote: for line in sys.stdin: print line, print eof -- Aman Agarwal -- Aman Agarwal -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Earn a ipod with just a facebook like
http://www.studyshare.in/share/content.php?195 I have received a apple shuffle few days back with just liking a facebook video. I am still boggled, but I want all of you earn it. Yes, this may sound spam, but it is a real story. pre Congrats for an ipod/tshirt/mug who are going to 'like' this facebook video. Just make sure your address is correctly entered on your facebook account. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] must experience
go on www.studyshare.in .. if u click 'like' on SECOND LAST video you can win a lucky draw with prizes such as t-shirts and mugs even ipods, provided u have given correct address at your facebook account. IT IS NOT SPAM. you can really experience it. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: first larger element in unsorted array...
this code will work only for this test case, it is wrong for all cases...eg3 4 9 8 6 7 10 there will be -1 output for 8 and 9 which is actually wrong.. On Tue, Feb 1, 2011 at 6:01 PM, Veenus Gupta smartvee...@gmail.com wrote: #define N 7 int main() { int a[N]={1,3,5,7,6,4,8}; int m[N]; m[N-1]=-1; for(int i=N-2;i=0;i--) { if(a[i]=a[i+1]) m[i]=a[i+1]; else m[i]=m[i+1]; } for(int i=0;iN;i++) coutm[i]\t; system(pause); } On Feb 1, 1:06 pm, abc abc may.i.answ...@gmail.com wrote: Guys please check correctness of your algorithm before posting On Mon, Jan 31, 2011 at 11:47 PM, ritu ritugarg.c...@gmail.com wrote: @Ralph Build a data structure on array B[1..n] in O(n) time such that the following problem can be solved in O(log n) time: Given an index i and value v, find the index j of the first element in B such that j = i and B[j] v. Return -1 if no such j exists. then it ll take n*lg(n) time ... while a o(n) solution exists On Jan 31, 9:25 pm, Ralph Boland rpbol...@gmail.com wrote: On Jan 30, 11:00 pm, ritu ritugarg.c...@gmail.com wrote: You are given an array (unsorted) and for every element i, find the first occurance of an element j (in the remaining array) that is greater than or equal to i. If no such j occurs then print -1. Eg: Input--- A={1,3,5,7,6,4,8} Output--- 3 5 7 8 8 8 -1 Time Complexity:O(n) Space Complexity:O(n) I solved a version of this problem in my thesis. Build a data structure on array B[1..n] in O(n) time such that the following problem can be solved in O(log n) time: Given an index i and value v, find the index j of the first element in B such that j = i and B[j] v. Return -1 if no such j exists. I have an application of this data structure in my thesis (which is why I invented it) but I would love to hear other applications. Ralph Boland -- 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.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2Bunsubscribe@googlegroups .com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: first larger element in unsorted array...
we can create a height balanced tree with all nodes having their value and also their index value.. can be done in o(n) then we need to look to d right side of the node and check for index(greater ).. which will be o(log(n)) correct me if i m wrong.. On Tue, Feb 1, 2011 at 7:50 PM, Aman Goyal aman.goya...@gmail.com wrote: this code will work only for this test case, it is wrong for all cases...eg3 4 9 8 6 7 10 there will be -1 output for 8 and 9 which is actually wrong.. On Tue, Feb 1, 2011 at 6:01 PM, Veenus Gupta smartvee...@gmail.comwrote: #define N 7 int main() { int a[N]={1,3,5,7,6,4,8}; int m[N]; m[N-1]=-1; for(int i=N-2;i=0;i--) { if(a[i]=a[i+1]) m[i]=a[i+1]; else m[i]=m[i+1]; } for(int i=0;iN;i++) coutm[i]\t; system(pause); } On Feb 1, 1:06 pm, abc abc may.i.answ...@gmail.com wrote: Guys please check correctness of your algorithm before posting On Mon, Jan 31, 2011 at 11:47 PM, ritu ritugarg.c...@gmail.com wrote: @Ralph Build a data structure on array B[1..n] in O(n) time such that the following problem can be solved in O(log n) time: Given an index i and value v, find the index j of the first element in B such that j = i and B[j] v. Return -1 if no such j exists. then it ll take n*lg(n) time ... while a o(n) solution exists On Jan 31, 9:25 pm, Ralph Boland rpbol...@gmail.com wrote: On Jan 30, 11:00 pm, ritu ritugarg.c...@gmail.com wrote: You are given an array (unsorted) and for every element i, find the first occurance of an element j (in the remaining array) that is greater than or equal to i. If no such j occurs then print -1. Eg: Input--- A={1,3,5,7,6,4,8} Output--- 3 5 7 8 8 8 -1 Time Complexity:O(n) Space Complexity:O(n) I solved a version of this problem in my thesis. Build a data structure on array B[1..n] in O(n) time such that the following problem can be solved in O(log n) time: Given an index i and value v, find the index j of the first element in B such that j = i and B[j] v. Return -1 if no such j exists. I have an application of this data structure in my thesis (which is why I invented it) but I would love to hear other applications. Ralph Boland -- 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.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2Bunsubscribe@googlegroups .com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] basic problem
thanx to all.special one to Sathaiah Dontula ..i got ur point and it is completely valid..!!! On Wed, Mar 24, 2010 at 1:37 PM, TurksHead Education turksheadeducat...@gmail.com wrote: This is because by definition linked lists are dynamic.. If they reside on stack they cannot be dynamic (extensible in size) On Wed, Mar 24, 2010 at 2:42 AM, aman goyal aman...@gmail.com wrote: why do we use malloc funtcn to allocate memory for a stuct node variable pointer.. why dont we simply write struct node p; instead we do struct node *p p=malloc(); any valid reasons for this?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@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.