Re: [algogeeks] Re: HOW TO CALCULATE THA size of union
but when i compile it on Dev C it gives 24..whats the reason ? On Fri, Dec 7, 2012 at 7:19 AM, Don dondod...@gmail.com wrote: The actual size is system dependent because the language doesn't specify the size of int or long int. I'll assuming the common convention that sizeof(int)=4 and sizeof(long int)=8. The size of a union is the size of the largest element in the union. So sizeof(D) = 5*sizeof(int)=20 C and B will be the same, because there is nothing bigger in any of them. sizeof(A) will be 40 which is the size of an array of eight long ints. Don On Dec 7, 5:42 am, zerobyzero narayan.shiv...@gmail.com wrote: what will be the size of union A ,B,C and D. also please explain the logic. * union A{* * long int y[5];* * union B{* *double g;* *union C{* * int k;* * union D{* *char ch;* *int x[5];* * }s;* *}a;* * }b;* *}*p;* -- -- Shiv Narayan Sharma Jt. Secretary CSI-DTU +919971228389 www.jugadengg.com --
[algogeeks] Re: Snapdeal placement proceedure
hey how was your snapdeal exam you also please give some details ... On Tuesday, 28 August 2012 22:26:48 UTC+5:30, [we]fork wrote: -- Forwarded message -- From: sachin singh sach...@gmail.com javascript: Date: Tue, Aug 28, 2012 at 10:23 PM Subject: Snapdeal placement proceedure To: algo...@googlegroups.com javascript: Can anyone tell about the recruitment process of snapdeal? I mean how to prepare for the written test?What kind of written test it would be? What are they asking in interview? And some pointers on what skills they are basically looking at when they come to hire at colleges -- 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/-/nJTLqRxkQNQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: given col id, print col name in excel
yes actually we have to print a,b,c..z instead of nos , so for that i have stored nos in character array so only characters will be printed not nos On Sat, Aug 11, 2012 at 2:18 AM, yq Zhang zhangyunq...@gmail.com wrote: @shiv, your code is correct go compute the base 26 number. However, this question is not base 26 number obviously. On Wed, Aug 8, 2012 at 4:46 AM, shiv narayan narayan.shiv...@gmail.comwrote: this is similar to conversion of no in base 26.( where digits are a,b,c,d...z) just think it like decimal to binary conversion here base is instead 26. char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n/=2; } while(n) ; for(int i=n-1;i=0;i--) coutCarr[a[i]]; correct me if i am wrong. On Wednesday, 8 August 2012 12:56:56 UTC+5:30, ashgoel wrote: Imagine a sequence like this: a, b, c...z, aa, ab, ac...zz, aaa, aab, aac aax, aaz, aba, abc... (Its same as excel column names). Given an integer (n), generate n-th string from the above sequence. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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/-/Z3kYiTZi_F8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Shiv Narayan Sharma Jt. Secretary CSI-DTU +919971228389 www.jugadengg.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.
[algogeeks] Re: AMAZON: given col id, print col name in excel
this is similar to conversion of no in base 26.( where digits are a,b,c,d...z) just think it like decimal to binary conversion here base is instead 26. char Carr[26]={a,b,c...z} i=0; int arr[]; do { arrr[i++]=n%26; n/=2; } while(n) ; for(int i=n-1;i=0;i--) coutCarr[a[i]]; correct me if i am wrong. On Wednesday, 8 August 2012 12:56:56 UTC+5:30, ashgoel wrote: Imagine a sequence like this: a, b, c...z, aa, ab, ac...zz, aaa, aab, aac aax, aaz, aba, abc... (Its same as excel column names). Given an integer (n), generate n-th string from the above sequence. Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 -- 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/-/Z3kYiTZi_F8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] : constructing fully binary tree
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: Given Preorder and postorder traversals of a tree. Device an algorithm to constuct a fully binary tree from these traversals. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/XkRghiAUWHEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] : constructing fully binary tree
Preorder and postorder do not uniquely define a binary tree. so question is vague . On Sunday, 15 July 2012 01:41:15 UTC+5:30, Navin Kumar wrote: Given Preorder and postorder traversals of a tree. Device an algorithm to constuct a fully binary tree from these traversals. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/xaHfTySoo58J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Most compatible people
check this out http://www.careercup.com/question?id=14182739 . On Friday, 6 July 2012 10:27:32 UTC+5:30, enchantress wrote: Given a list of people and music bands they like, two people are compatible if they have at least 2 bands in common. The compatibility of two people is directly proportional to the number of bands they like in common. Find the two most compatible people that is having maximum number of bands in common. Number of people and bands can be as large as 10k. -- 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/-/-HIhNBBZcx8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: C output
6/5=1, in integer division, how come you can think it as 2? On Tuesday, 3 July 2012 13:22:07 UTC+5:30, rahul sharma wrote: #includestdio.h #includeconio.h int main() { int i; i=5; i=++i/i++; printf(%d,i); getch(); } Why o/p is 1 and not 2?? what happened for post increment??? -- 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/-/oW8rNHRnxVAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Basics of Cloud Computing
could you please provide free E-copy ? On Saturday, 9 June 2012 22:00:52 UTC+5:30, Ravi wrote: Hi All, Hope you are all doing great. I am a cloud engineer and specialize in cloud computing development and architecting as well big data analysis. Check out my blog for my views @ http://www.cloudcer.com I have recently published my first book. Its' based on cloud computing basics for the beginners. It covers the various aspects of cloud computing and virtualization and services provided by all the major cloud providers in all the service models like IaaS, PaaS SaaS. You can find the the book here: http://www.amazon.com/dp/B0083TC47C Be Well, Ravi Shankar -- 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/-/ULRFovABFEAJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Can anyone plz explain how we get this output
although we know this is compiler dependent , but still such questions are very frequent in some local competitions and can be found in some old books too. is it possible to have such questions in any company placement paper or interview ? On Thursday, 14 June 2012 11:41:04 UTC+5:30, Ajesh js wrote: main() { int a=10,b=5; printf(%d %d %d\n,a++,a,++a); printf(%d %d %d\n,++b,b,b++); } output 11 12 12 7 7 5 -- 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/-/L_rlqCezgtQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: No of tri-angles
this is the running code to find no of triangles using brute force technique logic: in a triangle having sides a,b,c; then a+bc(if c is greatest side) correct me if i am wrong. #includeiostream #includeconio.h using namespace std; int max(int a,int b,int c) { return ((ab?a:b)c?(ab?a:b):c); } int main() { int n,a[120],t,p,q; cint; while(t--) { cinn; for(int i=0;in;i++) cina[i]; int i,j,no_of_triangles=0,sum=0,largest_edge; for(i=0;in-2;i++) { for(j=i+2;jn;j++) { sum=a[i]+a[i+1]+a[j]; largest_edge=max(a[i],a[i+1],a[j]); if(sum-largest_edgelargest_edge) { no_of_triangles++; couta[i] a[i+1] a[j]\n;} } } coutno_of_trianglesendl; } getch(); return 0; } On Wednesday, 13 June 2012 22:18:01 UTC+5:30, payel roy wrote: Let's say there are N sides are given. Length of them are like 1,2,3,4,5,N. How do you determine how many tri-angles can be made out of these N sides? -- 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/-/WizMjfsoizsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Directi Question
On Jun 16, 2:1@shubham couldnt understand following logic in you algo please explain when first k elemnts traversed then traverse again k elemnts of B and S[2*k-i]+=B[i])...again S[i-2*k]+=B[i][.so on till B is traversed completely. 6 am, Shubham Sandeep s.shubhamsand...@gmail.com wrote: wat constraints does dis bring in the question... Also the books are arranged in a certain order and this order must never be changed. does this imply --- a student gets only consecutivly numbered book if not then sort the array B in decreasing order in Onlogn take another array S of k elements traverse B(sorted) S[i]=B[i] when first k elemnts traversed then traverse again k elemnts of B and S[2*k-i]+=B[i])...again S[i-2*k]+=B[i][.so on till B is traversed completely.. On Sat, Jun 16, 2012 at 2:22 AM, Hemesh Singh hemesh.mn...@gmail.comwrote: At first look it appears to be a simple problem of discrete binary search. Take sum of b[i] as the upper_bound and 0 as the lower bound. Then apply a simple binary search for the number of pages that can be given to a student. Complexity : O(N log( sum( B ) ) ) On Thu, Jun 14, 2012 at 12:26 PM, algogeek dayanidhi.haris...@gmail.comwrote: In a library there are N books with the number of pages in i th book given by bi . These books are to be distributed among K students such that the difference between the largest sum of pages in the books assigned to any student and the smallest sum of number of pages in the books assigned to any student is minimum for the given input. Also the books are arranged in a certain order and this order must never be changed. For eg: suppose B[ ] contains the number of pages in each book. then N=6 K=3 B={3,7,8,2,6,4} then the output will be 0 as we can give book 1 and 2 to student 1 and book 3 and 4 to student 2 and the remaining to student 3. That makes 10 pages for student 1 10 for 2 and 10 for 3 and thus the difference is 0 similarly if B={3,6,8,2,6,4} then the minimum difference will be 1 . -- 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/-/JjKITS_gN9UJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Hemesh singh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: No of tri-angles
@anmol my algo will work even if nos are not in ascending order .correct me if i am wrong. On Jun 15, 7:45 am, Amol Sharma amolsharm...@gmail.com wrote: sry ignore the last comment for i wanted to say - your algo will work only when the numbers given are consecutive. -- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://www.simplyamol.blogspot.com/http://facebook.com/amolsharma99 On Fri, Jun 15, 2012 at 8:06 PM, Amol Sharma amolsharm...@gmail.com wrote: @enchantress : your algo will work only when the number given are positive. -- Amol Sharma Final Year Student Computer Science and Engineering MNNIT Allahabad http://gplus.to/amolsharma99 http://twitter.com/amolsharma99http://in.linkedin.com/pub/amol-sharma/21/79b/507http://www.simplyamol.blogspot.com/ On Fri, Jun 15, 2012 at 7:01 PM, shiv narayan narayan.shiv...@gmail.comwrote: this is the running code to find no of triangles using brute force technique logic: in a triangle having sides a,b,c; then a+bc(if c is greatest side) correct me if i am wrong. #includeiostream #includeconio.h using namespace std; int max(int a,int b,int c) { return ((ab?a:b)c?(ab?a:b):c); } int main() { int n,a[120],t,p,q; cint; while(t--) { cinn; for(int i=0;in;i++) cina[i]; int i,j,no_of_triangles=0,sum=0,largest_edge; for(i=0;in-2;i++) { for(j=i+2;jn;j++) { sum=a[i]+a[i+1]+a[j]; largest_edge=max(a[i],a[i+1],a[j]); if(sum-largest_edgelargest_edge) { no_of_triangles++; couta[i] a[i+1] a[j]\n;} } } coutno_of_trianglesendl; } getch(); return 0; } On Wednesday, 13 June 2012 22:18:01 UTC+5:30, payel roy wrote: Let's say there are N sides are given. Length of them are like 1,2,3,4,5,N. How do you determine how many tri-angles can be made out of these N sides? -- 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/-/WizMjfsoizsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Microsoft Interview Question
@ayush goel couldnt really understand your algo , can you please explain little bit more . On Wednesday, 13 June 2012 21:49:49 UTC+5:30, Krishna Kishore wrote: Given a array of integers both positive and negative and you need to shift positive numbers to one side and negative numbers to other side with the order intact. ex. {-1,5,3,-8,4,-6,9} to {-1,-8,-6,5,3,4,9}. This should be done in O(n). -- 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/-/5i2bW0t0pgQJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 problem
will be better if you post on spoj forums.!! On Wednesday, 13 June 2012 01:40:36 UTC+5:30, gaurav yadav wrote: plz nyone explain how to approach this problem.. http://www.spoj.pl/problems/XORROUND/ -- 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/-/lvClpFbMOwgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Sorting in O(n)
@jeevitesh yeah that may be right but it requires extra space as lot of space will be wasted... On May 5, 1:44 pm, Jeevitesh jeeviteshshekha...@gmail.com wrote: Hi all, I am new to this group. My last post was deleted i do not know the reason behind it. I will explain my logic here:- as the range is 1 to n^2 we have a input array like input[n^2]. We can take a auxillary array of size n^2 like aux[n^2]. Scan the input array. For each input input[i] increment by one corresponding aux[input[i]]. After this just iterate through the aux array printing the index aux[i] times. This way we can sort it in O(n) time. On Sat, May 5, 2012 at 2:02 PM, saurabh singh saurab...@gmail.com wrote: After giving some thought,I think even radix sort may not be sufficient. Complexity of radix sort is O(k*n) where k is the number of buckets required to sort the given range. The number of buckets is proportional to the number of bits required to represent the *maximum number in the given range.*For our case the maximum number is O(n^2).Hence *the number of buckets required would be proportional to log(n^2) in the worst case.* Hence the worst case complexity for the given constraints using radix sort would be *O(n*(log n^2)) = O(n*logn).* This is no better than comparision sort.A slight optimization that we can make is to use a higher base which would reduce the number of buckets required but would add the cost of converting each number into the higher base. Somehow I am getting convinced worst case O(n) algorithm may not be possible.Working on the mathematical proof. Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, May 5, 2012 at 8:37 AM, saurabh singh saurab...@gmail.com wrote: @cegprakash They are n numbers lying in the range 1 to n^2.Not necessarily sorted. eg 3 4 1 2 5 8 (6 numbers satisfying the conditions given in the problem) Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, May 5, 2012 at 5:17 AM, Prakash D cegprak...@gmail.com wrote: The range 1 to n^2 is already sorted On Sat, May 5, 2012 at 12:17 AM, Algobiz deepak.arulkan...@gmail.com wrote: How to sort n numbers in the range of 1 to n^2 in O(n).. Any ideas? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/PGgMdaIbGIsJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *Thanks, Jeevitesh Shekhar Singh.* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: check Similar array
can't be use squares of no's as said by rahul patil as said in previous comment?? On Jan 4, 10:57 am, atul anand atul.87fri...@gmail.com wrote: @sharad : after checking the link provided by u...it seem like complexity will be O(n^2) { not sure } + saurabh point is also valid. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] puzzle
Assume that you have just heard of a scandal and you are the first one to know. You pass it on to four person in a matter of 30 minutes. Each of these four in turn passes it to four other persons in the next 30 minutes and so on. How long it will take for everybody in the World to get to know the scandal? Assume that nobody hears it more than once and the population of the World is approximately 5.6 billions. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 online test
what is answer to In how many ways 3 identical coins can be placed in 5x5 grid so that no two coin come in same row and same column ?? according to me it should be 25*16*9 . On Sep 24, 2:19 am, Deoki Nandan deok...@gmail.com wrote: 1)write code to find first non repeating character in given string 2)write code for image of binary tree 3)swap adjacent nodes of given linked list using one pointer 4)find pair of number in given array whose sum is given 5)write BST(Binary Search Tree) into file and read from file there were 25 MCQ questions as well like 1)In how many ways 3 identical coins can be placed in 5x5 grid so that no two coin come in same row and same column 2)there is an array of length n having numbers from 1-10 . what is the probability to choose a number and chosen number is 10 3)one question on average waiting time of preemptive SJF scheduling algorithm 4)what will happen of child process if parent is killed 5)print value of present directory using UNIX command (my ans is $pwd | echo )correct me if I'm wrong other I don't remember On 23 September 2011 17:39, siddharth srivastava akssps...@gmail.comwrote: Hi On 23 September 2011 17:29, raju nikutel...@gmail.com wrote: hi all, can anyone pls share the questions amazon has been asking in online written tests. Search the archives This has been answered many times in the recent days. Best of Luck thanks raju -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Siddharth Srivastava -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Deoki Nandan Vishwakarma * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Max possible numbers in incremental order
i think this can be solved by dynamic programming. this is very similar to the knapsack problem. 1. We have to maximize profit by increasing the length of array. 2. principle of optimality also holds here. considering the points solution ca be visualized easily. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] knight's tour - variant
what is the starting position of knight. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Goldman sachs
hi, can anyone tell their experience of intern questions. and how to prepare for essay. On Aug 3, 5:02 pm, Ankit Minglani ankit.mingl...@gmail.com wrote: heyy thanks alot to you people .. it was of so much help :) On Wed, Aug 3, 2011 at 2:49 AM, Kunal Patil kp101...@gmail.com wrote: I agree with Ved that Apti of GS is really really tough and technical is relatively easy..They ask CAT (Quant) like questions and you have to solve them in little time too...Also there will be sectional cut-off for this written test. So dont be afraid if you can solve only 10-15 questions from quantitative apti..Just make sure you attempt as much questions from both the sections as possible. Essay will also be there, subject of which will be provided in last 10 mins of your apti. In Interview, they ask C++ and DBMS questions mostly.. On Wed, Aug 3, 2011 at 2:39 PM, Ved vedgar...@gmail.com wrote: Questions were from C language lik Pointers and wat will b the output of the code , Errors etc. Clearing written test is not that tough u shud manage time and solve technical which will b 10 ques first den try aptitude .. All the Best On Aug 3, 12:10 am, arvind kumar arvindk...@gmail.com wrote: i mean..the technical written round. On Wed, Aug 3, 2011 at 12:37 AM, arvind kumar arvindk...@gmail.com wrote: Hi thanks a lot..can u pls temme wat wer the main areas(and questions if possible) covered in the technical round? Regards Arvind On Wed, Aug 3, 2011 at 12:35 AM, Ved Garbha vedgar...@gmail.com wrote: Goldman Sachs : The aptitude+technical together(written test ) will b of 45 min .. Apti will b tough but technical wil b C damn easy . followed by GD , and after dat two technical and HR round On Tue, Aug 2, 2011 at 9:54 PM, arvind kumar arvindk...@gmail.com wrote: Hi there Goldman sachs is comin to our campus!!anyone has any idea about their interviews(technical),etc..? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Ved Garbha* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- The more you sweat in the field, the less you bleed in war. Ankit Minglani NITK Surathkal -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: probablity
according to me it is 1/3 read the line carefully What is the probability that the next pen from the same packet will also be a blue one? since it is said the first pen was blue and second pen must also be blue. for it to happen 1st packet contaning all blue pen should be selected whose probablity of selection is 1/3 On Aug 5, 9:06 pm, nishaanth nishaant...@gmail.com wrote: Bayes theorem... Approach : P(pen from packet 1 | Blue) =2/3 (from Bayes rule) P(pen from packet 2 | Blue) =1/3 Req prob = 2/3 + 1/3 . 1/2 =5/6 On Fri, Aug 5, 2011 at 6:02 PM, abhishek iyer abhishekr.iye...@gmail.comwrote: @Nishant.. Can u please explain ur approach.. I think its as per mentioned above 1/2... On 5 Aug 2011 21:30, nishaanth nishaant...@gmail.com wrote: 5/6 On Fri, Aug 5, 2011 at 5:55 PM, Rahul Jain rahuljai...@gmail.com wrote: i agree with puneet. 1/2 On Fri, Aug 5, 2011 at 9:18 PM, Puneet Goyal puneetgoya...@gmail.com wrote: 1/2 you got the blue pen so it is for sure that is one of the first two packets, so you are left with a black pen and a blue pen and you have to find the probability of finding a blue pen among them On Fri, Aug 5, 2011 at 9:14 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: I was given 3 packets, with 2 pens each. 1st Packet has 2 blue pens. 2nd Packet has 1 blue pen,1 black pen. 3rd Packet has 2 black pens. I took any one packet and pulled out one pen. It turned out to be a blue one. What is the probability that the next pen from the same packet will also be a blue one? -- 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. -- --- Puneet Goyal Student of B. Tech. III Year (Software Engineering) Delhi Technological University, 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] help on string manipulation bit manipulation
i have seen plenty of questions on string manipulation and bits operations asked in various comcanies exams. any one give me some good links where i can find some really good tutorials on string manipulation. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: difference between the two
according to me 2nd structure must also have 16 bit size for 64 bit architecture as padding must also take place there also. On Aug 6, 4:10 am, Shashank Jain shashan...@gmail.com wrote: i dont understand the diff btw dem, could u plz elaborate? Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Sat, Aug 6, 2011 at 12:32 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: in case of 64 bit, size of second structure will also be 16 not 8 On Fri, Aug 5, 2011 at 11:40 PM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: I think voth are just same.. On Fri, Aug 5, 2011 at 10:57 AM, priya v pria@gmail.com wrote: in case of 64 bit machine y doesn't padding happen in the 2nd structure? On Fri, Aug 5, 2011 at 11:21 PM, hary rathor harry.rat...@gmail.comwrote: no ,if u r using 32 bit machine . that will use 4 byte pointer size , but in 64 machine that enforce to be size of 8 . where padding will take int your given first structure so for 32 bit- size will 8 8 for both structure for 64 bit - size will 16 and 12 respectively cause of 4 bit padding in one structure hence 2nd structure is good for use -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- *UTKARSH SRIVASTAV CSE-3 B-Tech 2nd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.
[algogeeks] Re: array
yes we can. On Aug 3, 10:08 pm, Arshad Alam alam3...@gmail.com wrote: can we insert 16 elements of one dimension array in 4*4 of double dimension 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.
[algogeeks] plz explain
Mike has $20 more than Todd. How much does each have given that combined they have $21 between them. You can't use fractions in the answer. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Novell - Puzzle
solutions for cow questions: if we consider first cow would she calf at age 2 then first new cow would come at age two. at end of 2nd year: 1st would give new cow: at end of 3rd year:1st cow would another new cow at end of 4th year :1st cow will give new cow and the cow born at end of 2nd year would give another cow at 5th year: :now of new cows=cow born by(1st+2nd year+3rd year) - - - - if you try it this way then you would be able to understad that it would be a reverse fibinacci series( try to analyse by last cow produced by 1st cow) total no of cows would be: 1+1+2+3+5+8+13+21+34+55+89=(sum of first 11 terms of fibinacci series) 232 correct me if i am wrong. On Jul 29, 11:15 am, Reynald reynaldsus...@gmail.com wrote: If a cow produces its first she-calf at age two years and after that produces another single she-calf every year, how many she-calves are there after 12 years? assuming none die. and a similar one, asked to another guy, Suppose a newly-born pair of rabbits, one male, one female, are put in a field. Rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits. Suppose that our rabbits never die and that the female always produces one new pair (one male, one female) every month from the second month on. How many pairs will there be in one year? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: wht is d logic behind this
this is very popular interview question i also want solution. On Jul 29, 11:19 am, jagrati verma jagrativermamn...@gmail.com wrote: an array containing +ve and -ve integers.find sub array with the largest sum -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: binary search tree question!!!!
would it work temp=root; for(int i=0;ik;i++) { temp=temp-left; } On Jul 29, 10:48 am, sunny agrawal sunny816.i...@gmail.com wrote: Node* x = TREE_MINIMUM(root); for(int i = 0; i k-1; i++){ x = TREE-SUCCESSOR(x);} return x; On Fri, Jul 29, 2011 at 11:08 AM, noobcoder ase.as...@gmail.com wrote: Iterative inorder of tree till you have traversed k elements. Last element is the kth smallest. On Jul 29, 10:10 am, AMAN AGARWAL mnnit.a...@gmail.com wrote: Please tell the solution of this question Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can’t pass the value k to any function also -- AMAN AGARWAL Success is not final, Failure is not fatal: It is the courage to continue that counts! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.
[algogeeks] Re: Novell - Puzzle
i think for rat pair answer should be same as cow..correct me if i am wrong On Jul 29, 1:10 pm, sunny agrawal sunny816.i...@gmail.com wrote: No ans will be sum of all final fib. number is the no of she-calves of age 0 second last is number is she-calves of age 1 ...and so on so answer is sum of all On Fri, Jul 29, 2011 at 1:09 PM, Reynald Suz reynaldsus...@gmail.comwrote: Shivnarayan, why should we add all Fibonacci number? Since 1+1 both digits represent the same cow. I think the last Fibonacci is the answer. I'm sorry if I'm wrong. On Fri, Jul 29, 2011 at 12:53 PM, Hemalatha hemalatha.amru...@googlemail.com wrote: @Shivnarayan As per the analysis from the number of cows produced from the she-calves of the 1st cow, I get the foll numbers: 1+2+4+7+11+16+22+29+38+48+59+1(MainCow) = 238. Correct me If am wrong. Regards Hemalatha On Fri, Jul 29, 2011 at 11:45 AM, Reynald reynaldsus...@gmail.comwrote: If a cow produces its first she-calf at age two years and after that produces another single she-calf every year, how many she-calves are there after 12 years? assuming none die. and a similar one, asked to another guy, Suppose a newly-born pair of rabbits, one male, one female, are put in a field. Rabbits are able to mate at the age of one month so that at the end of its second month a female can produce another pair of rabbits. Suppose that our rabbits never die and that the female always produces one new pair (one male, one female) every month from the second month on. How many pairs will there be in one year? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Reynald Reni Masters in Software Engineering CIT - India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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.
[algogeeks] Re: GATE C-Question
value of k in any if case would be k=m+n-1, now analyse both of the options i)jm, k=n+j-1, and a[n-1]b[j] if i=n ii)in,k=m+i-1, and b[m-`1]=a[i] if j=m for 1st case k=n+j-1 and jm so km+n-1 which is false for 2nd case k=m+i-1 and in so km+n-1 which is also false so both statement are false ans:c correct me if i am wrong On Jul 26, 8:42 pm, rajeev bharshetty rajeevr...@gmail.com wrote: C ) On Tue, Jul 26, 2011 at 9:02 PM, Vijay Khandar vijaykhand...@gmail.comwrote: Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n+m] be an other integer array. void XYZ(int a[],int b[], int c[]) { int i,j,k; i=j=k=0; while((in)(jm)) { if (a[i]b[j]) c[k++]=a[i++]; else c[k++]=b[j++]; } Which of the following condition(s) hold(s) after the termination of the while loop? i)jm, k=n+j-1, and a[n-1]b[j] if i=n ii)in,k=m+i-1, and b[m-`1]=a[i] if j=m A)only i B)only ii C)either i or ii but not both D)neither i nor ii Can I have to take any example -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards Rajeev N B http://www.opensourcemania.co.cc -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] clock synchronisation puzzle..
There is a clock at the bottom of the hill and a clock at the top of the hill. The clock at the bottom of the hill works fine but the clock at the top doesn't. How will you synchronize the two clocks. Obviously, you can,t carry either of the clocks up or down the hill! And you have a horse to help you transport yourself. And, the time required for going up the hill is not equal to the time required to go down the hill. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] puzzle
There is a temple, whose premises have a garden and a pond. It has 4 idols, each of Ram, Shiv, Vishnu and Durga. The priest plucks x flowers from the garden and places them in the pond. The number of flowers doubles up, and he picks y flowers out of them and goes to offer it to Lord Ram. By the time he reaches to the pond, he finds the remaining flowers also have doubled up in the meantime, so he again picks up y from the pond and goes to Lord Shiv.This process is repeated till all the Gods have y flowers offered to them, such that in the end no flower is left in the pond. Find x and y. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] what would be the output of following code??
Printf(“%d”,printf(“%d %d”,2,2) printf(“%d %d ”, 2, 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.
[algogeeks] Re: Printf ...
according to me it processing is done from righ to left .first right most a would be incremented and then from righ to left for first question answer should be 8+7+6=21 and for 2nd it should be (8)+(7)*10+(6)*100=678 On Jul 15, 1:15 pm, Antony Kotre antonyko...@gmail.com wrote: can any tell and explain the output of following code #includestdio.h main() { int a =5, b=5; int res1=(++a)+(++a)+(++a); int res2=(++b)+(++b)*10+(++b)*100; printf(%d\n%d\n,res1,res2); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: plz explain if the solution is possible with less than 2n-3 comparisons??
@sunny iam asking minimum no of comaparisons. On Jul 14, 10:22 am, sunny agrawal sunny816.i...@gmail.com wrote: n+lgn-2 no of comparisions will do On Thu, Jul 14, 2011 at 10:19 AM, shiv narayan narayan.shiv...@gmail.comwrote: Describe an optimal algorithm to find the second minimum number in an array of numbers. What is the exact number of comparisons required in the worst case? Note that they didn't ask the order in Big-Oh notation. They wanted the exact number of comparisons. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.
[algogeeks] puzzle-plz explain stepwise
A car is traveling at a uniform speed.The driver sees a milestone showing a 2-digit number. After traveling for an hour the driver sees another milestone with the same digits in reverse order.After another hour the driver sees another milestone containing the same two digits. What is the average speed of the driver? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz explain if the solution is possible with less than 2n-3 comparisons??
Describe an optimal algorithm to find the second minimum number in an array of numbers. What is the exact number of comparisons required in the worst case? Note that they didn't ask the order in Big-Oh notation. They wanted the exact number of comparisons. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: output
cant i invoke both simultaneously?? if i try to make two objects like x const a; x a; then it gives error..can u explain plz. On Jul 12, 9:55 pm, Sandeep Jain sandeep6...@gmail.com wrote: *const* in C++ is not exactly same as *final* in java. SO unlike java adding the keyword const to a function does not affect overriding. Infact, adding in C++ const functions == that they will not modify any member of the class. non-const functions cannot be invoked by const objects. Try making object 'a' as const i.e. const x a; and then invoke f(), it should invoke the correct version. Note that C++ allows function overloading based on const-ness. Refer (Const function section)http://www.cprogramming.com/tutorial/const_correctness.html Also, subscript operators generally come in pairs, Referhttp://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-1...http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12 Regards, Sandeep Jain On Tue, Jul 12, 2011 at 10:09 PM, dheeraj tyagi dheeraj2...@gmail.comwrote: const means that it cannot be overloaded..i think due to that this is happening. On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.comwrote: #includeiostream using namespace std; class x{ public: x() {} int func() const{ coutit is const function\n; } int func() { coutit is simple functin\n; } }; int main() { x a; a.func(); return 0; } why cann't it take const function? explain it -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With regards Dheeraj Tyagi 8197218001 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: NVIDIA Q
it would be size of int. On Jul 7, 10:34 am, oppilas . jatka.oppimi...@gmail.com wrote: Ok. So for differentiating objects, we have size 1. What will be size of following class:- class A{ int z;}; How does different objects gets differentiated in above case? On Wed, Jul 6, 2011 at 2:24 PM, durgaprasad k durga...@gmail.com wrote: The size will be 1 byte as there is nothing to look into the object. And it is 1 instead of zero because two objects of the class will have different addresses by assigning each object size 1. Regards, Durga On Wed, Jul 6, 2011 at 2:11 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: What is the size of an object of a class with no members in it?? -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] puzzle
* You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: puzzle
whr s(S+1)/2 must be nearly equal to 100 can uexplain.. On Jul 6, 10:48 pm, TIRU REDDY tiru...@gmail.com wrote: s(s+1)/2 must be close to 100. The best possible number is 14. try from 14th floor. next from 14+13th floor. next from 14+13+12th floor. Worest case number of attempts = 14. Best Regards, T V Thirumala Reddy Engineer, Qualcomm India Private Ltd. 1540C30, 15th Floor, Building #9, Mindspace, Hitech city, Madhapur, Hyderabad-81. On Wed, Jul 6, 2011 at 11:14 PM, Sriganesh Krishnan 2448...@gmail.comwrote: @tiru and @aseem: explanation pls...! On Wed, Jul 6, 2011 at 11:11 PM, TIRU REDDY tiru...@gmail.com wrote: 14 On 6 Jul 2011 22:35, shiv narayan narayan.shiv...@gmail.com wrote: * You are given 2 eggs. * You have access to a 100-storey building. * Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor.Both eggs are identical. * You need to figure out the highest floor of a 100-storey building an egg can be dropped without breaking. * Now the question is how many drops you need to make. You are allowed to break 2 eggs in the process -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: Puzzle
speed of river=(distance traveled by object in it) / total time it took to travel here hat has traveled a distance of 1 KM and it has taken =5mn+5 min=10 min=10min/60=1/6 hrs; so speed = 1/(1/6)=6km/hr On Jul 6, 9:28 pm, Tushar Bindal tushicom...@gmail.com wrote: Let speed of boat be x miles/hr Let speed of river be s miles/hr First Method: Hat comes down 1 mile in 10 minutes. Hat comes with flow of river only. So its speed is equal to speed of river. In 60 minutes, it will travel 6 miles. thus, s = 6 miles/hr Second Method: Distance travelled upward by boat = 1 + (5/60)*(x-s) miles Distance travelled downward by boat = (5/60)*(x+s) miles Both are same, so 1 + (5/60)*(x-s) = (5/60)*(x+s) x gets cancelled, and we have s/6 = 1 s = 6 miles/hr Second method is just one possible method which nobody would like to follow. First one is easier and faster - win-win situation For a change the easier method is faster as well -- Tushar Bindal Computer Engineering Delhi College of Engineering Mob: +919818442705 E-Mail : tushicom...@gmail.com Website:www.jugadengg.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.
[algogeeks] Re: NVIDIA Q
hey i am getting size of empty struct 1. check my code #includeiostream #includeconio.h using namespace std; struct empty{}; int main() { empty e; int x=sizeof(e); coutx; getch(); return 0; } when i run this i get 1 as output On Jul 6, 10:16 pm, Ashish Modi ashishrmod...@gmail.com wrote: @piyush: No,one can declare the variable of empty struct and access its address via pointer. So, when you are accessing address via pointer means some memory is allocated for that variable. But *sizeof()* operator returns *zero*?? why??? On Wed, Jul 6, 2011 at 10:38 PM, T3rminal piyush@gmail.com wrote: @ashish Most probably because empty struct in C have nothing associated with it. They are as good as nothing. But empty classes in C++ can have member functions. These functions need to be associated with object, having a unique address, for that class. And unique address is not possible with class of size 0 as already explained above. -- 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/-/XP8yGGz2YbEJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Ashish Modi 9423721478 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] help to code
Write a program that accepts an input integer n, and calculates the number and sum of all the numbers between 1 and n (inclusive) that are NOT evenly divisible by ANY of the first 5 prime numbers (2,3,5,7,11). The program should print out a clearly labeled count and sum my code is : it is not giving correct result #include iostream #includeconio.h using namespace std; int main() { int userInteger = 0; cout Enter A Number endl; cin userInteger; // Ask For a number from the user if (userInteger 0) // Is the number valid? { int result = 0; int prime[5] = { 2, 3, 5, 7, 11 }; int a = 1, count = 0; while (a userInteger) // Looping to user's input { int b = 0; while (b 5) // Looping the prime numbers array { if (a % prime[b]) { result += a; // If Not evenly divisible by prime number at index 'b' count++; } b++; } a++; // Increment the counter } cout Numbers Not evenly divisible by 5 prime numbers: count endl; cout The Sum of numbers not evenly divisible by 5 prime numbers: result endl; } getch(); 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.
[algogeeks] Re: help to code
@ tushar as per your interpretation this looks coreect...but i am not saying to exclude all no's which are divisible by first 5 prime no ..question says to exclude those no which are evenly divisible by first 5 prime no.. On Jul 5, 10:47 pm, Tushar Bindal tushicom...@gmail.com wrote: If my interpretation is right, following should be the code. int main() { int userInteger = 0; cout Enter A Number endl; cin userInteger; // Ask For a number from the user if (userInteger 0) // Is the number valid? { int result = 0; int prime[5] = { 2, 3, 5, 7, 11 }; int a,b, count = 0; *for(a=1;a=userInteger;++a) // Looping to user's input { for(b=0;b 5;++b) // Looping the prime numbers array { if (a % prime[b] == 0) //if divisible by any number, just end it there break; } //break or end of loop will bring the control here if(b==5) //a was not divisible by any of the first 5 prime numbers { result+=a; ++count; }}* cout Numbers Not evenly divisible by 5 prime numbers: count endl; cout The Sum of numbers not evenly divisible by 5 prime numbers: result endl;} getch(); return 0; } --- - As per my solution, Test Cases: 1) userInteger = 20 count = 4 Numbers will be: 1, 13, 17, 19 result = 50 2) userInteger = 35 count = 7 Numbers will be: 1, 13, 17, 19, 23, 29, 31 result = 133 Even numbers can never be there in this list as they are all divisible by 2. Bfore 169, only prime numbers can be included. Hope my interpretation of your question was correct -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: help to code
@ tushar just one modification to you code would make the things correct.makin if (a % 2*prime[b] == 0) inspite of if (a % prime[b] == 0) would take care of even things hope i am correct.. thanx! for the reply On Jul 5, 10:47 pm, Tushar Bindal tushicom...@gmail.com wrote: If my interpretation is right, following should be the code. int main() { int userInteger = 0; cout Enter A Number endl; cin userInteger; // Ask For a number from the user if (userInteger 0) // Is the number valid? { int result = 0; int prime[5] = { 2, 3, 5, 7, 11 }; int a,b, count = 0; *for(a=1;a=userInteger;++a) // Looping to user's input { for(b=0;b 5;++b) // Looping the prime numbers array { if (a % prime[b] == 0) //if divisible by any number, just end it there break; } //break or end of loop will bring the control here if(b==5) //a was not divisible by any of the first 5 prime numbers { result+=a; ++count; }}* cout Numbers Not evenly divisible by 5 prime numbers: count endl; cout The Sum of numbers not evenly divisible by 5 prime numbers: result endl;} getch(); return 0; } --- - As per my solution, Test Cases: 1) userInteger = 20 count = 4 Numbers will be: 1, 13, 17, 19 result = 50 2) userInteger = 35 count = 7 Numbers will be: 1, 13, 17, 19, 23, 29, 31 result = 133 Even numbers can never be there in this list as they are all divisible by 2. Bfore 169, only prime numbers can be included. Hope my interpretation of your question was correct -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Some adobe interview questions.
@ashish thanx buddy nice solution On Jul 6, 7:20 am, Ashish Goel ashg...@gmail.com wrote: Q3 : 42101000 started with 7000 then changes this to 6010 51000100 to 42101000 to Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On Tue, Jul 5, 2011 at 11:54 AM, vikas mehta...@gmail.com wrote: These all were asked cumulatively in five interviews, one after another. Q1 given 2 string A ,B. write a code to find all character of A exists in B or not? Q2. A puzzle athttp://mathforum.org/library/drmath/view/56756.html Q3. Find a 8-digit number, where the first figure defines the count of zeros in this number, the second figure the count of numeral 1 in this number and so on Q4. write a recursive function to find a given string is palindrome or not? Q5. write a code to generate the parse tree like compilers do internally for any given expression e.g. a+(b+c*(e/f)+d)*g Q6. 3 reverse the string word by word e.g. My name is pradeep .. o/p shd be pradeep is name My ...intwer expecting a 1 traversal algo Q7. C++ (What are virtual functions) what happened if I do Base *d = new Derived(); and Derived *d = new Base(); is it error(in which statement) or not if yes what type of error? Q8. you have 6 coins of Indian denomination (a+b+c+d+e+f=115 paisa) ...if user ask for a change of 100,50,25,10,5 paisa then you r not able to give find the value of a,b,c,d,e,f.e.g. lets if user ask for a change of 25 paisa then you r not able to return (10+10+5) or (20+5) Q9. allocate 2D array dynamically with min no. of malloc calls. Q10. given unsorted array and a no. X ,find 2 no. whose sum is Xa[i]+a[j]=X ...do it in O(n) Q11. class A {}; A obj ; what is sizeof(obj)explain ANS Q12. Write a code of Merge sort on Linked list. Lets discuss them -- 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/-/FAVdr2McPqIJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: puzzle
can u please explain how is it 3? On Jun 26, 11:18 pm, D.N.Vishwakarma@IITR deok...@gmail.com wrote: 3 mice . On Sun, Jun 26, 2011 at 6:13 PM, ArPiT BhAtNaGaR arpitbhatnagarm...@gmail.com wrote: 3 On Mon, Jun 27, 2011 at 2:10 AM, amit the cool amitthecoo...@gmail.comwrote: There are 6 beer bottle nd one is poisoned. we have mice who will die within 14 hrs after drinkin poisned beer. In 24 hrs we have to find poisoned beer bottle. How many no of mice we require to find out poisoned bottle. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks Regards Arpit Bhatnagar (Computer Engineering) (MNIT JAIPUR) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Deoki Nandan Vishwakarma IITR MCA * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Stroustrup C++ BOOK
can you please give the link of the book or mail me at narayan.s...@gmail.com On Apr 24, 7:31 pm, D.N.Vishwakarma@IITR deok...@gmail.com wrote: I have shared this book with algo geek group please check in group On Sun, Apr 24, 2011 at 6:52 PM, hary rathor harry.rat...@gmail.com wrote: send link to me also harry.rat...@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. -- **With Regards Deoki Nandan Vishwakarma IITR MCA Mathematics Department* * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Good Maths Question
Hi, Here is a solution I have coded- http://codepad.org/bPOoakm3 Please let me know if you see any errors. *Logic for decreasing numbers-* Number of 'n' digit valid numbers (say 2), starting with digit 'k' (say 5); will be sum of number of 'n' digit valid numbers starting with 'k-1' and number of 'n-1' digit number starting with 'k' [not k-1 as 55 is a valid decreasing number.]. I have used the same thought process for increasing numbers. ~Shiv. P.S. To avoid using too much memory, I have used only two int[10] arrays. I keep overwriting them. And to know which array is being filled now, I am using even/odd criteria. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Good Maths Question
If the below link does not work- http://codepad.org/MDoQ8Kry ~Shiv. ** Hi, Here is a solution I have coded- http://codepad.org/bPOoakm3 Please let me know if you see any errors. *Logic for decreasing numbers-* Number of 'n' digit valid numbers (say 2), starting with digit 'k' (say 5); will be sum of number of 'n' digit valid numbers starting with 'k-1' and number of 'n-1' digit number starting with 'k' [not k-1 as 55 is a valid decreasing number.]. I have used the same thought process for increasing numbers. ~Shiv. P.S. To avoid using too much memory, I have used only two int[10] arrays. I keep overwriting them. And to know which array is being filled now, I am using even/odd criteria. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: program for evaluation of remainders
Hi, I agree with ankit sablok. And if we get the factorial of n in 1!, 2!, 3! Etc. Then we can find the number easily. In its complexity will be O(N) -Original Message- From: algogeeks@googlegroups.com [mailto:algoge...@googlegroups.com] On Behalf Of Dave Sent: Friday, December 10, 2010 8:10 PM To: Algorithm Geeks Subject: [algogeeks] Re: program for evaluation of remainders @Ankit: Why not just use the algorithm I proposed in http://groups.google.com/group/algogeeks/msg/2941ab071a39517c: x = 0; for( i = (n N ? n : N) ; i 0 ; --i ) x = (i * x + i) % n; Dave On Dec 10, 4:23 am, ankit sablok ankit4...@gmail.com wrote: @Dave we will use residues then i think the property of modulus 1!mod997 + 2!mod997 + 3!mod997 .. + 997!mod997 i just proposed the solution using congruences for the case nN can u generalize the problem using congruences if so then please post it thnanx in advance On Dec 9, 2:13 am, Dave dave_and_da...@juno.com wrote: @Ankit: So how does that work with, e.g., N = n = 997? I.e., what is the calculation? Dave On Dec 8, 11:33 am, ankit sablok ankit4...@gmail.com wrote: @ all the authors thanx for the suggestions actually wt i know about the problem is i think we can solve the problem mathematically if we know about congruences for instance if N=100 1! + 2! + . + 100! and n=12 we find that 4!mod24=0 hence the above equation reduces to the (1!+2!+3!)mod 12 =9 hence the answer is 9 so can anyone write a program for this logic On Dec 8, 6:19 pm, ankit sablok ankit4...@gmail.com wrote: Q) can anyboy find me the solution to this problem Given an integer N and an another integer n we have to write a program to find the remainder of the following problems (1! + 2! + 3! + 4! + . + N!)mod(n) N=100 n=1000; please help me write a program for this problem thanx in advance- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Brain Teaser
Several solutions are possible for it 518 2 736 4 Here we can swap the position of 5-7, 1-3 etc. On Thu, Nov 11, 2010 at 11:48 PM, jagannath prasad das jpdasi...@gmail.comwrote: 4 8 3 7 2 6 1 5 On Thu, Nov 11, 2010 at 5:57 PM, sunny agrawal sunny816.i...@gmail.comwrote: @rohit 4 5 are diagonally adjacent . On Thu, Nov 11, 2010 at 5:09 PM, Rohit Singhal rsinghal.it...@gmail.comwrote: 1 5 2 6 - - - - - - 3 7 4 8 On Thu, Nov 11, 2010 at 3:16 PM, Abhilasha jain mail2abhila...@gmail.com wrote: solution is 5 1 6 2 _ _ _ _ 7 3 8 4 On Thu, Nov 11, 2010 at 1:26 PM, Amod gam...@gmail.com wrote: We have a rectangle It is divided in eight parts by three vertical and one horizontal line so that there are 8 chambers. Now we have numbers from 1-8 to be filled in these chambers. Rule : No two consecutive numbers must be present either side to side or diagonal Invalid situation example Given 5 at position 2 then 4 cannot occur at any of the give position. 4 5 4 _ _ _ _ 4 4 4 _ _ _ _ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Rohit Singhal B.Tech. Part-IV, Department Of Electronics Engineering, Centre of Advanced Studies, Institute Of Technology, BHU -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With Regards, Shiv Shankar, -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Yahoo Interview Question for Software Engineer/Developer about Algorithms
i will choose BFS. As we just don't want to show a connection.. we want to show the shortest one. On Sat, Sep 18, 2010 at 4:12 PM, soundar soundha...@gmail.com wrote: Even if u are connected to that person via some another friend it'll show the shortest chain by which you are connected to that person..So DFS will be optimum i guessWhy do you think it wouldn't be optimum.? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Simple reVerse
I think Dave is trying to reverse the bit-order (in binary) reverse( 1110011 = 115) is 1100111 (= 103). On Sat, Sep 4, 2010 at 12:31 AM, albert theboss alberttheb...@gmail.comwrote: if input is 12345 then the output should be 54321 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Permutation of Array.
An interesting idea would be treat the inputs as strings and sort them. On Thu, Aug 19, 2010 at 4:01 AM, amit amitjaspal...@gmail.com wrote: Given an array of numbers. Calculate a permutation when the concatenate number is smallest. For instance, [55,31,312,33] is 312313355 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Maximum size binary search tree
Gopinath's solution can be extended by adding one more logic. Do in-order traversal, store it in an array or something. Keep resetting this data-structure if you hit a right leaf or a non-increasing number. Well we will need two such arrays, one for storing the current increasing sequence and other for the previous best. *These are my principle. If you don't like, i have others.* On Wed, Aug 11, 2010 at 1:44 PM, Divya Jain sweetdivya@gmail.comwrote: @ above ur soln ll fail in situation like 10 / \ 15 18 /\ / \ 22 7 17 77 the inorder is 22 15 7 10 17 18 77 so the longest increasing sequence is 7-77 but this is not a bst as 10 n 7 r nt connected On 24 June 2010 22:36, gopinath sikha gopisi...@gmail.com wrote: We can find the solution in O(n) where n is number of nodes. Do an in-order traversal of the binary tree. then scan through the numbers and find the list and find the longest(increasing or decreasing) sequence. That is the size of maximum size of BST in the given binary tree. On Wed, Jun 23, 2010 at 11:40 AM, Raj N rajn...@gmail.com wrote: Find the maximum size Binary search tree in a binary tree?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- -- If u doubt your believes,u believe ur doubts If u fail to practise,u practises failure Thanks and Regards GopiNath -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Find the duplicate
In constant space??? How? will you please elaborate? On Thu, Aug 5, 2010 at 9:29 PM, dinesh bansal bansal...@gmail.com wrote: If I understand the question correctly... there is an array of size n which has n/2 distinct elements and one element is repeated n/2 times. For e.g.: n = 4: 1 2 3 3 n = 61 2 3 4 4 4 n = 81 2 3 4 5 5 5 5 So now this problem can be reduced to finding the first duplicate element in the array because remaining other elements will be unique. I think this can be done in linear time. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] What is the time complexity of multiplying two n-digit numbers base b
O(log n). If u add in pairs. e.g. (5+5)=10. now add 10+10. On Sat, Jul 31, 2010 at 6:28 PM, sourav souravs...@gmail.com wrote: When you first learned to multiply numbers, you were told that x * y means adding x a total of y times, so 5 * 4 = 5+5+5+5 = 20. What is the time complexity of multiplying two n-digit numbers in base b using the repeated addition method, as a function of n and b. Assume that single-digit by single-digit addition or multiplication takes O(1) time. Show how you arrive at your answer. (Hint that was given : how big can y be as a function of n and b?) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: What is the time complexity of multiplying two n-digit numbers base b
What about this- = long multiply(long num, int n) { long bigSum=0; while(n=1) { int sum =num; int j; for(int i =2; i=n; i= i*2) { sum+=sum; j=i; } //for n = n -j; bigSum=bigSum+sum; }//while return bigSum; }//multiply() === It's *O(logn).* On Sun, Aug 1, 2010 at 8:54 AM, Apoorve Mohan apoorvemo...@gmail.comwrote: If suppose we want to Do N*K then we add N K-times or K N-times. hence the complexity should be O(N*K) On Sat, Jul 31, 2010 at 9:12 PM, Dave dave_and_da...@juno.com wrote: If by repeated addition method, you mean m + m + m + ... + m (where m occurs k times) for forming the product k*m, then the work of forming k*m where k and m are n digit numbers is O((k-1)*n). Using the elementary school algorithm, the work can be reduced to O(n^2). See http://en.wikipedia.org/wiki/Multiplication_algorithm for even faster algorithms. Dave On Jul 31, 7:58 am, sourav souravs...@gmail.com wrote: When you first learned to multiply numbers, you were told that x * y means adding x a total of y times, so 5 * 4 = 5+5+5+5 = 20. What is the time complexity of multiplying two n-digit numbers in base b using the repeated addition method, as a function of n and b. Assume that single-digit by single-digit addition or multiplication takes O(1) time. Show how you arrive at your answer. (Hint that was given : how big can y be as a function of n and b?) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: What is the time complexity of multiplying two n-digit numbers base b
An edgy case... On Sun, Aug 1, 2010 at 9:52 AM, Shiv ... shivsinha2...@gmail.com wrote: What about this- = long multiply(long num, int n) { long bigSum=0; while(n=1) { int sum =num; int j*=1*; //to avoid garbage @n=1. for(int i =2; i=n; i= i*2) { sum+=sum; j=i; } //for n = n -j; bigSum=bigSum+sum; }//while return bigSum; }//multiply() === It's *O(logn).* On Sun, Aug 1, 2010 at 8:54 AM, Apoorve Mohan apoorvemo...@gmail.comwrote: If suppose we want to Do N*K then we add N K-times or K N-times. hence the complexity should be O(N*K) On Sat, Jul 31, 2010 at 9:12 PM, Dave dave_and_da...@juno.com wrote: If by repeated addition method, you mean m + m + m + ... + m (where m occurs k times) for forming the product k*m, then the work of forming k*m where k and m are n digit numbers is O((k-1)*n). Using the elementary school algorithm, the work can be reduced to O(n^2). See http://en.wikipedia.org/wiki/Multiplication_algorithm for even faster algorithms. Dave On Jul 31, 7:58 am, sourav souravs...@gmail.com wrote: When you first learned to multiply numbers, you were told that x * y means adding x a total of y times, so 5 * 4 = 5+5+5+5 = 20. What is the time complexity of multiplying two n-digit numbers in base b using the repeated addition method, as a function of n and b. Assume that single-digit by single-digit addition or multiplication takes O(1) time. Show how you arrive at your answer. (Hint that was given : how big can y be as a function of n and b?) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
No it won't it will just reduce the height of tree to n/2 (from n). My algo- 1. Parse in triplets. For every 3 nodes make the second one parent of other two. Also, queue up such parents. 2. repeat step 1 till you have only 1 node left (root). But this may give a tree 'imbalanced at root. we may need to do some height re-balancing. -Thanks On Sun, Aug 1, 2010 at 9:26 AM, Manjunath Manohar manjunath.n...@gmail.comwrote: find the middle of the list and make it as the root..thus i this maner u will get a balanced tree.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: ALGORITHM
I think we can assume a perfect hashing to exist. [Please correct me if I am wrong] Implementing one, is a different issue. :)) Other than hashing, we can use BST or Heap. ~ O(klog(n)) On Thu, Jul 29, 2010 at 1:07 PM, sourav souravs...@gmail.com wrote: @Shiv Collision is itself a wel known issue in hashing and much need to be done to avoid collision. When you say your appraoch is hash the numbers, how do u make sure without knowing the nature of the numbers that you can hash them without bringing ing collision of inequal items of the array? On Jul 28, 11:38 pm, Shiv ... shivsinha2...@gmail.com wrote: What if the number are not consecutive? My approach- Put the numbers in a hash till a collision occurs. On Wed, Jul 28, 2010 at 9:21 PM, Apoorve Mohan apoorvemo...@gmail.com wrote: Solution : 1. Find Xor of numbers from 1 to n-1. 2. Find Xor of the numbers present in the array. 3. Xor the results from step 1 and 2 you will get the repeated number. On Wed, Jul 28, 2010 at 8:46 PM, akshay akshayrastogi2...@gmail.com wrote: An array of unsorted numbers n is given with one no.repeated once ie n-1 distinct nos to find duplicate no. in o(n) complexity -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: a google question
I have formulated a solution, not strictly of O(n), but I guess it's close. === 1. for(int k=0;kn;k++) { 2 get_max_of_temp_array(maxVal,visited_index_of_A/*Va[i]*/,visited_index_of_b/*Vb[j]*/); 3. Print_Max_of( a[va[i]+1] +b[Vb[j]] , a[va[i]] + b[vb[j+1]] ,maxVal) 4 insert_other_two_of_the_triplet(); 5(i,j)=(index_of_maximum_value printed_above); 6 update_Va__Vb_accordingly(); } insert... on line 6 is to insert the (set-)element in an insertion-sorted array. But still not O(n). :( On Wed, Jul 28, 2010 at 4:11 PM, manish bhatia mb_mani...@yahoo.com wrote: I guess your solution would also be proved incorrect with the following, Numbers in bold are the two arrays. 125122 120 110 104 103 102 101 100 99 9897 130255 252 250 240 234 233 232 231 230 229 228 227 128253 250 248 238 232 231 230 229 228 227 226 225 126251 248 246 236 230 229 228 227 226 225 224 223 125250 247 245 235 229 228 227 226 225 224 223 222 105230 227 225 215 209 208 207 206 205 204 203 202 104229 226 224 214 208 207 206 205 204 203 202 201 103228 225 223 213 207 206 205 204 203 202 201 200 102227 224 222 212 206 205 204 203 202 201 200 199 101226 223 221 211 205 204 203 202 201 200 199 198 100225 222 220 210 204 203 202 201 200 199 198 197 99 224 221 219 209 203 202 201 200 199 198 197 196 98 224 221 219 209 203 202 201 200 199 198 197 196 manish... -- *From:* Varun Nagpal varun.nagp...@gmail.com *To:* Algorithm Geeks algogeeks@googlegroups.com *Sent:* Mon, 3 May, 2010 12:26:24 PM *Subject:* Re: [algogeeks] Re: a google question Guys no one commented on my solution? Any takes on it? Anyways, below is my solution (in pseudo code) Pre-condition: A and B are sequences of equal length and sorted in descending order Input: Sequences A[1..N] and B[1..N] of equal lengths(N) Ouput: Sequence C[1..N] containing sorted sum of ordered pairs from cartesian products of A, B or B,A Sort(A,B) { k = 1 N = length(A) = length(B) C[1..2*N] = []// Empty array cart_prod_order = 0 // 0 - AxB, 1 - BxA. 0 is default // Complexity : O(N) while(k != N+1) { if (A[k] B [k]) { cart_prod_order = 1 break } else { k = k + 1 } } // Choose the correct order of Cartesian product sum // Complexity: Theta(2N) = O(N) if (cart_prod_order == 1) { // take cartesian product of B and A, storing the sum of ordered pair (b,a) in each element of C C[1..2N] = B[1..2] x A[1..N] } else { // take cartesian product of A and B, storing the sum of ordered pair (a,b) in each element of C C[1..2N] = A[1..2] x B[1..N] } // Merge // C[1..N] and C[N+1..2N] are already sorted in descending order // Complexity: Theta(N) C[1..2N] = Merge(C[1..N],C[N+1..2N]) return C[1..N] } Merge(C,D) { i=1,j=1,k=1 E = [] while(i=length(C) OR j=length(D)) { if(i=length(C) AND (jlength(D) OR C[i]D[j])) { E[k] = C[i] i = i + 1 } else { E[k] = D[j] j = j + 1 } k = k + 1 } return E; } On Fri, Apr 30, 2010 at 7:50 PM, banu varun.nagp...@gmail.com wrote: Nice question: 1. |A| = |B| i.e I assume their cardinality is equal 2. A(n) = { a1, a2 a3, ...aN} such that a1=a2=a3...=aN 3. B(n) = { b1, b2 b3, ...bN} such that b1=b2=b3...=bN 4. S(n^2) = A x B = {(a1,b1), (a1,b2)(a1,bN), (a2,b1), (a2,b2)(a2,bN), (aN,b1), (aN,b2)(aN,bN)} assuming we have added in a way such that we find a pair ai bi, for some i in 1..N such that a(i-1) = b(i-1) A first observation is that in the worst case, the first 2N numbers in S will contain the final result of N numbers. i.e in (a1,b1), (a1,b2)(a1,bN), (a2,b1), (a2,b2)(a2,bN) In the best case first N numbers in S will contain the final N numbers (already sorted in decreasing order) i.e in (a1,b1), (a1,b2)(a1,bN) Now, if we consider again the worst case scenario, then we can first divide 2N numbers in two groups of size N each and each of this group is already sorted in decreasing order. i.e (a1,b1), (a1,b2)(a1,bN) and (a2,b1), (a2,b2)(a2,bN) Now we can simply apply Merge Algorithm on these 2 already sorted arrays of size N each in O(N) time, which solves the problem I can
Re: [algogeeks] Generate a number
If space is not a restriction- Build a B-tree. 1. Have a dummy root. 2. At level one- Numbers divisible by 1. ie. (1-9). 3. At level 2- numbers made after adding a digit to numbers at level 1. e.g. number 7 at level will have children- (70,72,74,76,78). and so on.. 4. Do the same at each level. Leaf nodes at level 10 will be your answers. I think math can optimize this a bit- though. On Thu, Jul 29, 2010 at 9:57 PM, amit amitjaspal...@gmail.com wrote: An algorithm to print all the 10-digit nos such that first 1 digit is divisible by 1, first 2 digits by 2, first 3 digits by 3 and so on...first 9 digits by 9. I think the tenth digit can be anything from 0 to 9. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Adobe Strings matching Puzzle.
Excuse the indentations, how about the following solution? O(strlen(B)). match(char * A, char *B) { char * tempA = *A; while(1) { char * tempB=*B; while(*B *B == *A) { *B++;*A++; } if(!*B) return *tempB; else { while(*B *B++ != *A) ; if(*B) continue; else return NULL; } //while(1) }//match() -Shiv On Wed, Jul 28, 2010 at 3:41 AM, Anand anandut2...@gmail.com wrote: It is just an Implementation of KMP string match Algorithm. In the first section, I am find the prefix function π for a pattern which encapsulates knowledge about how the pattern matches against shifts of itself. This information can be used in second section to avoid testing useless shifts for string matching. On Tue, Jul 27, 2010 at 3:41 AM, bujji jajalabu...@gmail.com wrote: Hi Anand, Can you please explain your code? What is the magic number 10 in if(k == 10) { printf(String Matched\n); } in your code? What does while loop do in your code? Can you please write a comment? -Thanks in advance, Bujji #include stdio.h #include string.h /* KMP algorithm for string Matching */ main() { char *p=This is my first post to this group; char *T=to this group this is my post; int len = strlen(p); int len1 = strlen(T); printf(len:%d len1:%d\n,len,len1); int k = 0,i; int array[40]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* Pre processing which takes O(m)*/ for(i = 2; i len; i++) { while(k 0 p[k+1] != p[i]) { k = array[k]; } if(p[k+1] == p[i]) { k++; array[i] = k; } } /* Matching which takes O(n) */ k = 1; for(i = 0; i len1; i++) { while(k 0 p[k+1] != T[i]) { k = array[k]; } if(p[k+1] == T[i]) { k++; printf(%d %d %c\n,k,i,p[k]); if(k == 10) { printf(String Matched\n); } } } } On Jul 22, 9:22 pm, Anand anandut2...@gmail.com wrote: http://codepad.org/grtqfF5f Here is KMP code to solve the problem On Thu, Jul 22, 2010 at 2:01 AM, Mallesh Kavuluri mallesh...@gmail.com wrote: Taking for granted that KMP algorithm searches for a given string of length n in a string of length m in O(n+m) time, How do we solve this puzzle in linear time? On Thu, Jul 22, 2010 at 1:29 PM, sharad kumar aryansmit3...@gmail.comwrote: @all:pls make use of KMP algorithm...because knuth morris prat algor On Wed, Jul 21, 2010 at 6:16 PM, anugrah anugrah.agra...@gmail.com wrote: Stack can be used to push the characters of the string A and then popped off while scanning through the string B until there is a difference in the character read from the string B and the one popped off from the stack.. On Jul 20, 4:40 pm, agnibha nath agni.fl...@gmail.com wrote: You can try rabin-carp.. On Jul 20, 4:18 pm, mallesh mallesh...@gmail.com wrote: We are given two strings. A and B. First few letters of A match with Last letters of B. We have to find the longest match in linear time. Example: char * A =This is my first post to this group; char *B= to this group this is my post; Algorithm should return starting position of substring to this group in string A. How do we do this? -Thanks and regards, Mallesh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.- Hide quoted text - - Show quoted text - -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send
Re: [algogeeks] Re: Adobe Strings matching Puzzle.
Ignore the last post. match(char * A, char *B) { char * tempA = *A; while(1) { char * tempB=*B; while(*B *B == *A) { *B++; *A++; } if(!*B) return *tempB; else { while(*B *B != *A){ *B++ ; } if(*B) { *A = *tempA; continue; } else return NULL; } //while(1) }//match() On Wed, Jul 28, 2010 at 1:32 PM, Shiv ... shivsinha2...@gmail.com wrote: Excuse the indentations, how about the following solution? O(strlen(B)). match(char * A, char *B) { char * tempA = *A; while(1) { char * tempB=*B; while(*B *B == *A) { *B++;*A++; } if(!*B) return *tempB; else { while(*B *B++ != *A) ; if(*B) continue; else return NULL; } //while(1) }//match() -Shiv On Wed, Jul 28, 2010 at 3:41 AM, Anand anandut2...@gmail.com wrote: It is just an Implementation of KMP string match Algorithm. In the first section, I am find the prefix function π for a pattern which encapsulates knowledge about how the pattern matches against shifts of itself. This information can be used in second section to avoid testing useless shifts for string matching. On Tue, Jul 27, 2010 at 3:41 AM, bujji jajalabu...@gmail.com wrote: Hi Anand, Can you please explain your code? What is the magic number 10 in if(k == 10) { printf(String Matched\n); } in your code? What does while loop do in your code? Can you please write a comment? -Thanks in advance, Bujji #include stdio.h #include string.h /* KMP algorithm for string Matching */ main() { char *p=This is my first post to this group; char *T=to this group this is my post; int len = strlen(p); int len1 = strlen(T); printf(len:%d len1:%d\n,len,len1); int k = 0,i; int array[40]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* Pre processing which takes O(m)*/ for(i = 2; i len; i++) { while(k 0 p[k+1] != p[i]) { k = array[k]; } if(p[k+1] == p[i]) { k++; array[i] = k; } } /* Matching which takes O(n) */ k = 1; for(i = 0; i len1; i++) { while(k 0 p[k+1] != T[i]) { k = array[k]; } if(p[k+1] == T[i]) { k++; printf(%d %d %c\n,k,i,p[k]); if(k == 10) { printf(String Matched\n); } } } } On Jul 22, 9:22 pm, Anand anandut2...@gmail.com wrote: http://codepad.org/grtqfF5f Here is KMP code to solve the problem On Thu, Jul 22, 2010 at 2:01 AM, Mallesh Kavuluri mallesh...@gmail.comwrote: Taking for granted that KMP algorithm searches for a given string of length n in a string of length m in O(n+m) time, How do we solve this puzzle in linear time? On Thu, Jul 22, 2010 at 1:29 PM, sharad kumar aryansmit3...@gmail.comwrote: @all:pls make use of KMP algorithm...because knuth morris prat algor On Wed, Jul 21, 2010 at 6:16 PM, anugrah anugrah.agra...@gmail.com wrote: Stack can be used to push the characters of the string A and then popped off while scanning through the string B until there is a difference in the character read from the string B and the one popped off from the stack.. On Jul 20, 4:40 pm, agnibha nath agni.fl...@gmail.com wrote: You can try rabin-carp.. On Jul 20, 4:18 pm, mallesh mallesh...@gmail.com wrote: We are given two strings. A and B. First few letters of A match with Last letters of B. We have to find the longest match in linear time. Example: char * A =This is my first post to this group; char *B= to this group this is my post; Algorithm should return starting position of substring to this group in string A. How do we do this? -Thanks and regards, Mallesh -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- yezhu malai vaasa venkataramana Govinda Govinda -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com algogeeks
Re: [algogeeks] ALGORITHM
What if the number are not consecutive? My approach- Put the numbers in a hash till a collision occurs. On Wed, Jul 28, 2010 at 9:21 PM, Apoorve Mohan apoorvemo...@gmail.comwrote: Solution : 1. Find Xor of numbers from 1 to n-1. 2. Find Xor of the numbers present in the array. 3. Xor the results from step 1 and 2 you will get the repeated number. On Wed, Jul 28, 2010 at 8:46 PM, akshay akshayrastogi2...@gmail.comwrote: An array of unsorted numbers n is given with one no.repeated once ie n-1 distinct nos to find duplicate no. in o(n) complexity -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- 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 algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.