[algogeeks] Re: worst case complexity
O(n^5) more interesting will be to find exact number of iterations ... On Sep 10, 10:48 am, siddharam suresh siddharam@gmail.com wrote: first loop n send loop n^2 third loop n(i m not sure) so n^4 Thank you, Sid. On Sat, Sep 10, 2011 at 11:09 AM, ravi maggon maggonr...@gmail.com wrote: I think it should be n^3 On Sat, Sep 10, 2011 at 10:51 AM, Neha Singh neha.ndelhi.1...@gmail.comwrote: O(n^5) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] virtual table count
as of my knowledge ... virtual table is created for every class which has either a virtual function or derived from a class which has virtual function.. suppose..B is child of A , if u create an obj for A and called virtual method overloaded in B,then the method in A only be called... So, in ur prog , there are 3 classes and 3 virtual tables ... class Base { public: virtual void method() { printf(in base virtual); } }; class Child : public Base { public: void method() { printf(in child virtual); } }; main() { /* Base *b=new Child(); b-method(); // prints in child virtual... */ Base b; b.method(); // prints in base virtual } On Sat, Sep 10, 2011 at 1:05 AM, ravi maggon maggonr...@gmail.com wrote: let their be two classes A and B having a virtual function. class C derives both class A and B. How many virtual table does class C have? -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
Re: [algogeeks] tree traversal
in traversing a tree , all we know are conventional tree traversals(pre,in,post).. there r converse tree traversals also... converse pre,in,post... ex: 1 23 45 6 7 converse preorder : 13276254 converse inorder : 7361524 converse postorder : 7635421 On Sat, Sep 10, 2011 at 1:56 AM, amrit harry dabbcomput...@gmail.comwrote: there is one more way called as.. Level order traversing or spiral traversing google this term u will find a new method. On Sat, Sep 10, 2011 at 11:08 AM, ravi maggon maggonr...@gmail.comwrote: can u elaborate its algo On Sat, Sep 10, 2011 at 10:58 AM, Shravan Kumar shrava...@gmail.comwrote: zigzag, level by level ? On Sat, Sep 10, 2011 at 10:48 AM, ravi maggon maggonr...@gmail.comwrote: give some traversal other then pre,in and post order to print all elements of tree? Asked in informatica interview. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- AMRIT -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
[algogeeks] cormen question
given a set of S of n integers and another integer x,determine whether or not there exists two elements in S whose sum is exactly x..running time should be (n lgn) -- * RASHMI JAIN 3rd Year,B.E.(IT) Delhi technological University * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: worst case complexity
ans : O(n^5) inner most loop rums for j times then middle loop sums 'j ' from j=0 to j= i^2 so ans is proportional to i^4 and outer loop again sums it for n times so ans : O(n^5) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] samsung placement
hi friends if any one have pattern or que/ans for samsung (SIEL) plz help -- Regards SOURABH KUMAR JAIN MCA, NIT RAIPUR MOB.-+919993878717 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] cormen question
Sort the numbers in Set S having n integers. O(nlogn). Take two variables a and b pointing to least and max index of n. Move the pointers in such a way that if(*a+*b xa=b) b--; else if(*a+*bxa=b) a++; else printf(AB is found %d + %d = %d,*a,*b,x); Note this covers the array from two sides and hence summing up to order n. So total order is O(nlogn) Since this is covering the array from left and right On Sat, Sep 10, 2011 at 12:01 PM, Rashmi Jain rashmi.jain...@gmail.comwrote: given a set of S of n integers and another integer x,determine whether or not there exists two elements in S whose sum is exactly x..running time should be (n lgn) -- * RASHMI JAIN 3rd Year,B.E.(IT) Delhi technological University * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thanks and Regards, Shiwakant Bharti -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] samsung placement
hey bro.there were puzzles questions in c language.and mostly came frm rs aggarwal reasoning buk..so just go through them and in quant part mainly questions were on DI and few questions were there on other chapters of aptitude like time and work, percentage, profit and loss, ratio and proportion etc. and technical test was easy -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: worst case complexity
In work case (ie max value of i,j and k ll be) for(i=0;in;i++) //i=n { for(j=0;jn*n;j++) // j=i=n; { for(k=0;kn*n;k++) // k=j=i=n; } } So Ans O(n^5) -- Prashant Kulkarni On Sat, Sep 10, 2011 at 12:05 PM, deepikaanand swinyanand...@gmail.comwrote: ans : O(n^5) inner most loop rums for j times then middle loop sums 'j ' from j=0 to j= i^2 so ans is proportional to i^4 and outer loop again sums it for n times so ans : O(n^5) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
@Piyush: +1 On Sat, Sep 10, 2011 at 1:07 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: pseudo algo: =array idx[0...k-1] indicates the current pointer position in the ith stream(initialized to 0). =heap tree of size k where each node stores value of the data and value of stream which the node belongs to. do{ for all i = 0:k-1 =insert idx[i] value of ith stream to the heap =take the root element of the heap and put it in the output stream. =idx[m]++ where m is the stream value stored at the root. } while(true); On Sat, Sep 10, 2011 at 12:15 AM, aditya kumar aditya.kumar130...@gmail.com wrote: Given k sorted streams where each stream could possibly be infinite in length, describe an efficient algorithm to merge the k streams into a new stream (also in sorted order). -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz help for C output
(a) #define f(g,g2) g##g2 int main() { int var12=100; printf(%d,f(var,12)); getch(); } what will be the output?? (b) main() { int i=400,j-300; printf(%d...%d); } (c) void main() { char far *farther,* farthest ; printf(%d..%d,sizeof(father),sizeof(farthest)); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: worst case complexity
i==n j==i*i= n*n k==j=i*i=n*n so total i*j*k=n^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/-/jv1X4YzDp_sJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz help for C output
a) 100 On Sat, Sep 10, 2011 at 12:40 AM, abhishek abhishek.ma...@gmail.com wrote: (a) #define f(g,g2) g##g2 int main() { int var12=100; printf(%d,f(var,12)); getch(); } what will be the output?? (b) main() { int i=400,j-300; printf(%d...%d); } (c) void main() { char far *farther,* farthest ; printf(%d..%d,sizeof(father),sizeof(farthest)); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 help for C output
@ abhinav u r right could you plz explain how? On Sep 10, 12:50 pm, abhinav gupta guptaabhinav...@gmail.com wrote: a) 100 On Sat, Sep 10, 2011 at 12:40 AM, abhishek abhishek.ma...@gmail.com wrote: (a) #define f(g,g2) g##g2 int main() { int var12=100; printf(%d,f(var,12)); getch(); } what will be the output?? (b) main() { int i=400,j-300; printf(%d...%d); } (c) void main() { char far *farther,* farthest ; printf(%d..%d,sizeof(father),sizeof(farthest)); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz help for C output
1. 100 2. 400...300 3. 4 .. 2 -- Parag Khanna B.tech Final Year NIT,Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz help for C output
2nd answer is compiler dependent ..i think so .. in gcc it gives garbage values . On Sat, Sep 10, 2011 at 3:51 AM, parag khanna khanna.para...@gmail.comwrote: 1. 100 2. 400...300 3. 4 .. 2 -- Parag Khanna B.tech Final Year NIT,Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
[algogeeks] Re: plz help for C output
@ parag u r right could u explain how?? On Sep 10, 12:51 pm, parag khanna khanna.para...@gmail.com wrote: 1. 100 2. 400...300 3. 4 .. 2 -- Parag Khanna B.tech Final Year NIT,Kurukshetra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] plz help for C output
in #definef(g,g2) g##g2 the ## operator concatenate the 2 arguments in the macro expansion. thus it becomes var12 -- Sajal Choudhary Undergraduate Student, Division of Computer Engineering, Netaji Subhas Institute of Technology, New Delhi. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Kth largest element
@Dave: TC in your first case will be O(klogn + n). Transforming array into heap would be O(n). Correct me If i am wrong. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: informatica pattern and question of interview
Yeah..agree with this... Just find minimum no and increment that..! Any counter-example?? On Saturday, 10 September 2011 01:19:41 UTC+5:30, hashd wrote: For question 2 I guess finding the minimum element's index should suffice (considering all elements are positive integer). No need to even calculate n! as it might cause overflow in case the arrary is big. -- 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/-/PY1okbjIwNoJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Paypal
Has anyone recently attended the placement procedure for paypal. Like how is it? -- 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/-/WzkQbuBpGlkJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Implementing a grep
If i have to code the functioning of grep what data structure is recommended for implementing it. I was thinking may be using trie with each node having a vector list of line numbers in which they appear. Is it the correct one or is there any better solution to this. -- 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/-/TnrBS2wCopMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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] Code it
What would be the efficient way to code this program.?? Given an array of size n, find all the possible sub set of the array of size k(all the subsets must be of size k). -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: worst case complexity
O(n^4) Just think... for(i = 0; i n; i++) for(j = 0; j i; j++) has Time Complexity O(n^2) then how come for(i = 0; i n; i++) for(j=0; ji*i; j++) it's O(n^2).. it's...1 + 2^2 + 3^2 + ...n^2 which is O(n^3) but adding one for(k=0; k j; k++) will not make it n^5 it will be 1+ (1+4) + (1+4+9)... which is sum(O(n^3)) hence time complexity is O(n^4) On Sat, Sep 10, 2011 at 1:19 PM, Brijesh brijeshupadhyay...@gmail.comwrote: i==n j==i*i= n*n k==j=i*i=n*n so total i*j*k=n^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/-/jv1X4YzDp_sJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] What would be the ans.
three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Kth largest element
why evaryone is thinking about heap...we can use selection algorithm and find the n-k smallest element in that. this will take O(n) time On Sep 10, 1:23 pm, Kunal Patil kp101...@gmail.com wrote: @Dave: TC in your first case will be O(klogn + n). Transforming array into heap would be O(n). Correct me If i am wrong. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.comwrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
I got.. 1.) 2/pi 2.) 3.) 0.5 - (1/pi) On Sat, Sep 10, 2011 at 2:47 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] What would be the ans.
@Piyush Grover: please explain ur answer On Sat, Sep 10, 2011 at 3:30 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: I got.. 1.) 2/pi 2.) 3.) 0.5 - (1/pi) On Sat, Sep 10, 2011 at 2:47 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Circular Left shift
consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.comwrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Kth largest element
just look at the cormen's 9th chapter in 3rd edition.. randomized_select procedure is exactly suitable for this.. it is less complex than heapify procedures and all actually it is of modification of quick sort and u guys ll appreciate that.. On Sat, Sep 10, 2011 at 3:12 PM, a.maiskar maiskara...@gmail.com wrote: why evaryone is thinking about heap...we can use selection algorithm and find the n-k smallest element in that. this will take O(n) time On Sep 10, 1:23 pm, Kunal Patil kp101...@gmail.com wrote: @Dave: TC in your first case will be O(klogn + n). Transforming array into heap would be O(n). Correct me If i am wrong. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] logical and physical address
we have page table having 64 entries of 10 bits each. and page size is of 512 bytes. tell the no of bits required for physical and logical address. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
@sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.com wrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
Sorry guys.. I was wrong, radius also matters here... still investigating On Sat, Sep 10, 2011 at 3:56 PM, sarath prasath prasathsar...@gmail.comwrote: @Piyush Grover: please explain ur answer On Sat, Sep 10, 2011 at 3:30 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: I got.. 1.) 2/pi 2.) 3.) 0.5 - (1/pi) On Sat, Sep 10, 2011 at 2:47 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Write a program
#includestdio.h int main() { int a[]={3,1,2,1}; int n=4; int top=0,i; for(int i=0;in;i++) { int flag=0; for(int j=0;ji;j++) { if(a[i]==a[j]) { flag=1; break;} } if(!flag) { a[top++] =a[i]; } } n=top; for(int i=0;in;i++) printf(%d,a[i]); } time :O(n^2) space :O(1) extra ... If we hashing , we can do this in O(n) with cost of space O(n) extra ... On Sat, Sep 10, 2011 at 5:21 AM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program? -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
Re: [algogeeks] logical and physical address
physical address:19 bits(10+9) logical address : 15 bits(6+9) On Sat, Sep 10, 2011 at 6:48 AM, ravi maggon maggonr...@gmail.com wrote: we have page table having 64 entries of 10 bits each. and page size is of 512 bytes. tell the no of bits required for physical and logical address. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
[algogeeks] Re: File trying to read when reached EOF , WHY ????
The code was bug free . I just asked why the code is still going inside the blockof code where the condition (!feof() ) is given ...Moreover it was been asked in an Interview for ur information .. I have just introduced class on top of it . You should perhaps read the question properly then judge it The solution for the making it bug free was also provided. Without seeing the question u r saying the above . U take ur decision undeliberately and hastily man ...sry to tell tht but it's true . -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
Re: [algogeeks] Circular Left shift
How is this one ?? int a[9]={9,7,6,5,3,23,14,2,4} n=9 int *p,*q; p=a; for(q=a;in;q++,i++); ReverseArray(p,q) p=a[0]; q=a[n-1-k] ReverseArray(p,q) p=a[n-k]; q=a[n-1] ReverseArray(p,q) void ReverseArray(int *l,int *r) { int temp; while(lr) { temp=*l; *l=*r; *r=temp l++; r--; } } Thanks Regards, -Rohit On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@gmail.com -- You received this
Re: [algogeeks] Circular Left shift
This can also be done: for( i=0; ik;i++) { b[i]=a[i]; } for (;in;i++) { a[i-k]=a[i]; } while((i-k)n) { a[i-k]=b[i]; } But extra array is used here. On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com wrote: How is this one ?? int a[9]={9,7,6,5,3,23,14,2,4} n=9 int *p,*q; p=a; for(q=a;in;q++,i++); ReverseArray(p,q) p=a[0]; q=a[n-1-k] ReverseArray(p,q) p=a[n-k]; q=a[n-1] ReverseArray(p,q) void ReverseArray(int *l,int *r) { int temp; while(lr) { temp=*l; *l=*r; *r=temp l++; r--; } } Thanks Regards, -Rohit On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.com wrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this
Re: [algogeeks] Circular Left shift
@rohit : why don't u have a look at the older posts before replying some thing ...ok .. I'm sorry if u are hurt .. what is the time complexity and space complexity of u'r older post .. On Sat, Sep 10, 2011 at 8:03 AM, Rohit jalan jalanha...@gmail.com wrote: This can also be done: for( i=0; ik;i++) { b[i]=a[i]; } for (;in;i++) { a[i-k]=a[i]; } while((i-k)n) { a[i-k]=b[i]; } But extra array is used here. On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com wrote: How is this one ?? int a[9]={9,7,6,5,3,23,14,2,4} n=9 int *p,*q; p=a; for(q=a;in;q++,i++); ReverseArray(p,q) p=a[0]; q=a[n-1-k] ReverseArray(p,q) p=a[n-k]; q=a[n-1] ReverseArray(p,q) void ReverseArray(int *l,int *r) { int temp; while(lr) { temp=*l; *l=*r; *r=temp l++; r--; } } Thanks Regards, -Rohit On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.com wrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.
Re: [algogeeks] What would be the ans.
no...it's close to zero but we can't compute it in terms of pi, R or so. We need to get number of points on the perimeter which is not possible with the standard method. For the right-triangle. choose one random point and if second points is diametric to the first point then any third point on the circle will make it right triangle. or any two points amongst the three are diametric then it will form a right triangle. So...P = 3C2/nC3 now n- infinite How to solve this?? On Sat, Sep 10, 2011 at 5:22 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: According to me, it should be 1/3 for each of the three options... On Sat, Sep 10, 2011 at 4:48 PM, Piyush Grover piyush4u.iit...@gmail.comwrote: Sorry guys.. I was wrong, radius also matters here... still investigating On Sat, Sep 10, 2011 at 3:56 PM, sarath prasath prasathsar...@gmail.comwrote: @Piyush Grover: please explain ur answer On Sat, Sep 10, 2011 at 3:30 PM, Piyush Grover piyush4u.iit...@gmail.com wrote: I got.. 1.) 2/pi 2.) 3.) 0.5 - (1/pi) On Sat, Sep 10, 2011 at 2:47 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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.
Re: [algogeeks] Re: worst case complexity
Sorry for one small mistake in my analysis. I forgot summation includes extreme values also, in the calculation. So, final number of iteration is for for(int i=1;i=(n);i++) for(int j=1;j=(i*i);j++) for(int k=1;k=(j);k++) { } But this mistake doesn't have any effect on the O(n^5) Time complexity. :) :) On Sat, Sep 10, 2011 at 5:10 PM, Kunal Patil kp101...@gmail.com wrote: @Piyush: In 2 ways I will prove you wrong. 1) Lets take 2 innermost loops. for(j=0;ji*i;j++) { for(k=0;kj;k++) } Let i*i be m. Thus, It becomes. for(j=0;jm;j++) { for(k=0;kj;k++) } You would agree that this is O(m^2). This means innermost two loops constitute O(m^2) -- O(( i^2) ^ 2) -- O(i ^ 4) Outer loop iterates over i once till n. So, for i=0 it will run O(i^4=0) times for i=1 it will run O(i^4=1) times for i=2 it will run O(i^4=16) times for i=n it will run O(n^4) times. Summing all them up, its O(n^5). 2) Lets represent given loops by summations: for(i=0;in;i++) -- summation_i_from_0_to_n { for(j=0;ji*i;j++) -- summation_j_from_0_to_i^2 { for(k=0;kj;k++) -- summation_k_from_0_to_j So To calculate exact number of iterations you would need to solve these nested summations. Steps: 1) Initially we have, summation_i_from_0_to_n ( summation_j_from_0_to_i^2 (summation_k_from_0_to_j (constant) )) 2) Innermost summation evaluates to j So now we are left with -- summation_i_from_0_to_n ( summation_j_from_0_to_i^2 ( j ) ) 3) Innermost evaluates to (i^2)*(i^2 + 1) /2 So now we are left with -- summation_i_from_0_to_n ( (i^2)*(i^2 + 1) /2 ) 4) This evalutes to (1/2) { (6*n^5 + 15n^4 + 10n^3 - n) / 30 } + (1/2) { n*(n+1)*(2n+1) / 6 } which is equal to the exact number of iterations. This is clearly O(n^5). Correct me If I am wrong anywhere in the analysis... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Circular Left shift
@BharathKumar: extremely sorry dude .. will not do this again .. Can you forgive me ? :p On Sep 10, 2011 12:09 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @rohit : why don't u have a look at the older posts before replying some thing ...ok .. I'm sorry if u are hurt .. what is the time complexity and space complexity of u'r older post .. On Sat, Sep 10, 2011 at 8:03 AM, Rohit jalan jalanha...@gmail.com wrote: This can also be done: for( i=0; ik;i++) { b[i]=a[i]; } for (;in;i++) { a[i-k]=a[i]; } while((i-k)n) { a[i-k]=b[i]; } But extra array is used here. On Sat, Sep 10, 2011 at 5:30 PM, Rohit jalan jalanha...@gmail.com wrote: How is this one ?? int a[9]={9,7,6,5,3,23,14,2,4} n=9 int *p,*q; p=a; for(q=a;in;q++,i++); ReverseArray(p,q) p=a[0]; q=a[n-1-k] ReverseArray(p,q) p=a[n-k]; q=a[n-1] ReverseArray(p,q) void ReverseArray(int *l,int *r) { int temp; while(lr) { temp=*l; *l=*r; *r=temp l++; r--; } } Thanks Regards, -Rohit On Sat, Sep 10, 2011 at 5:24 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.com wrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.com wrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.com wrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html (\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.com wrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You
Re: [algogeeks]
@aayush Dude... i dont knw from where did u find such a stupid question... Whole cryptography.mean all SSL , RSA , etc etc based on large numbers which have prime factors... if we are able to break them in partitions then whole security is. ! Cryptography's base is wholly and wholly depends on large numbers with large prime factors On Thu, Sep 8, 2011 at 11:25 AM, siddharam suresh siddharam@gmail.comwrote: guys there is subject called number theory and cryptography, in which there are so many algos to find prime number and prime factors of the number. Thank you, Sid. On Thu, Sep 8, 2011 at 11:17 AM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @sukran : sieve of erathothenes algo gives only the prime numbers below a number .. How can we find a number's all prime factors using this algo pls explain ... On Wed, Sep 7, 2011 at 5:15 PM, sukran dhawan sukrandha...@gmail.com wrote: sieve of erathothenes algo On Wed, Sep 7, 2011 at 1:36 PM, Yogesh Yadav medu...@gmail.com wrote: prime no has only 2 factors. number itself and 1. On Wed, Sep 7, 2011 at 12:14 PM, aayush jain ajain...@gmail.com wrote: can anybody tell me the code of find the prime no. and after finding prime no. find its prime factore using linkes list?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees BharatKumar Bagana http://www.google.com/profiles/bagana.bharatkumar Mobile +91 8056127652 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] What would be the ans.
The correct ans is : for right angled triangle : 0 for acute angled triangle : 1/2 for obtuse angled triangle : 1/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.
Re: [algogeeks] What would be the ans.
How u calculated this?? On Sat, Sep 10, 2011 at 6:19 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote: The correct ans is : for right angled triangle : 0 for acute angled triangle : 1/2 for obtuse angled triangle : 1/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. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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.
Re: [algogeeks] Paypal
hey browat's it eligibility criteria and package and branches allowed at ur campus.and when it is visiting.. On Sat, Sep 10, 2011 at 2:22 PM, mohit mittal mohitm.1...@gmail.com wrote: Has anyone recently attended the placement procedure for paypal. Like how is it? -- 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/-/WzkQbuBpGlkJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Implementing a grep
correct me if I m wrong.. grep function is to print all line which has substring. containing... the string to be search we r picking a line by line... by getline function... from text file... approaches : trie approach :if memory could not be a problem ..it would not be a problem to use it... but we have to care of freeing trie ... list after searching for the given substring. KMP approach : would be otherwise... better With regards, Praveen Raj DCE-IT 4th yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
it would be close to zero but not exactly zero. On Sat, Sep 10, 2011 at 6:28 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: How u calculated this?? On Sat, Sep 10, 2011 at 6:19 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote: The correct ans is : for right angled triangle : 0 for acute angled triangle : 1/2 for obtuse angled triangle : 1/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. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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.
Re: [algogeeks] What would be the ans.
Can anyone explain me approach. how u r calculating..it... With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
for RT angled triangle , 0 cudnt be the answer , for obvious reason.. however it'll very small and close to zero... and for any two points on the circumference , there will be a point by which u can make rt angle triangle.. On Saturday, 10 September 2011 18:19:25 UTC+5:30, Neha Singh wrote: The correct ans is : for right angled triangle : 0 for acute angled triangle : 1/2 for obtuse angled triangle : 1/2 -- 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/-/-fOUp84vPjMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
@brijesh and piyush : There are infinite no. of points on the circumference of the circle. We have to select 2 diametrically opp. points for a right angled triangle. We can select 1 point anywhere. The second point has to be only one of all the infinite points. So, its probability is 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: What would be the ans.
let say there are n points on the circumference, then for rt angle triangle , answer would be nC2..select any two points , u'll always get a point which will make rt angle triangle.. but again we can not define no of points on circle..so :| On Saturday, 10 September 2011 14:47:53 UTC+5:30, Ishan Aggarwal wrote: three points are randomly chosen on a circle.what the probability that 1.triangle formed is right angled triangle. 2.triangle formed is acute angled triangle. 3.triangle formed is obtuse angled triangle. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 -- 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/-/-qmHfbqRbKYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
@brijesh : there r infinite points -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Kth largest element
@kunal.. +1 @dave ... for min heap.. read my statement again... kth largest would be (n-k+1)th smallest... @others ... randomized- partioning.. will not assure of finding an element..in O(n) for finding median ... we can be assure... that... O(n).. proof given in the cormenn With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
@brijesh.. +1.. but can we think of area approach...I m just thinking...??do google.. may find our answer With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 would be the ans.
But probability ZERO means , impossible scenario , while this is possible so better say very less, near to zero..not zero exactly :P -- 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/-/1JeUKFr2b7cJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] cormen question
@rashmi.. just sort the set in O(nlogn) then use two pointers ... one from first end and another from second endgiven below...in O(n).. i=0; j=n-1; while(ij) { if((a[i]+a[j])==x) { printf(%d%d,a[i],a[j]); break;} if((a[i]+a[j])x) j--; else i++; } do it with example... running time...O(nlogn)... With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@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.
Re: [algogeeks] Re: microsoft interview
whts the question?? With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Fri, Sep 9, 2011 at 12:17 PM, Amit Gupta amit30ma...@gmail.com wrote: Guys, why don't we do something like this : 1. If (arrayHasBeenTraversed, Goto 4). Else, Traverse the 2-D array [row,column] wise. Inspect element array[row][column]. Goto 2. 2. If you encounter a '1' (array[row][column]), change all the 0's in the corresponding [row,column] to '-1' Also, don't do anything if you encounter a '1'. 3. Goto 1. 4. Scan the array, change all '-1s' to 1s. Finish. Send your comment. Cheers, Amit -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks]
@ayush I am giving overall design ... class shape { public: virtual void display()=0; }; class triangle :public shape { public: void dispaly() {} }; class circle: public shape { public: void dispaly() {} } void main() { shape *bptr; triangle tr; circle ci; . if(character input=='t') bptr=tr; else bptr=ci; bptr-display(); } With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@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.
[algogeeks] Links for mock interviews.
I would like to take some mock interviews for internships in companies like Google, Microsoft, Can anybody guide me for good material or links for mock interviews? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Write a program
@brijesh ..+1 but character range.. from 0 to 255... With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sat, Sep 10, 2011 at 7:03 PM, Brijesh brijeshupadhyay...@gmail.comwrote: If you are talking about character array then it can be done in space O(128)=constant and time O(n),,. as Use Hash table of all 128 characters , and then traverse through your array and mark a flag in the hash table..when you encounter any duplicate character , which would be marked already in the hash table , dont print it..! And if its integer array... best would be sort it in O(n logn) and traverse through the loop and print those numbers which are not same as previous number.. On Saturday, 10 September 2011 14:51:18 UTC+5:30, Ishan Aggarwal wrote: Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program? -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2@aricent.com -- 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/-/TqJhP_DAD2AJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Write a program
Hi, Actually I am not good at hash tables. can u plzz suggest me some gud link from where I can study hash tables... and also tell me the logic for integer arrays for which the complexity will be o(n logn). Thanks in advance. -- Kind Regards Ishan Aggarwal Phone : +91-9654602663 On Sat, Sep 10, 2011 at 7:03 PM, Brijesh brijeshupadhyay...@gmail.comwrote: If you are talking about character array then it can be done in space O(128)=constant and time O(n),,. as Use Hash table of all 128 characters , and then traverse through your array and mark a flag in the hash table..when you encounter any duplicate character , which would be marked already in the hash table , dont print it..! And if its integer array... best would be sort it in O(n logn) and traverse through the loop and print those numbers which are not same as previous number.. On Saturday, 10 September 2011 14:51:18 UTC+5:30, Ishan Aggarwal wrote: Write a program to remove duplicate elements from an array by printing them only once? What will be the minimum time and space complexity required for this program? -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2@aricent.com -- 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/-/TqJhP_DAD2AJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] logical and physical address
please explain ... On Sat, Sep 10, 2011 at 5:10 PM, bharatkumar bagana bagana.bharatku...@gmail.com wrote: physical address:19 bits(10+9) logical address : 15 bits(6+9) On Sat, Sep 10, 2011 at 6:48 AM, ravi maggon maggonr...@gmail.com wrote: we have page table having 64 entries of 10 bits each. and page size is of 512 bytes. tell the no of bits required for physical and logical address. -- Regards Ravi Maggon Final Year, B.E. CSE Thapar University -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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.
Re: [algogeeks] semaphores
@neha ..+1 With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@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.
Re: [algogeeks] Circular Left shift
Ur idea does not work in the following case array : 7 5 3 6 9 2 11 n=7 and k=3 as per your explanation the answer would come 9 2 11 6 7 5 3 correct me if i am wrong... On 10 September 2011 04:54, bharatkumar bagana bagana.bharatku...@gmail.com wrote: swap k elements form 1 to k and n-k to n respectively... ex: k=3 temp=k; int a[9]= {9,7,6,5,3,23,14,2,4} ; has become {14,2,4,5,3,23,9,7,6}; now swap first k elements with k+1 to 2k elements ...now k=2k+1 , do this step again up to (kn-temp)... at last {5,3,23,14,2,4,9,7,6,} ; Time :O(n) and space O(1). On Sat, Sep 10, 2011 at 7:15 AM, kumar raja rajkumar.cs...@gmail.comwrote: @sarath: I did not get u .Could u please explain it with the example. On 10 September 2011 03:39, sarath prasath prasathsar...@gmail.comwrote: consider this approach.. first reverse the entire array... so it will be.. 4,2,14,23,3,5,6,7,9 and u want to shift k times right so u have to cut the array as n-k and reverse both the sides u ll get it.. so in ur scenario we are reversing upto the element 5 in array and reversing the remaining elements.. hope the complexity is of o(n).. On Sat, Sep 10, 2011 at 3:17 PM, kumar raja rajkumar.cs...@gmail.comwrote: U have used c[3] extra array.It is already known solution. so it is using O(k) space .i want the solution with constant space.. On 10 September 2011 02:08, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Solution :- void main(){int a[9]= {9,7,6,5,3,23,14,2,4} ;int n = 3;int c[3];int i;int k =0;for ( i=0;i3;i++) c[i]= a[i];for(i=3;i9;i++) a[i-3] =a[i];for(i=9-3;i9;i++) a[i] = c[k++];for(i=0;i9;i++)printf http://www.opengroup.org/onlinepubs/009695399/functions/printf.html(\n%d,a[i]);} On Sat, Sep 10, 2011 at 2:09 PM, kumar raja rajkumar.cs...@gmail.comwrote: Given an array of 'n' values you need to circular shift it 'k' times towards left. Input : 9 7 6 5 3 23 14 2 4 output : 5 3 23 14 2 4 9 7 6 n=9 , k= 3 constraints : Time complexity O(n) Space complexity O(1) The solutions with O(kn) time complexity and O(n) complexity with O(k) space complexity are already available. I want the O(n) solution with constant space.. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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. -- Regards Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Kumar Raja M.Tech(SIT) IIT Kharagpur, 10it60...@iitkgp.ac.in 7797137043. 09491690115. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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] How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
How can we find second largest element in an array... in O(n +logn-2)... give me proof. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
It can be done trivially in O(n). On Sat, Sep 10, 2011 at 10:18 AM, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
@gaurav... how?? With regards, Praveen Raj DCE-IT 3rd yr 735993 praveen0...@gmail.com On Sat, Sep 10, 2011 at 7:49 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: It can be done trivially in O(n). On Sat, Sep 10, 2011 at 10:18 AM, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Circular Left shift
@all... arr=[3,6,7,1,2,7,8,9] suppose: k=3 rotated three times.. first step... reverse.. first k(3) elements... [7,6,3,1,2,7,8,9] second step...reverse last (n-k) elements... [7,6,3,9,8,7,2,1] third step reverse the whole array[1,2,7,8,9,3,6,7] thanx, With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
@Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
+1. On Sat, Sep 10, 2011 at 7:58 PM, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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.
Re: [algogeeks] Circular Left shift
@amrit... +1 .. With regards, Praveen Raj DCE-IT 3rd yr -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Question -- plz answer
1.) there is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on.. It looks something like this 1 2 3 4 5 6 every cup has capacity C. you pour L liters of water from top . when cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled , Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the cups and so on. Now given C and M .Find the amount of water in ith cup. -- Kind Regards Ishan Aggarwal [image: Aricent Group] Presidency Tower-A, M.G.Road,Sector-14 Gurgaon,Haryana.122015 INDIA Phone : +91-9654602663 ishan2.aggar...@aricent.com puneet.ar...@aricent.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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
@Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from 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] Write a function to find the least common multiple of integers in an 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] MICROSOFT WRITTEN QUESTION
There are set of coins of {50,25,10,5,1} paise in a box.Write a program to find the number of ways a 1 rupee can be created by grouping the paise. post ur code. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] MICROSOFT WRITTEN QUESTION
O(n/a) where n is the required sum which is to be created by grouping the coins and a is the coin of smallest denomination so, O(n) in the worst case -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
@Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from 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] Find th gcd of 2 nos in the most efficient way
-- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 th gcd of 2 nos in the most efficient way
Euclid's GCD Algorithm: http://www.cs.berkeley.edu/~vazirani/s99cs170/notes/lec3.pdf On Sat, Sep 10, 2011 at 8:54 PM, Neha Singh neha.ndelhi.1...@gmail.comwrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- AMRIT -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] MICROSOFT WRITTEN QUESTION
On Sat, Sep 10, 2011 at 11:22 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote: O(n/a) For every n, it would add values for W(n-v1), W(n-v2),..., W(n-vm), if there are m denominations of coins. So the complexity would be O(nm). Also, this can be implemented in two ways. Top-down (which is what I mentioned), and Bottom-up. Search for Bottom-up DP. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT WRITTEN QUESTION
@Gaurav wat if here is n=1 den W(0)=? i dint get that -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
Oops ..no u hav to quicksort it. On Sat, Sep 10, 2011 at 8:24 AM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 th gcd of 2 nos in the most efficient way
C'mon http://en.wikipedia.org/wiki/Greatest_common_divisor On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] MICROSOFT WRITTEN QUESTION
On Sat, Sep 10, 2011 at 11:28 AM, teja bala pawanjalsa.t...@gmail.com wrote: @Gaurav wat if here is n=1 den W(0)=? i dint get that See, when you get to W(0) state, that means, you have created a valid combination. That means, you have gone through one 'path' through the various possibilities. That is why W(0)=1. It is the 'tail' of the recursion, i.e. the base case. When n=1, then, W(1)=W(1-50)+W(1-25)+...+W(1-1) All but the last factors would call W(n') where n' 0, and would result in 0. But the last part would be W(0), which is a valid state. So W(1) = 0+0+...+W(0) = 1 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
Then the complexity will be nlogn not n and if it is the worst case then it would be O(n^2)... On Sat, Sep 10, 2011 at 8:58 PM, abhinav gupta guptaabhinav...@gmail.comwrote: Oops ..no u hav to quicksort it. On Sat, Sep 10, 2011 at 8:24 AM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Akhilesh NSIT-COE -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
sort it in quicksort (descending order)...den take arr[1] --second largest On Sat, Sep 10, 2011 at 8:34 AM, Akhilesh Vedhera akhileshn...@gmail.comwrote: Then the complexity will be nlogn not n and if it is the worst case then it would be O(n^2)... On Sat, Sep 10, 2011 at 8:58 PM, abhinav gupta guptaabhinav...@gmail.comwrote: Oops ..no u hav to quicksort it. On Sat, Sep 10, 2011 at 8:24 AM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Akhilesh NSIT-COE -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
Well you can avoid that condition by comparing the number by: 1. Keeping two numbers, largest and second largest. 2. Comparing with the second largest. If it is greater than the second largest, set second_largest = num. Else continue. 3. If second_largest largest, swap(largest,second_largest). O(n) complexity. Not sure, how to put a bound on the number of comparisons. On Sat, Sep 10, 2011 at 11:36 AM, abhinav gupta guptaabhinav...@gmail.com wrote: sort it in quicksort (descending order)...den take arr[1] --second largest On Sat, Sep 10, 2011 at 8:34 AM, Akhilesh Vedhera akhileshn...@gmail.com wrote: Then the complexity will be nlogn not n and if it is the worst case then it would be O(n^2)... On Sat, Sep 10, 2011 at 8:58 PM, abhinav gupta guptaabhinav...@gmail.com wrote: Oops ..no u hav to quicksort it. On Sat, Sep 10, 2011 at 8:24 AM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Akhilesh NSIT-COE -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post
Re: [algogeeks] Write a function to find the least common multiple of integers in an array
http://tinyurl.com/3hm3gug On Sat, Sep 10, 2011 at 10:46 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
large1 = a[0]; large2 = a[1]; if(large1 large2) swap(large1,large2) while(i n) { if(a[i] large1) { large2 = large1 large1 = a[i] } else if(a[i] large2) large2 = a[i] } // test the case if no of elements is 1 :) On Sat, Sep 10, 2011 at 8:54 PM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Write a function to find the least common multiple of integers in an array
find GCD by eucledian method LCM = (a * b )/GCD; On Sat, Sep 10, 2011 at 9:13 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: http://tinyurl.com/3hm3gug On Sat, Sep 10, 2011 at 10:46 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: How can we find second largest element in an array... in O(n+logn-2)... give me proof.....
where n is the size of array On Sat, Sep 10, 2011 at 9:16 PM, sukran dhawan sukrandha...@gmail.comwrote: large1 = a[0]; large2 = a[1]; if(large1 large2) swap(large1,large2) while(i n) { if(a[i] large1) { large2 = large1 large1 = a[i] } else if(a[i] large2) large2 = a[i] } // test the case if no of elements is 1 :) On Sat, Sep 10, 2011 at 8:54 PM, Dave dave_and_da...@juno.com wrote: @Abhinav: Does it work correctly on {1, 3, 2}, or, for that matter, on any array where the second largest comes after the largest? Dave On Sep 10, 10:16 am, abhinav gupta guptaabhinav...@gmail.com wrote: temp2 is second largest element. On Sat, Sep 10, 2011 at 8:00 AM, abhinav gupta guptaabhinav...@gmail.comwrote: I can solve this problem in O(n) i=0; temp1=arr[0]; while(i != len) { if(arr[i] temp1) { temp2=temp1; temp1=arr[i] } i++; } On Sat, Sep 10, 2011 at 7:42 AM, Dave dave_and_da...@juno.com wrote: @Replying to my own posting: remove the words one of the numbers that lost to, so that the explanation reads The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the largest, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:28 am, Dave dave_and_da...@juno.com wrote: @Praveen: The question should be How can we find the second largest element in an array in n + ceiling(log_2(n)) - 2 comparisons? The answer is to use a tournament to select the largest number. The second largest number will have lost to one of the numbers that lost to the largest. It takes n - 1 comparisons to determine the largest number. There are ceiling(log_2(n)) numbers that have lost to the maximum, and it takes ceiling(log_2(n)) - 1 comparisons to find the largest of them. Dave On Sep 10, 9:18 am, praveen raj praveen0...@gmail.com wrote: How can we find second largest element in an array... in O(n +logn-2)... give me proof.- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |3 # ! /\/ @ \./ -- @ |3 # ! /\/ @ \./- 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Paypal
around 25th 65 arnd 8 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/7FtN8hsesrgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 th gcd of 2 nos in the most efficient way
while(num2 != 0) { rem = num1 % num2 num1 = num2 num2 = rem } On Sat, Sep 10, 2011 at 8:59 PM, Gaurav Menghani gaurav.mengh...@gmail.comwrote: C'mon http://en.wikipedia.org/wiki/Greatest_common_divisor On Sat, Sep 10, 2011 at 11:24 AM, Neha Singh neha.ndelhi.1...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Gaurav Menghani -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Paypal
cau u elaborate me.m not getting it... On Sat, Sep 10, 2011 at 9:21 PM, mohit mittal mohitm.1...@gmail.com wrote: around 25th 65 arnd 8 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/7FtN8hsesrgJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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.