Re: [algogeeks] Reverse
Thanks On Wed, Jun 29, 2011 at 2:45 AM, aditya kumar aditya.kumar130...@gmail.comwrote: @sagar : it works perfectly fine. On Tue, Jun 28, 2011 at 3:29 PM, sagar pareek sagarpar...@gmail.comwrote: Check out my solution above :) Its reversing the string On Tue, Jun 28, 2011 at 1:56 PM, shady sinv...@gmail.com wrote: no, you arent actually reversing anything, you are just printing. On Tue, Jun 28, 2011 at 11:40 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: #include stdio.h #include stdlib.h void revers(char *s) { if(*s) { revers(++s); s--; printf(%c ,*s); } } int main(int argc, char *argv[]) { char arr[]=string; revers(arr); system(PAUSE); return 0; } acording to above given definition of temporary variable will the above code also work for this question??? On Mon, Jun 27, 2011 at 11:56 PM, Swathi chukka.swa...@gmail.comwrote: it works perfectly On Mon, Jun 27, 2011 at 11:53 PM, hary rathor harry.rat...@gmail.comwrote: this solution according to sameer statement solution if there is any problem then pls tell me . here string or char is not being store anywhere char * reverse(char *str,int i ,int j) { while(ij) { str[i]=str[i]^str[j]; str[j]=str[i]^str[j]; str[i]=str[i]^str[j]; i++;j--; } return str; } int main () { char str[]=harish; printf(%s,reverse(str,0,sizeof(str)-2)); return 0; } -- 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, 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. -- 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 SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
Re: [algogeeks] Re: Amazon telephonic question
@bittu : In your first approach which u pointed out : What if the minimum element is poped out of the stack ?? We may have to search the whole stack to get the minimum element. O(n) in worst case In your second approach which u pointed out : If u use 2 stacks, consistency of 2 stacks in a problem and also we may have problems if we have duplicate problems. The complexity may be high if we use this approach. Just point out whats the complexity of ur approach On Wed, Jun 29, 2011 at 3:41 PM, bittu shashank7andr...@gmail.com wrote: @juver++ correct @ankit you can see here 1st Approach . You can implement this by having each node in the stack keep track of the minimum beneath itself. Then, to find the min, you just look at what the top element thinks is the min.When you push an element onto the stack, the element is given the current minimum. It sets its “local min” to be the min. The disadvantage of above algo is that if we have a large stack, we waste a lot of space by keeping track of the min for every single element. 2nd Approach(Use Two Stack) so We can (maybe) do a bit better than this by using an additional stack which keeps track of the mins. it is also good If many elements have the same local min, then we’re keeping a lot of duplicate data. so when we will push the value then we will push in 2nd stack as well. while popping if value is equal to min then we will remove it from 2nd stack. Hope It Will Help.:) Thanks Shashank I Don't Do Code to Code But I Do Code to Build Product Computer Science Engineering Birla Institute of Technology,Mesra -- 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] linked list
http://geeksforgeeks.org/?p=12000 -- 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/-/OnLux79bj3MJ. 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] strange output
scanf returns no of integers it read,not the read integer. On 6/26/11, sameer.mut...@gmail.com sameer.mut...@gmail.com wrote: It breaks out correctly when test condition value is 0 i.e when value of t is 1 On Sat, Jun 25, 2011 at 4:41 PM, sunny agrawal sunny816.i...@gmail.comwrote: No, Read about the return type of scanf On Sun, Jun 26, 2011 at 4:56 AM, amit the cool amitthecoo...@gmail.comwrote: main() { int i,t; for ( t=4;scanf(%d,i)-t;printf(%d\n,i)) printf(%d--,t--); } inputs and corresponding outputs are: 0 4--0 1 3--1 2 2--2 3 but the loop should break when 2 is given as input. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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: GOOGLE QUESTION
In TRIE , we can store nodes by characters. So it is very easy to search by names and hence their corresponding numbers :) . TRIE saves a lot memory coz it stares a character only once. LIKE :- if i want to save sagar with phone no. 123456789 then we store it in TRIE as : s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | NULL now if we want to add new contact as sagarika,123454321 then it will stored as :- s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | i-NULL | k-NULL | NULL now if we want to store new contact as sag,345678909 s-NULL | a-NULL | g-345678909 | a-NULL | r-123456789 | i-NULL | k-NULL | NULL I hope now you get how it saves a lot memory :) | a- 123454321 On Wed, Jun 29, 2011 at 11:31 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Swathi :We can't use trie data structure to store the phone numbers. The most sound reason is that the users require phone numbers to be sorted by name, but by using the trie data structure we can't get the phone numbers which are sorted by name. Again we can't use trie whose nodes are numbers, because phone numbers are searched by name always. Nobody searches for a name, given a number. And if we use names as the node in the trie, we end up using a lot of space because of pointers. Worst case time complexity of search using trie - O(n) Worst case time complexity of search using fixed array with circular indexing O(log n) because we can use binary search, and search is most frequent query in a list of phone numbers. I hope u got the idea. Another point is that we have very limited memory in a phone, so we have too use fixed 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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
Re: [algogeeks] Re: GOOGLE QUESTION
Sorry for the previous post it got a mistake here take a look again :- In TRIE , we can store nodes by characters. So it is very easy to search by names and hence their corresponding numbers :) . TRIE saves a lot memory coz it stares a character only once. LIKE :- if i want to save sagar with phone no. 123456789 then we store it in TRIE as : s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | NULL now if we want to add new contact as sagarika,123454321 then it will stored as :- s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | i-NULL | k-NULL | a-123454321 | NULL now if we want to store new contact as sag,345678909 s-NULL | a-NULL | g-345678909 | a-NULL | r-123456789 | i-NULL | k-NULL | a- 123454321 | NULL I hope now you get how it saves a lot memory :) On Thu, Jun 30, 2011 at 12:21 PM, sagar pareek sagarpar...@gmail.comwrote: In TRIE , we can store nodes by characters. So it is very easy to search by names and hence their corresponding numbers :) . TRIE saves a lot memory coz it stares a character only once. LIKE :- if i want to save sagar with phone no. 123456789 then we store it in TRIE as : s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | NULL now if we want to add new contact as sagarika,123454321 then it will stored as :- s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | i-NULL | k-NULL | NULL now if we want to store new contact as sag,345678909 s-NULL | a-NULL | g-345678909 | a-NULL | r-123456789 | i-NULL | k-NULL | NULL I hope now you get how it saves a lot memory :) | a- 123454321 On Wed, Jun 29, 2011 at 11:31 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Swathi :We can't use trie data structure to store the phone numbers. The most sound reason is that the users require phone numbers to be sorted by name, but by using the trie data structure we can't get the phone numbers which are sorted by name. Again we can't use trie whose nodes are numbers, because phone numbers are searched by name always. Nobody searches for a name, given a number. And if we use names as the node in the trie, we end up using a lot of space because of pointers. Worst case time complexity of search using trie - O(n) Worst case time complexity of search using fixed array with circular indexing O(log n) because we can use binary search, and search is most frequent query in a list of phone numbers. I hope u got the idea. Another point is that we have very limited memory in a phone, so we have too use fixed 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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
Re: [algogeeks] Backtracking!
Thanks for the link! -- 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/-/xHZEwuTNT2kJ. 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: GOOGLE QUESTION
I wonder why people have discarded the idea of Hash map here. Searching is obviously the most important task here and if we are to assume that names can be uniformly hashed over a table of 1000 rows with each row containing 1000 names each. Further optimization can be achieved by having names stored in binary search tree for each row. (So it will take max 10 comparisons to search a name) (Need to Keep it a balanced tree) So in all, a total of max 11 operations - 1 Hash + 10 comparisons will be used to search for any phone number. In the above, hashing is to be done on names obviously. On Thu, Jun 30, 2011 at 12:24 PM, sagar pareek sagarpar...@gmail.com wrote: Sorry for the previous post it got a mistake here take a look again :- In TRIE , we can store nodes by characters. So it is very easy to search by names and hence their corresponding numbers :) . TRIE saves a lot memory coz it stares a character only once. LIKE :- if i want to save sagar with phone no. 123456789 then we store it in TRIE as : s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | NULL now if we want to add new contact as sagarika,123454321 then it will stored as :- s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | i-NULL | k-NULL | a-123454321 | NULL now if we want to store new contact as sag,345678909 s-NULL | a-NULL | g-345678909 | a-NULL | r-123456789 | i-NULL | k-NULL | a- 123454321 | NULL I hope now you get how it saves a lot memory :) On Thu, Jun 30, 2011 at 12:21 PM, sagar pareek sagarpar...@gmail.com wrote: In TRIE , we can store nodes by characters. So it is very easy to search by names and hence their corresponding numbers :) . TRIE saves a lot memory coz it stares a character only once. LIKE :- if i want to save sagar with phone no. 123456789 then we store it in TRIE as : s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | NULL now if we want to add new contact as sagarika,123454321 then it will stored as :- s-NULL | a-NULL | g-NULL | a-NULL | r-123456789 | i-NULL | k-NULL | NULL now if we want to store new contact as sag,345678909 s-NULL | a-NULL | g-345678909 | a-NULL | r-123456789 | i-NULL | k-NULL | NULL I hope now you get how it saves a lot memory :) | a- 123454321 On Wed, Jun 29, 2011 at 11:31 PM, ankit sambyal ankitsamb...@gmail.com wrote: @Swathi :We can't use trie data structure to store the phone numbers. The most sound reason is that the users require phone numbers to be sorted by name, but by using the trie data structure we can't get the phone numbers which are sorted by name. Again we can't use trie whose nodes are numbers, because phone numbers are searched by name always. Nobody searches for a name, given a number. And if we use names as the node in the trie, we end up using a lot of space because of pointers. Worst case time complexity of search using trie - O(n) Worst case time complexity of search using fixed array with circular indexing O(log n) because we can use binary search, and search is most frequent query in a list of phone numbers. I hope u got the idea. Another point is that we have very limited memory in a phone, so we have too use fixed 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. -- Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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. -- --Navneet -- 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] Explain this.....
Well, according to gnu standards, it's never safe to depend on the order of evaluation of the arguements passed to a function. So the output in the above case would vary from compiler to compiler Source: http://gcc.gnu.org/onlinedocs/gcc/Non_002dbugs.html read the second last point -- 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/-/4IBDW_MOIpAJ. 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] Amazon Telephonic Interview Questions
1. write iterative program to find if a binary tree is binary search tree or not. 2. write iterative program to convert a binary tree into its mirror image. -- 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/-/waFGnRE_7voJ. 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: POWER CRISES :Spoj
@rizwaan u r ryt bt i want a O(n) soln .. whats say On Wed, Jun 29, 2011 at 2:55 PM, rizwan hudda rizwanhu...@gmail.com wrote: http://ideone.com/MSLXT The constraints are so less that you can brute force the solution..N100. My solution is O(N^3) On Thu, Jun 30, 2011 at 1:13 AM, harshit pahuja hpahuja.mn...@gmail.com wrote: http://en.wikipedia.org/wiki/Josephus_problem here there is an explanation of the derivation of josephus which is nt very clearcan some1 explain it plzz On Wed, Jun 29, 2011 at 12:40 PM, harshit pahuja hpahuja.mn...@gmail.com wrote: Hello guys... http://www.spoj.pl/problems/POCRI/ this problem is using a variant of josephus problem. in josephus we for given n persons in a circle we start killing every kth person and last person remaining is the survivor..kth 2kth 3kth...so on i solved it using f(n,k)=(f(n-1,k)+k)%m nd dp... nw in its variant which is the spoj problem we have to kill evert kth person but we have to start by killing 1st den (k+1)th den(2k+1)th so on i m nt able to modify the above problem plzz help -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. 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. -- Thanks and regards Rizwan A Hudda http://sites.google.com/site/rizwanhudda2 -- 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. -- HARSHIT PAHUJA M.N.N.I.T. 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.
[algogeeks] Re: Amazon Telephonic Interview Questions
For 1. you need an in-order traversal. During the visit check to see that each successive key is non-decreasing. For 2. you need a post order traversal. During the visit swap the left and right child pointers. Now you can look up the standard algorithms for these traversals. On Jun 30, 3:34 am, vikas mehta...@gmail.com wrote: 1. write iterative program to find if a binary tree is binary search tree or not. 2. write iterative program to convert a binary tree into its mirror image. -- 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: GOOGLE QUESTION
@samby You are wrong anyway. Main problem is to reduce memory while storing phone numbers. We have 1 million of phones, they have many common prefixes which can be addressed by trie. For storing names, you may use any data structure which is best for the particular problem. Key is name, and value is a leaf node in trie which represents desired phone number. If one want improve memory usage, they can build ternary trie based on already sorted phones, so it makes it balanced. -- 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/-/r3vvzArkr1kJ. 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: GOOGLE QUESTION
@Navneet Please read problem again - it is about memory efficient storing. -- 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/-/-hsmsOgm2YUJ. 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: Amazon Telephonic Interview Questions
for 1 i did implement exactly the same algorithms. and for 2 i donot know why but at that time i was not able to implement it iteratively and hense implemented its recursive version only. -- 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/-/hJswdQGammMJ. 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] Reverse
guy can anybody reverse without taking 0 extra variables ? -- 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] Reverse
We need at least one variable - loop counter. All other can be done via XOR. -- 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/-/AzSS4tMoDlYJ. 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] Reverse
@ juver++ : that i have already done. -- 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] Reverse
On Tue, Jun 28, 2011 at 3:04 PM, sagar pareek sagarpar...@gmail.com wrote: I have 1 more solution :- #includestdio.h #includestring.h main() { int i,j,l; char arr[100]; printf(Enter the string\n); fgets(arr,100,stdin); for(i=0,l=strlen(arr),j=l;i=l/2;i++) { arr[j--]=arr[i]; arr[i]=arr[j]; } for(i--;il;i++) arr[i]=arr[i+1]; arr[i]='\0'; printf(%s\n,arr); } I hope it will work perfect :) it works, but it does need extra space to swap variables, it uses '\0' space. personally speaking, I prefer to use XOR, it is so cool. :-) -- Regards Anders -- 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 Telephonic Interview Questions
1. check here http://ideone.com/VjjqN *int isBSTiterative(Tnode *root) {* *int prev = -9;* *Tnode *node = NULL;* *while (root) {* *push(root);* *if (root-left == NULL) {* ** *do {* *node = pop();* *if (node-data prev)* *return 0;* *prev = node-data;* *root = node-right;* *} while (root == NULL isempty() != 1);* *} else {* *root = root-left;* *}* *}* *return 1;* *}* 2.Check here http://ideone.com/yufa2 *Tnode *BTMirrorIterative(Tnode *root) {* *Tnode *node = NULL, *tmp = NULL;* * * *if (root == NULL)* *return root;* *while (root) {* *push(root);* *if (root-left != NULL)* *root = root-left;* *else if (root-right != NULL)* *root = root-right;* *else {* *do {* *node = pop();* *tmp = node-left;* *node-left = node-right;* *node-right = tmp;* * * *if (head == NULL)* *return root;* *root = head-data;* *} while (root-right == node || root-right == NULL);* *if (root-right != NULL)* *root = root-right;* *}* *}* *return NULL;* *}* Thanks Regards Anantha Krishnan On Thu, Jun 30, 2011 at 2:12 PM, vikas mehta...@gmail.com wrote: for 1 i did implement exactly the same algorithms. and for 2 i donot know why but at that time i was not able to implement it iteratively and hense implemented its recursive version only. -- 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/-/hJswdQGammMJ. 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: Amazon Telephonic Interview Questions
1. int chk_bst(node *root) { if(root) { enqueue(root); while(!isempty()) { p=dequeue(); if(p-left) { if(!(p-left-data p-data)) return 0; enqueue(p-left); } if(p-right) { if(!(p-right-data = p-data)) return 0; enqueue(p-right); } } } return 1; } 2. void mirror(node **root) { if(root) { enqueue(*root); while(!isempty()) { *p = dequeue(); if(*p-left) enqueue(*p-left); if(*p-right) enqueue(*p-right); swap(*p-left,*p-right); } } } On Thu, Jun 30, 2011 at 2:12 PM, vikas mehta...@gmail.com wrote: for 1 i did implement exactly the same algorithms. and for 2 i donot know why but at that time i was not able to implement it iteratively and hense implemented its recursive version only. -- 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/-/hJswdQGammMJ. 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.
Re: [algogeeks] Binary Tree
Try traversing in LEVEL order and maintain array for each level...(Levels can be found by height of tree) then try by calculating sums starting from root(level zero) to higher level. Its typical to explain here but i found it as a solution and that will definitely found the solution. On Thu, Jun 30, 2011 at 9:08 AM, rajeev bharshetty rajeevr...@gmail.comwrote: By traversing tree either preorder or inorder or postorder and storing the partial sums along the way and comparing the partial sums with the required sum can solve the problem On Wed, Jun 29, 2011 at 7:56 PM, Akshata Sharma akshatasharm...@gmail.com wrote: How to find a path in a given binary tree which sums up to a given target value? for example if the given BT is 5 / \ 3 2 / 7 and if the target is 10, then the path is root(5) + left node(3) + right node (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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
Re: [algogeeks] Re: Yahoo Question
Oh I got it. If ( interview at google) { Map reduce } else if(interview at yahoo) { Hadoop } else { Your personal preference. } On Thu, Jun 30, 2011 at 4:02 AM, bittu shashank7andr...@gmail.com wrote: 1.Use Haddop Map Reduce Framework .Obviously We Need Distributed Algo we will make one computer as master assign the job to all slave computer to do the crawling the web depending upon the geographic area ( m thinking real time problem).to crawled the maximum pages in least time we need above framework or any other distributed framework like google map reduce or GFS. computers are given for maximizing the crawling function minimizing the the crawling time time.. Algorithmically you ca think of its like a graph which has 100 connected components in it we will bfs to traverse each computer to find out the number of pages it has been crawled till now. i have given some overview hope it will help Thanks Shashank I Don't Do Code to Code But I Do Code to Build Product Computer Science Engineering Birla Institute of Technology,Mesra -- 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, chinna. -- 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] linked list
Here is one approach which works :) Traverse the list from a pointer name ptr when encounter odd then start traversing from a tmp pointer (start point is ptr-next) to find even no. when find it swap the numbers. then again start forwarding ptr. If during traversing ptr==tmp make flag=0(at start make it flag=1) if again ptr encounter odd then if flag=0 then tmp=ptr-next else tmp=tmp-next do it until tmp or ptr becomes null. :) I hope no questions :) :) On Thu, Jun 30, 2011 at 12:01 PM, Rohan Kalra ronziiretu...@gmail.comwrote: http://geeksforgeeks.org/?p=12000 -- 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/-/OnLux79bj3MJ. 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 SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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.
Re: [algogeeks] Re: Sort - Consecutive Array in O(n)
can we not use count sort because of O(n) .? -- 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] linked list
Check this http://ideone.com/1I40z On Wed, Jun 29, 2011 at 8:04 PM, Nishant Mittal mittal.nishan...@gmail.comwrote: segregate even and odd nodes in a singly linked list.Order of even and odd numbers must be same... e.g:- i/p list is 4-1-3-6-12-8-7-NULL o/p list 4-6-12-8-1-3-7-NULL -- 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] linked list
@sagar pareek If there are more fields in the node like: struct node{ int data; float mark; char ch; struct node *link; }; Here swapping *data* alone will corrupt the list right!! On Thu, Jun 30, 2011 at 4:38 PM, sagar pareek sagarpar...@gmail.com wrote: Here is one approach which works :) Traverse the list from a pointer name ptr when encounter odd then start traversing from a tmp pointer (start point is ptr-next) to find even no. when find it swap the numbers. then again start forwarding ptr. If during traversing ptr==tmp make flag=0(at start make it flag=1) if again ptr encounter odd then if flag=0 then tmp=ptr-next else tmp=tmp-next do it until tmp or ptr becomes null. :) I hope no questions :) :) On Thu, Jun 30, 2011 at 12:01 PM, Rohan Kalra ronziiretu...@gmail.comwrote: http://geeksforgeeks.org/?p=12000 -- 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/-/OnLux79bj3MJ. 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 SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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] meaning of null in output
what is meaning of (null) in d output in cnd what r d possible reason nd causes for dt -- 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] conditional compilation
somewhere i read dt conditional compilation such as #if and #elif etc cn only use constant expressions and previously defined macrosthey cant use variables cz preprocessng is done b4 compilation... bt whn i try it on gcc and vc both r compiling it with variables abs. fyneven disabling extensions dint work i.e int i; #if i+1 printf(hi); vl print hi...no error occurs #endif thn i read it on net dt it cn eval. varables also nw m confused who is ryt... whtr it cn eval var also or nt... nd if it cn thn hws it possible dt preprocessor knows d val. of var. b4 compiling d prog... -- 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: conditional compilation
1 more thngif its possible to eval. variable expression lyk abv... thn... int i=2; #if i==2 printf(hi); #else printf(bye); //prints byei think it shld print hi... #endif even this code prints bye. int i=3; #if i==2 printf(hi); #else printf(bye); #endif On Thu, Jun 30, 2011 at 5:13 PM, himanshu kansal himanshukansal...@gmail.com wrote: somewhere i read dt conditional compilation such as #if and #elif etc cn only use constant expressions and previously defined macrosthey cant use variables cz preprocessng is done b4 compilation... bt whn i try it on gcc and vc both r compiling it with variables abs. fyneven disabling extensions dint work i.e int i; #if i+1 printf(hi); vl print hi...no error occurs #endif thn i read it on net dt it cn eval. varables also nw m confused who is ryt... whtr it cn eval var also or nt... nd if it cn thn hws it possible dt preprocessor knows d val. of var. b4 compiling d prog... -- Regards Himanshu Kansal Msc Comp. sc. (University of Delhi) -- 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] Binary Tree
My approach : int FindPath(Node n , sum s ) { FindPath(n-left , s ) || FindPath(n-right , s) || OneOf { a1 = AllSumsFromLeafToRoot( n-left ) } + n-value + Oneof { a2 = AllSumsFromLeafToRoot( n-right ) == s ) } // Use a1 and a2 to find out the actual path } Here all possible sums from a node to the leaves can be precomputed in O(n) (one inorder traversal) and so lookup can be made in O(1). For each node store child_left , sum1,sum2,sum3 ... , child_right , sum1,sum2,sum3 ... We may need this data to traverse the tree again with the sum values to find the path. Looks complicated to me too, waiting for comments. On Thu, Jun 30, 2011 at 4:17 PM, sagar pareek sagarpar...@gmail.com wrote: Try traversing in LEVEL order and maintain array for each level...(Levels can be found by height of tree) then try by calculating sums starting from root(level zero) to higher level. Its typical to explain here but i found it as a solution and that will definitely found the solution. On Thu, Jun 30, 2011 at 9:08 AM, rajeev bharshetty rajeevr...@gmail.comwrote: By traversing tree either preorder or inorder or postorder and storing the partial sums along the way and comparing the partial sums with the required sum can solve the problem On Wed, Jun 29, 2011 at 7:56 PM, Akshata Sharma akshatasharm...@gmail.com wrote: How to find a path in a given binary tree which sums up to a given target value? for example if the given BT is 5 / \ 3 2 / 7 and if the target is 10, then the path is root(5) + left node(3) + right node (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. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT 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. -- regards, chinna. -- 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] Partial Roundrobin Generation
Hello, I've been working on a problem in which I want to generate half, partial, and full round-robin schedules for teams. The half roundrobin was no problem, and the full can be done by repeating the process and by checking who was home/away in the first half roundrobin and flipping it in the second and combining the two for a full. However, the partial is giving me some trouble. The catch is that I'd like to keep the home/away either equal if the number of weeks is even, or 50% of the teams having (floor(n/2) + 1) home games and the other half having floor(n/2) home games if the number of weeks is even. Does anybody have a good recommendation on how to go about doing this? Also, my half RR assignment may be inefficient. I go about it by assigning the matchups of Team A vs Team B, etc. and then in a second stage, assigning home/away. Is there a way to simply combine this? Thanks, Richard -- 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] Another spoj problem
Any idea how to solve this problem? I am currently using graph and counting adjacent edges for the index. 1 2 \ \ 3 eg for this graph structure 2 will have maximum possible friends.I am still sorting out the bugs in my code. Anybody has better solution? -- Saurabh Singh B.Tech (Computer Science) 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.
[algogeeks] Constructing a Binary Search Tree from Post Order traversal-Possible or not
Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- 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: Constructing a Binary Search Tree from Post Order traversal-Possible or not
if BST contains integers then sort the postorder traversal which will give you inorder traversal... On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote: Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- 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: Constructing a Binary Search Tree from Post Order traversal-Possible or not
it can be done without sorting(Finding any other traversal) Do it recursively, last element of the traversal will be head, and now if you will see in the traversal left part of the traversal will be its LST and Right will be RST (except Head) only thing you need to find will be the index of the element which divides the traversal into LST and RST. this index can be find very easily beacause all elements of LST are less than root value. On Thu, Jun 30, 2011 at 7:16 PM, Nishant mittal.nishan...@gmail.com wrote: if BST contains integers then sort the postorder traversal which will give you inorder traversal... On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote: Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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] Another spoj problem
Problem Link ? On Thu, Jun 30, 2011 at 6:48 PM, saurabh singh saurab...@gmail.com wrote: Any idea how to solve this problem? I am currently using graph and counting adjacent edges for the index. 1 2 \ \ 3 eg for this graph structure 2 will have maximum possible friends.I am still sorting out the bugs in my code. Anybody has better solution? -- Saurabh Singh B.Tech (Computer Science) 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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] Another spoj problem
very sorry.. https://www.spoj.pl/problems/socialne/ https://www.spoj.pl/problems/socialne/apologies once again On Thu, Jun 30, 2011 at 7:23 PM, sunny agrawal sunny816.i...@gmail.comwrote: Problem Link ? On Thu, Jun 30, 2011 at 6:48 PM, saurabh singh saurab...@gmail.comwrote: Any idea how to solve this problem? I am currently using graph and counting adjacent edges for the index. 1 2 \ \ 3 eg for this graph structure 2 will have maximum possible friends.I am still sorting out the bugs in my code. Anybody has better solution? -- Saurabh Singh B.Tech (Computer Science) 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Saurabh Singh B.Tech (Computer Science) 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.
Re: [algogeeks] Another spoj problem
http://www.spoj.pl/problems/SOCIALNE/ On Thu, Jun 30, 2011 at 7:25 PM, saurabh singh saurab...@gmail.com wrote: very sorry.. https://www.spoj.pl/problems/socialne/ https://www.spoj.pl/problems/socialne/apologies once again On Thu, Jun 30, 2011 at 7:23 PM, sunny agrawal sunny816.i...@gmail.comwrote: Problem Link ? On Thu, Jun 30, 2011 at 6:48 PM, saurabh singh saurab...@gmail.comwrote: Any idea how to solve this problem? I am currently using graph and counting adjacent edges for the index. 1 2 \ \ 3 eg for this graph structure 2 will have maximum possible friends.I am still sorting out the bugs in my code. Anybody has better solution? -- Saurabh Singh B.Tech (Computer Science) 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- Saurabh Singh B.Tech (Computer Science) 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.
Re: [algogeeks] Re: Constructing a Binary Search Tree from Post Order traversal-Possible or not
I am unable to find a test case where this particular approach fails( I hardly thinks it's correct but anyway here it is). We make the last element the root of the BST. And keep inserting each element one by one just like normal binary tree insertion. This will take O(n^2) time in worst case( when the tree is only leftist or rightist). For a balance tree it will be T(nLogn). On Thu, Jun 30, 2011 at 7:22 PM, sunny agrawal sunny816.i...@gmail.comwrote: it can be done without sorting(Finding any other traversal) Do it recursively, last element of the traversal will be head, and now if you will see in the traversal left part of the traversal will be its LST and Right will be RST (except Head) only thing you need to find will be the index of the element which divides the traversal into LST and RST. this index can be find very easily beacause all elements of LST are less than root value. On Thu, Jun 30, 2011 at 7:16 PM, Nishant mittal.nishan...@gmail.comwrote: if BST contains integers then sort the postorder traversal which will give you inorder traversal... On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote: Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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: Constructing a Binary Search Tree from Post Order traversal-Possible or not
Check this http://ideone.com/ARsJ1 On Thu, Jun 30, 2011 at 7:48 PM, oppilas . jatka.oppimi...@gmail.comwrote: I am unable to find a test case where this particular approach fails( I hardly thinks it's correct but anyway here it is). We make the last element the root of the BST. And keep inserting each element one by one just like normal binary tree insertion. This will take O(n^2) time in worst case( when the tree is only leftist or rightist). For a balance tree it will be T(nLogn). On Thu, Jun 30, 2011 at 7:22 PM, sunny agrawal sunny816.i...@gmail.comwrote: it can be done without sorting(Finding any other traversal) Do it recursively, last element of the traversal will be head, and now if you will see in the traversal left part of the traversal will be its LST and Right will be RST (except Head) only thing you need to find will be the index of the element which divides the traversal into LST and RST. this index can be find very easily beacause all elements of LST are less than root value. On Thu, Jun 30, 2011 at 7:16 PM, Nishant mittal.nishan...@gmail.comwrote: if BST contains integers then sort the postorder traversal which will give you inorder traversal... On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote: Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give reason/counter examples. -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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] Re: SPOJ GPA1
@kartik sachan: I just compared your output file with the output file for this test case 5 1 2 3 4 5 19 ab ab 100 50 20 20 20 75 75 10 0 ab 88 0 13 12 15.5 88 99 12 7 9 66 66 11 ab ab 99 100 your code outputs FAILED, 4.35 but actually he's PASSED, 7.20 I think you are assuming he's fail if he bunks 2 internal assessments. -- 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] Office Suite
circular linklist containing three pointers start,end,current On 6/27/11, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha k but i think we need to store the bottom of the stack for deleting the last node in O(1). as we can click the redo or undo fixed number of times and we would need two stacks is that ok. On Mon, Jun 27, 2011 at 10:31 PM, radha krishnan radhakrishnance...@gmail.com wrote: You asked the Most Efficient dude On Mon, Jun 27, 2011 at 10:29 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha: hw abt using a fixed size circular list? On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan radhakrishnance...@gmail.com wrote: simple!! Stack:P On Sat, Jun 25, 2011 at 8:11 PM, rShetty rajeevr...@gmail.com wrote: Suggest the most efficient Data Structures and algorithms to implement Undo and Redo operations in any of the Office Suites ? -- You received this message because you are subscribed to the Google Groups 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. -- 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] Java Developer Needed in MD -- F2F required
Hello Associates, Wishes for the day!! Please go through the below requirement and let me know if you have any consultants for the below position? *Job Title: Java Developer Location: Silver Spring, MD Duration: 7-12 Months* Must have skills: Java 5; JEE technologies Expertise with Spring, iBatis and Velocity Oracle or other RDBMS Rational Application Developer WebSphere application server Web technologies: HTML, HTML5, JavaScript, CSS, JQuery, cross-browser compatibility CVS or SVN source code control Continuous Integration development Experience working in an Agile or Scrum team Desired Skills: Endeca Linux Apache configuration Experience building and installing software, including open source Strong shell scripting skills Akamai or other CDN Content Management Systems (CMS) Autonomy TeamSite MySQL server administration Mobile applications (iOS/Android) Required Qualifications: Requires bachelor's degree (in Computer Science or related field). Eight years of related experience in J2EE development. Thanks Leon Parker - l...@panzersolutions.com 203-983-9475 -- 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] Java Developer Needed in MD -- F2F required
banned On Thu, Jun 30, 2011 at 10:13 PM, Leon Parker leon.pan...@gmail.com wrote: Hello Associates, Wishes for the day!! Please go through the below requirement and let me know if you have any consultants for the below position? *Job Title: Java Developer Location: Silver Spring, MD Duration: 7-12 Months* Must have skills: Java 5; JEE technologies Expertise with Spring, iBatis and Velocity Oracle or other RDBMS Rational Application Developer WebSphere application server Web technologies: HTML, HTML5, JavaScript, CSS, JQuery, cross-browser compatibility CVS or SVN source code control Continuous Integration development Experience working in an Agile or Scrum team Desired Skills: Endeca Linux Apache configuration Experience building and installing software, including open source Strong shell scripting skills Akamai or other CDN Content Management Systems (CMS) Autonomy TeamSite MySQL server administration Mobile applications (iOS/Android) Required Qualifications: Requires bachelor's degree (in Computer Science or related field). Eight years of related experience in J2EE development. Thanks Leon Parker - l...@panzersolutions.com 203-983-9475 -- 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] Java Developer Needed in MD -- F2F required
banned in 6 mins pretty cool... :) On Thu, Jun 30, 2011 at 10:19 PM, shady sinv...@gmail.com wrote: banned On Thu, Jun 30, 2011 at 10:13 PM, Leon Parker leon.pan...@gmail.com wrote: Hello Associates, Wishes for the day!! Please go through the below requirement and let me know if you have any consultants for the below position? Job Title: Java Developer Location: Silver Spring, MD Duration: 7-12 Months Must have skills: Java 5; JEE technologies Expertise with Spring, iBatis and Velocity Oracle or other RDBMS Rational Application Developer WebSphere application server Web technologies: HTML, HTML5, JavaScript, CSS, JQuery, cross-browser compatibility CVS or SVN source code control Continuous Integration development Experience working in an Agile or Scrum team Desired Skills: Endeca Linux Apache configuration Experience building and installing software, including open source Strong shell scripting skills Akamai or other CDN Content Management Systems (CMS) Autonomy TeamSite MySQL server administration Mobile applications (iOS/Android) Required Qualifications: Requires bachelor's degree (in Computer Science or related field). Eight years of related experience in J2EE development. Thanks Leon Parker - l...@panzersolutions.com 203-983-9475 -- 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. -- Cheers Naveen Kumar -- 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] Office Suite
stack is the best option, isnt it ? O(1) for both operations. On Thu, Jun 30, 2011 at 9:55 PM, Jitendra singh jsinghrath...@gmail.comwrote: circular linklist containing three pointers start,end,current On 6/27/11, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha k but i think we need to store the bottom of the stack for deleting the last node in O(1). as we can click the redo or undo fixed number of times and we would need two stacks is that ok. On Mon, Jun 27, 2011 at 10:31 PM, radha krishnan radhakrishnance...@gmail.com wrote: You asked the Most Efficient dude On Mon, Jun 27, 2011 at 10:29 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha: hw abt using a fixed size circular list? On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan radhakrishnance...@gmail.com wrote: simple!! Stack:P On Sat, Jun 25, 2011 at 8:11 PM, rShetty rajeevr...@gmail.com wrote: Suggest the most efficient Data Structures and algorithms to implement Undo and Redo operations in any of the Office Suites ? -- You received this message because you are subscribed to the Google Groups 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. -- 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] Google Interview
can anybody give an example...pls.. On Thu, Jun 30, 2011 at 9:26 AM, Jitendra singh jsinghrath...@gmail.comwrote: kthlargest(a[],b[],lefta,righta,leftb,rightb,k) { mida=lefta+(righta-lefta)/2; midb=leftb+(rightb-leftb)/2; if(a[mida]bmidb]) kthlargest(a[],b[],mida+1,righta,leftb,midb-1); elseif(a[mida]bmidb]) kthlargest(a[],b[],lefta,mida-1,midb+1,rightb,); else return a[mida]; } On 6/25/11, Anantha Krishnan ananthakrishnan@gmail.com wrote: Idea is like this since both the arrays may not be of same length lets divide (k-1) smallest elements proportionally in both the arrays: let i point the array A by i=m/(m+n) * (k-1) [since we have to divide k-1 elements among two] j=(k-1) - i then try to insert A[i] between B[j-1] and B[j] if three are not in asc order try to insert B[j] between A[i-1] and A[i] If any one of the above satisfies we found kth smallest element else, check which one is smallest among A[i] and B[j] its logical that if A[i] is smallest then we can A[0] to A[i] for the next iteration and k becomes k-i-1 also m becomes m-i-1 i.e now we have only m-i-1+n elements out of which we have to find k-i-1th smallest thus the iteration goes on until we find our kth smallest element. Consider 2 arrays A={5,7,9,20}; length of A: m=4 B={10,12,21,27,35,50}; length of B: n=6 let K be 4 i=4/10*3=1; A[1]=7; j=3-1=2; B[2]=21; B[1]=12 A[1]=7 B[2]=21 [not in asc order] A[0]=5 B[2]=21 A[1]=7 [not in asc order] so now, k=k-i-1 =4-1-1=2 m=m-i-1=4-1-1=2 n=6 A={9,20}; length of A: m=2 B={10,12,21,27,35,50}; length of B: n=6 i=2/8*1=0; A[0]=9; j=1-0=1; B[1]=12; (acutally A[-1] is just for understanding) B[0]=10 A[0]=9 B[1]=12 [not in asc order] A[-1]=-INF B[1]=12 A[0]=9 [not in asc order] now, k=k-i-1=2-0-1=1; m=m-i-1=2-0-1=1; n=6; A={20}; length of A: m=1 B={10,12,21,27,35,50}; length of B: n=6 i=1/7*0=0; A[0]=20; j=0-0=0; B[0]=10; (acutally A[-1] and B[-1] are just for understanding) B[-1]=-INF A[0]=20 B[0]=10 [not in asc order] A[-1]=-INF B[0]=10 A[0]=20 [in asc order] We got the Kth(4th) smallest element which is 10. Thanks Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 11:20 PM, Akshata Sharma akshatasharm...@gmail.comwrote: @Anantha can you explain the logic please? On Fri, Jun 24, 2011 at 10:21 PM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Check this http://ideone.com/C8fQC http://ideone.com/C8fQCThanks Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 10:18 PM, Decipher ankurseth...@gmail.com wrote: Can anybody please explain how to solve this question with logarithmic time complexity ? Write the code/algorithm to find the k-th Smallest Element in the Union of Two Sorted Arrays . -- 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. -- 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
[algogeeks] null macro
null macro is defined as #define NULL (void*)0..is there any difference in null macro definition in c and c++? -- 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: Google Interview
@Jitendra: where r u using k in the first call? On Jun 30, 8:56 am, Jitendra singh jsinghrath...@gmail.com wrote: kthlargest(a[],b[],lefta,righta,leftb,rightb,k) { mida=lefta+(righta-lefta)/2; midb=leftb+(rightb-leftb)/2; if(a[mida]bmidb]) kthlargest(a[],b[],mida+1,righta,leftb,midb-1); elseif(a[mida]bmidb]) kthlargest(a[],b[],lefta,mida-1,midb+1,rightb,); else return a[mida]; } On 6/25/11, Anantha Krishnan ananthakrishnan@gmail.com wrote: Idea is like this since both the arrays may not be of same length lets divide (k-1) smallest elements proportionally in both the arrays: let i point the array A by i=m/(m+n) * (k-1) [since we have to divide k-1 elements among two] j=(k-1) - i then try to insert A[i] between B[j-1] and B[j] if three are not in asc order try to insert B[j] between A[i-1] and A[i] If any one of the above satisfies we found kth smallest element else, check which one is smallest among A[i] and B[j] its logical that if A[i] is smallest then we can A[0] to A[i] for the next iteration and k becomes k-i-1 also m becomes m-i-1 i.e now we have only m-i-1+n elements out of which we have to find k-i-1th smallest thus the iteration goes on until we find our kth smallest element. Consider 2 arrays A={5,7,9,20}; length of A: m=4 B={10,12,21,27,35,50}; length of B: n=6 let K be 4 i=4/10*3=1; A[1]=7; j=3-1=2; B[2]=21; B[1]=12 A[1]=7 B[2]=21 [not in asc order] A[0]=5 B[2]=21 A[1]=7 [not in asc order] so now, k=k-i-1 =4-1-1=2 m=m-i-1=4-1-1=2 n=6 A={9,20}; length of A: m=2 B={10,12,21,27,35,50}; length of B: n=6 i=2/8*1=0; A[0]=9; j=1-0=1; B[1]=12; (acutally A[-1] is just for understanding) B[0]=10 A[0]=9 B[1]=12 [not in asc order] A[-1]=-INF B[1]=12 A[0]=9 [not in asc order] now, k=k-i-1=2-0-1=1; m=m-i-1=2-0-1=1; n=6; A={20}; length of A: m=1 B={10,12,21,27,35,50}; length of B: n=6 i=1/7*0=0; A[0]=20; j=0-0=0; B[0]=10; (acutally A[-1] and B[-1] are just for understanding) B[-1]=-INF A[0]=20 B[0]=10 [not in asc order] A[-1]=-INF B[0]=10 A[0]=20 [in asc order] We got the Kth(4th) smallest element which is 10. Thanks Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 11:20 PM, Akshata Sharma akshatasharm...@gmail.comwrote: @Anantha can you explain the logic please? On Fri, Jun 24, 2011 at 10:21 PM, Anantha Krishnan ananthakrishnan@gmail.com wrote: Check thishttp://ideone.com/C8fQC http://ideone.com/C8fQCThanks Regards, Anantha Krishnan On Fri, Jun 24, 2011 at 10:18 PM, Decipher ankurseth...@gmail.comwrote: Can anybody please explain how to solve this question with logarithmic time complexity ? Write the code/algorithm to find the k-th Smallest Element in the Union of Two Sorted Arrays . -- 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. -- 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] Office Suite
stack, real implmentation is also stack AFAIK Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Thu, Jun 30, 2011 at 10:34 PM, shady sinv...@gmail.com wrote: stack is the best option, isnt it ? O(1) for both operations. On Thu, Jun 30, 2011 at 9:55 PM, Jitendra singh jsinghrath...@gmail.comwrote: circular linklist containing three pointers start,end,current On 6/27/11, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha k but i think we need to store the bottom of the stack for deleting the last node in O(1). as we can click the redo or undo fixed number of times and we would need two stacks is that ok. On Mon, Jun 27, 2011 at 10:31 PM, radha krishnan radhakrishnance...@gmail.com wrote: You asked the Most Efficient dude On Mon, Jun 27, 2011 at 10:29 PM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @radha: hw abt using a fixed size circular list? On Sat, Jun 25, 2011 at 8:25 PM, radha krishnan radhakrishnance...@gmail.com wrote: simple!! Stack:P On Sat, Jun 25, 2011 at 8:11 PM, rShetty rajeevr...@gmail.com wrote: Suggest the most efficient Data Structures and algorithms to implement Undo and Redo operations in any of the Office Suites ? -- You received this message because you are subscribed to the Google Groups 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. -- 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.
Re: [algogeeks] Printing unique rows.
we can convert all rows in an equivalent integer and then sort all numbers and for(int i=1;i=n;i++) { if(sorted[i]==sorted[i-1]) prinf(sorted[i]); } On 6/28/11, sunny agrawal sunny816.i...@gmail.com wrote: @Ankit if N is large how will you hash the rows, numbers will be very large can you explain using given example ? On Tue, Jun 28, 2011 at 11:38 AM, Ankit Agrawal ankitmnnit.agra...@gmail.com wrote: u can use hashing ... hash fun can b base2 to base10 -- 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. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- 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] Re: Amazon - Longest palindrome in a string in O(n)
heres the code: http://ideone.com/aiG1m using the algo from http://www.akalin.cx/2007/11/28/finding-the-longest-palindromic-substring-in-linear-time/ On Jun 21, 11:31 pm, Swathi chukka.swa...@gmail.com wrote: Does any one know how to return the Longest palindrome in a string in O(n). From googling i found that we can use suffix trees but there is no code. I am looking for logic and also for running code. Thanks, Swathi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. 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: POWER CRISES :Spoj
any1??? On Thu, Jun 30, 2011 at 12:45 AM, harshit pahuja hpahuja.mn...@gmail.comwrote: @rizwaan u r ryt bt i want a O(n) soln .. whats say On Wed, Jun 29, 2011 at 2:55 PM, rizwan hudda rizwanhu...@gmail.comwrote: http://ideone.com/MSLXT The constraints are so less that you can brute force the solution..N100. My solution is O(N^3) On Thu, Jun 30, 2011 at 1:13 AM, harshit pahuja hpahuja.mn...@gmail.com wrote: http://en.wikipedia.org/wiki/Josephus_problem here there is an explanation of the derivation of josephus which is nt very clearcan some1 explain it plzz On Wed, Jun 29, 2011 at 12:40 PM, harshit pahuja hpahuja.mn...@gmail.com wrote: Hello guys... http://www.spoj.pl/problems/POCRI/ this problem is using a variant of josephus problem. in josephus we for given n persons in a circle we start killing every kth person and last person remaining is the survivor..kth 2kth 3kth...so on i solved it using f(n,k)=(f(n-1,k)+k)%m nd dp... nw in its variant which is the spoj problem we have to kill evert kth person but we have to start by killing 1st den (k+1)th den(2k+1)th so on i m nt able to modify the above problem plzz help -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. 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. -- Thanks and regards Rizwan A Hudda http://sites.google.com/site/rizwanhudda2 -- 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. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. 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.
[algogeeks] Re: MS
lets take the example {1,2, 10, 2, 3, 5, 1, 1,2,3,5,2} clearly min distance is 1 between a=2 b=5 take variables current=-1 min=INT_Max so we start from last element say its index is last which is array size -1 check it with a b if its equal to any of these then check current !=- a[current]!=a[last] if its true then compare min with min current-last update the min e.g min=minimum(min,current-last) set current=n; repeat until we run out of loop so function looks like minDistance (int a[], int n, int b, int c) { int ret = INT_MAX, cur rent= -1; while(n--) { if(a[n] == b || a[n] == c) { if(cur rent!= -1 a[current] != a[n]) { min = minimum(min, current - n); } current = n//upodate current } Thanks Shashank Mani CSE, BIT Mesra -- 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] null macro
no difference On Thu, Jun 30, 2011 at 11:24 PM, simran ngxprerna2...@gmail.com wrote: null macro is defined as #define NULL (void*)0..is there any difference in null macro definition in c and c++? -- 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] c output:
program 1; output :1 int main() { int i; i= 1,2,3; printf(i:%d\n,i); return 0; } program 2; output: ERROR int main() { int i=1,2,3; printf(i:%d\n,i); return 0; } pls explain -- 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] please explain
this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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.
Re: [algogeeks] c output:
@harry: it ll b btr if u go to this link n clr ur doubts link : http://en.wikipedia.org/wiki/Comma_operator On Fri, Jul 1, 2011 at 3:56 AM, hary rathor harry.rat...@gmail.com wrote: program 1; output :1 int main() { int i; i= 1,2,3; printf(i:%d\n,i); return 0; } program 2; output: ERROR int main() { int i=1,2,3; printf(i:%d\n,i); return 0; } pls explain -- 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] please explain
int maxdiff(int ); int maxdiff(int arr[]); The signatures of maxdiff function are not the same. On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote: this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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] please explain
still it's not working On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote: int maxdiff(int ); int maxdiff(int arr[]); The signatures of maxdiff function are not the same. On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote: this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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. -- with regards, Ashwini kumar singh ECE Final yr. MNNIT Allahabad *Mobile: *7505519402 -- 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] please explain
actually u r passing arr,and receiving arr[] which actually receives the first element address. So arr will be a reference to first address. so its size will be 4 bytes and arr size will also be 4 bytes. so ur len contains only 1. so ur loop runs only once.i hope it clears. On Thu, Jun 30, 2011 at 4:49 PM, ashwini singh asingh...@gmail.com wrote: still it's not working On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote: int maxdiff(int ); int maxdiff(int arr[]); The signatures of maxdiff function are not the same. On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.comwrote: this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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. -- with regards, Ashwini kumar singh ECE Final yr. MNNIT Allahabad *Mobile: *7505519402 -- 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. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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: Google Interview
check this code http://ideone.com/rX130 compares k/2 values of each array taking care of extremes. On Jun 24, 9:48 pm, Decipher ankurseth...@gmail.com wrote: Can anybody please explain how to solve this question with logarithmic time complexity ? Write the code/algorithm to find the k-th Smallest Element in the Union of Two Sorted Arrays . -- 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: conditional compilation
i think it will take a garbage value for i because these are preprocessor directives. On Jun 30, 4:46 pm, himanshu kansal himanshukansal...@gmail.com wrote: 1 more thngif its possible to eval. variable expression lyk abv... thn... int i=2; #if i==2 printf(hi); #else printf(bye); //prints byei think it shld print hi... #endif even this code prints bye. int i=3; #if i==2 printf(hi); #else printf(bye); #endif On Thu, Jun 30, 2011 at 5:13 PM, himanshu kansal himanshukansal...@gmail.com wrote: somewhere i read dt conditional compilation such as #if and #elif etc cn only use constant expressions and previously defined macrosthey cant use variables cz preprocessng is done b4 compilation... bt whn i try it on gcc and vc both r compiling it with variables abs. fyneven disabling extensions dint work i.e int i; #if i+1 printf(hi); vl print hi...no error occurs #endif thn i read it on net dt it cn eval. varables also nw m confused who is ryt... whtr it cn eval var also or nt... nd if it cn thn hws it possible dt preprocessor knows d val. of var. b4 compiling d prog... -- Regards Himanshu Kansal Msc Comp. sc. (University of Delhi) -- 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] Interview Questions ebook
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.
Re: [algogeeks] please explain
Rujin is right, here is the code which compiles.. vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c #includestdio.h int maxdiff(int arr[]); int main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); return 0; } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } vishal@ubuntu:~/progs/c\ 11:04:40 AM $ gcc alg.c -Wall On Fri, Jul 1, 2011 at 7:20 AM, varun pahwa varunpahwa2...@gmail.com wrote: actually u r passing arr,and receiving arr[] which actually receives the first element address. So arr will be a reference to first address. so its size will be 4 bytes and arr size will also be 4 bytes. so ur len contains only 1. so ur loop runs only once.i hope it clears. On Thu, Jun 30, 2011 at 4:49 PM, ashwini singh asingh...@gmail.com wrote: still it's not working On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote: int maxdiff(int ); int maxdiff(int arr[]); The signatures of maxdiff function are not the same. On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote: this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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. -- with regards, Ashwini kumar singh ECE Final yr. MNNIT Allahabad Mobile: 7505519402 -- 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. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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] please explain
why is the value of sizeof(arr) in maxdiff function = 4 ? where as in main function it is 24 On Fri, Jul 1, 2011 at 11:05 AM, Vishal Thanki vishaltha...@gmail.comwrote: Rujin is right, here is the code which compiles.. vishal@ubuntu:~/progs/c\ 11:04:37 AM $ cat alg.c #includestdio.h int maxdiff(int arr[]); int main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); return 0; } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } vishal@ubuntu:~/progs/c\ 11:04:40 AM $ gcc alg.c -Wall On Fri, Jul 1, 2011 at 7:20 AM, varun pahwa varunpahwa2...@gmail.com wrote: actually u r passing arr,and receiving arr[] which actually receives the first element address. So arr will be a reference to first address. so its size will be 4 bytes and arr size will also be 4 bytes. so ur len contains only 1. so ur loop runs only once.i hope it clears. On Thu, Jun 30, 2011 at 4:49 PM, ashwini singh asingh...@gmail.com wrote: still it's not working On Thu, Jun 30, 2011 at 4:42 PM, Rujin Cao drizzle...@gmail.com wrote: int maxdiff(int ); int maxdiff(int arr[]); The signatures of maxdiff function are not the same. On Fri, Jul 1, 2011 at 6:53 AM, ashwini singh asingh...@gmail.com wrote: this code gives an error ([Warning] passing arg 1 of `maxdiff' makes integer from pointer without a cast) . Please explain the reasons. #includestdio.h #includeconio.h int maxdiff(int ); main() { int p,arr[]={2,4,1,6,23,4}; p=maxdiff(arr); printf(\n MAX Diff is \t %d,p); getch(); } int maxdiff(int arr[]) { int diff=0,len,i,j; unsigned p; len=sizeof(arr)/sizeof(arr[0]); for(i=0;ilen;i++) { for(j=i;jlen;j++) { p=arr[j]-arr[i]; if((p-diff)0) diff=p; } } return diff; } -- with regards, Ashwini kumar singh ECE Final yr. NIT 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. -- with regards, Ashwini kumar singh ECE Final yr. MNNIT Allahabad Mobile: 7505519402 -- 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. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- 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.