Re: [algogeeks] Re: swap objects without temp variable
we need to use + and - as operator overloading. so, that i will work f9 for ur objects. so make operator overloading for + and - operator. On Sat, Nov 17, 2012 at 9:12 PM, AISHWARYA KUMAR aish@gmail.com wrote: in one line a=a^b^(b=a) ; -- -- *Thanks and Regards,* Abhinav Kumar Gupta Member Technical Staff | Oracle India Pvt. Lmt. Bangalore (KA) - 560029. +919060407434 | +918123065622 abhinav@gmail.com --
[algogeeks] MS: searching problem......help me out...
We have given a list 14 6 7 15 8 9 we have to find 15 in (log n ) times. -- *Thanks and Regards,* Abhinav Kumar Gupta **abhinav@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] MS: searching problem......help me out...
@Rahul: but for heapify, i need to build heap tree first from the list. which will cost linear traversal of the elements, that will cost O(n). but i need to search it in O(log n) or polylogrithmic complexity of (log n) i.e. (log^2 n). On Sun, Jun 3, 2012 at 8:55 AM, Rahul Kumar Patle patlerahulku...@gmail.com wrote: @abhinav: if you want to search just 15 in log(n) time then you can use the concept of heap tree.. apply one round of heapification (not for all elements but just one time it will be complete in log(n) times), and you will need to swap elements but when you got element 15 you can stop.. although space complexity has increased... you will need one redundant array to use heap operation so that finally you will have original array as it is... Thanks and Regards: Rahul Kumar Patle On Sun, Jun 3, 2012 at 8:31 PM, abhinav gupta abhinav@gmail.comwrote: We have given a list 14 6 7 15 8 9 we have to find 15 in (log n ) times. -- *Thanks and Regards,* Abhinav Kumar Gupta **abhinav@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. -- ++ *Technical Skill is the mastery of complexity, while Creativity is the master of presence of mind. ** * - Morihei Ueshiba ++ *Thanks and Regards,* Abhinav Kumar Gupta *M. Tech. (Software Engineering)* Motilal Nehru National Institute of Technology Allahabad(UP)-211004 +919628358065 abhinav@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] MS: searching problem......help me out...
@ Abhishek : Link that you have provided is for kth min element in the unsorted array, but here i dont know the given value is of at what min position. On Sun, Jun 3, 2012 at 9:06 AM, abhinav gupta abhinav@gmail.com wrote: @Rahul: but for heapify, i need to build heap tree first from the list. which will cost linear traversal of the elements, that will cost O(n). but i need to search it in O(log n) or polylogrithmic complexity of (log n) i.e. (log^2 n). On Sun, Jun 3, 2012 at 8:55 AM, Rahul Kumar Patle patlerahulku...@gmail.com wrote: @abhinav: if you want to search just 15 in log(n) time then you can use the concept of heap tree.. apply one round of heapification (not for all elements but just one time it will be complete in log(n) times), and you will need to swap elements but when you got element 15 you can stop.. although space complexity has increased... you will need one redundant array to use heap operation so that finally you will have original array as it is... Thanks and Regards: Rahul Kumar Patle On Sun, Jun 3, 2012 at 8:31 PM, abhinav gupta abhinav@gmail.comwrote: We have given a list 14 6 7 15 8 9 we have to find 15 in (log n ) times. -- *Thanks and Regards,* Abhinav Kumar Gupta **abhinav@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. -- ++ *Technical Skill is the mastery of complexity, while Creativity is the master of presence of mind. ** * - Morihei Ueshiba ++ *Thanks and Regards,* Abhinav Kumar Gupta *M. Tech. (Software Engineering)* Motilal Nehru National Institute of Technology Allahabad(UP)-211004 +919628358065 abhinav@gmail.com -- ++ *Technical Skill is the mastery of complexity, while Creativity is the master of presence of mind. ** * - Morihei Ueshiba ++ *Thanks and Regards,* Abhinav Kumar Gupta *M. Tech. (Software Engineering)* Motilal Nehru National Institute of Technology Allahabad(UP)-211004 +919628358065 abhinav@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] ARICENT PATTERN
Aricent will not conduct test by itself. They'll have other organization who will conduct the exams. There are many test to be conducted in the time period of 2 or more. i just forgot the time limit limit. But the exams on apptitute, c language/java language either of one, technical test, verbal reasoning, and many more but easy. So just have basic concepts clear, and have strong hand on c... On Wed, Feb 22, 2012 at 10:24 AM, vivek kumar kumarvivek1...@gmail.comwrote: hey guys plzz help me .. ARICENT is coming in my campus.. plzz provide me some info .. Thanks in Advance!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Qualcomm
@vijay can u plz shar some ques which will help us On Fri, Sep 23, 2011 at 5:20 PM, vijay singh vijaysinghb...@gmail.comwrote: Yes, it already visited.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: error in c++ program
@rahul +1 On Thu, Sep 22, 2011 at 11:20 PM, rahul vatsa vatsa.ra...@gmail.com wrote: time is a keyword in c/cpp, change time to any other string in ur code nd it will work. On Thu, Sep 22, 2011 at 12:27 PM, Rajesh Kumar testalgori...@gmail.comwrote: not working by changes provide by you On Thu, Sep 22, 2011 at 9:42 PM, payal gupta gpt.pa...@gmail.com wrote: #includeiostream.h class time { int m; int h; public: void set(int,int); void sum(time,time,time); void display(); }; void time::set(int x,int y) { m=x; h=y; } void time::sum(time t1,time t2,time t3) { m=t1.m+t2.m+t3.m; h=t1.h+t2.h+t3.h; } void time::display(void) { coutminute==mendl; couthours==hendl; } int main() { time a,b,c,d; a.set(1,2); b.set(2,4); c.set(4,8); d.sum(a,b,c); //display a.display(); b.display(); c.display(); d.display(); return 0; } dis does works...chk it out!!! Regards, PAYAL GUPTA, CSE-3rd yr, NIT_B On Thu, Sep 22, 2011 at 9:28 PM, Don dondod...@gmail.com wrote: Give us some help. What is the error? Syntax error? Logic error? Runtime error? On Sep 22, 10:47 am, Rajesh Kumar testalgori...@gmail.com wrote: how we can remove error ? #includeiostream using namespace std; class time { int m; int h; public: void set(int,int); void sum(time,time,time); void display();}; void time::set(int x,int y) { m=x; h=y;} void time::sum(time t1,time t2,time t3) { m=t1.m+t2.m+t3.m; h=t1.h+t2.h+t3.h;} void time::display(void) { coutminute==mendl; couthours==hendl;} int main() { time a,b,c,d; a.set(1,2); b.set(2,4); c.set(4,8); d.sum(a,b,c); //display a.display(); b.display(); c.display(); d.display(); } Regards Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Rajesh Kumar -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C++ Query
Whenver you call copy constructor it has to pass reference parameter beacuse you dont want constructor and destructor to be called twice. Here is the reason why, Suppose u have two objects of a class (let 'a' and 'b'). when u want to copy 'a' into 'b' you want current status of object 'a' to be copied into 'b'.But if it is pass by value then object 'b' will call its own constructor and u wont get the current status of object 'a' into 'b'. And when destructor is called then same piece of allocated memory will be deallocated twice.So it is necessary to have copy constructors as pass by reference. On Mon, Sep 19, 2011 at 10:22 PM, KARTHIKEYAN V.B. algo...@gmail.comwrote: Hi Can anyone say me which is the best hashing tecnicque which can store duplicates and minimize time complexity? Pls reply -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: prime factorization algo
@ Tammana : Can u explain the main logic of haveFactor() function inside Prime.? On Tue, Sep 20, 2011 at 11:28 AM, Tamanna Afroze afroze...@gmail.comwrote: haveFactor() function checked the factor of a number. if a number has a factor other than 1 and itself it isn't prime. Operation function does the rest of the thing, i.e. file reading and file writing and looping throgh the file's input. Does that make sense? Pz let me know. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: prime factorization algo
Dats not the logic Tammana you have to check whether there is any factor in between 2 to number/2; if there is any no then u have to brak at that point. On Tue, Sep 20, 2011 at 12:10 PM, Tamanna Afroze afroze...@gmail.comwrote: I checked whether th enuber s divisible by 2 nd 3 repeatedly... I got no other number which aren't divisible by these two numbers. nd I am done. Tht's all abhinav. Tamanna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: prime factorization algo
Welcum ! I think we need to discuss this 1 in gtalk...I think u still need sm clarification in this 1 On Tue, Sep 20, 2011 at 12:33 PM, Tamanna Afroze afroze...@gmail.comwrote: Thanks to all for the nice suggestions. thanks @abhianv and @siddhart. I will try all the suggestions.. Tamanna -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Question --
I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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] Question --
U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta guptaabhinav...@gmail.comwrote: I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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] Re: prime factorization algo
yup i too think so..Dats y I need to discuss this qs wid u. On Tue, Sep 20, 2011 at 12:36 PM, Tamanna Afroze afroze...@gmail.comwrote: @abhinav I think time complexity will be higher for that algorithm -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Question --
Its because o/p should look like dat.Bt dats simple you can do it by multiplying bits to power(2, i) and adding all expressions.Simple! On Tue, Sep 20, 2011 at 1:09 PM, abhinav gupta guptaabhinav...@gmail.comwrote In the first loop bits are added into the array N and M .I have taken two integers n and m . Caution : declare int N[31]={0}; int M[31]={0}; int n,m,i,j; On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com wrote: U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta guptaabhinav...@gmail.com wrote: I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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. -- 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. -- @ |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]
You can parse the array to find address of max element then you can parse second time leaving that particular address to find second largest element. On Tue, Sep 20, 2011 at 12:36 PM, surender sanke surend...@gmail.comwrote: based on minmax in minimum number of comparisons.. struct pa { int max; int secmax; }; struct pa getmm(int arr[], int low, int high) { struct pa mm = {-1,-1}, mml, mmr; int mid; /* If there is only on element */ if(low == high) { mm.max = arr[low]; mm.secmax = arr[low]; return mm; } /* If there are two elements */ if(high == low + 1) { if(arr[low] arr[high]) { mm.max = arr[low]; mm.secmax = arr[high]; } else { mm.max = arr[high]; mm.secmax = arr[low]; } return mm; } /* If there are more than 2 elements */ mid = (low + high)/2; mml = getmm(arr, low, mid); mmr = getmm(arr, mid+1, high); /* compare maximums of two parts*/ if(mml.max mmr.max) { int temp = mm.max; mm.max = mml.max; if(mmr.maxtemp) mm.secmax = mmr.max; else mm.secmax = temp; } else { int temp = mm.max; mm.max = mmr.max; if(mml.maxtemp) mm.secmax = mml.max; else mm.secmax = temp; } return mm; } surender On Tue, Sep 20, 2011 at 7:48 AM, Sandy sandy.wad...@gmail.com wrote: @Utkarsh: In Yogesh's code assigning a[1] to largest and second_largest in the beginning, -VE case will be handled. On Mon, Sep 19, 2011 at 12:10 PM, asdqwe ayushgoel...@gmail.com wrote: @Yogesh:fails for negative numbers.. (though I am also confused with the ques) On Sep 19, 10:38 am, Yogesh Yadav medu...@gmail.com wrote: current position is index n (say) largest=0; second_largest=0; for(i=1;i=n;i++) { if(a[i]a[n]) { if(a[i]largest) { second_largest=largest; largest=a[i];} elseif(a[i]second_largest) second_largest=a[i]; } } On Mon, Sep 19, 2011 at 2:15 AM, sagar pareek sagarpar...@gmail.com wrote: Give some examples ,i m not getting ur question On Mon, Sep 19, 2011 at 1:45 AM, UTKARSH SRIVASTAV usrivastav...@gmail.com wrote: how to find second largest element than current element in an array given condition that we have to find that second largest element from index 1 to the index of the current element -- *UTKARSH SRIVASTAV CSE-3 B-Tech 3rd Year @MNNIT ALLAHABAD* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **Regards SAGAR PAREEK COMPUTER SCIENCE AND ENGINEERING NIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Sandeep Kumar,* ( Mobile +91-9866507368 *“I believe in smart work, Believe Me”* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- @ |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] Question --
In the first loop bits are added into the array N and M .I have taken two integers n and m . Caution : declare int N[31]={0}; int M[31]={0}; int n,m,i,j; On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com wrote: U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta guptaabhinav...@gmail.com wrote: I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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. -- 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. -- @ |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] Question --
You can also solve the problem by using bit operators. by using| ! . Need sm thinking in dat..No time rite nw! On Tue, Sep 20, 2011 at 1:12 PM, abhinav gupta guptaabhinav...@gmail.comwrote: Its because o/p should look like dat.Bt dats simple you can do it by multiplying bits to power(2, i) and adding all expressions.Simple! On Tue, Sep 20, 2011 at 1:09 PM, abhinav gupta guptaabhinav...@gmail.comwrote In the first loop bits are added into the array N and M .I have taken two integers n and m . Caution : declare int N[31]={0}; int M[31]={0}; int n,m,i,j; On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com wrote: U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta guptaabhinav...@gmail.com wrote: I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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. -- 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. -- @ |3 # ! /\/ @ \./ -- @ |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] Re: Question --
Instead of Num[31] u should tk Num[32] On Tue, Sep 20, 2011 at 2:16 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Hi, When I am running this program, I am getting segmentation fault. Can u plz confirm where is the error. #includestdio.h void main() { int Num[31]={0}; int Mum[31]={0}; int n = 64,m = 7 ,i=0,j=3,k; for(k=31;k=0;k++) { Num[k]=n 1; Mum[k]=m 1; n=n1; m=m1; } for(k=i;k=j;k++) Num[k]=Mum[k]; for(k=0;k=31;k++) printf(%d , Num[k]); } On Tue, Sep 20, 2011 at 1:49 PM, tec technic@gmail.com wrote: mask = (1(j+1))-(1i); n = (n(~mask)) | m; On Sep 20, 3:43 pm, abhinav gupta guptaabhinav...@gmail.com wrote: You can also solve the problem by using bit operators. by using | ! . Need sm thinking in dat..No time rite nw! On Tue, Sep 20, 2011 at 1:12 PM, abhinav gupta guptaabhinav...@gmail.comwrote: Its because o/p should look like dat.Bt dats simple you can do it by multiplying bits to power(2, i) and adding all expressions.Simple! On Tue, Sep 20, 2011 at 1:09 PM, abhinav gupta guptaabhinav...@gmail.comwrote In the first loop bits are added into the array N and M .I have taken two integers n and m . Caution : declare int N[31]={0}; int M[31]={0}; int n,m,i,j; On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com wrote: U can use single walker (from 0 till 31) to convert integers N and M into array of bits, then another walker from i to j to replace values. for(k=31;k=0;k++) { N[k]=n 01; M[k]=m 01; n=1; m=1; } for(k=i;k=j;k++) N[k]=M[k]; On Tue, Sep 20, 2011 at 12:44 PM, abhinav gupta guptaabhinav...@gmail.com wrote: I can tell you the logic.Take two arrays N and M, put their bits in the array. Now using i and j index replace the value of N[j] to n[i] by M[j] to M[i]. On Tue, Sep 20, 2011 at 12:33 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: You are given two 32-bit numbers, N and M, and two bit positions, i and j.Write a method to set all bits between i and j in N equal to M (e.g., M becomes a substring of N located at i and starting at j). EXAMPLE: Input: N = 100, M = 10101, i = 2, j = 6 Output: N = 10001010100 -- 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. -- @ |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. -- 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. -- @ |3 # ! /\/ @ \./ -- @ |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. -- 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
Re: [algogeeks] getting segmentation fault..
What are the values of n and m you are providing??? On Tue, Sep 20, 2011 at 7:02 PM, deependra dsdeependraprat...@gmail.comwrote: long int n,m; cinnm; long int a[n][m]; a[0][0]=1; for(long int i=1;in;i++) a[i][0]=0; for(long int i=1;im;i++) a[0][i]=0; long int z=0; for(long int i=1;in;i++) { for( long int j=1;jm;j++) { a[i][j]=(j*(a[i-1][j]) + a[i-1][j-1] ); z=a[i][j]; } } int mod= z%2; coutmodendl; m getting segmentation fault error at run time in the above code. can any one explain segmentation fault and how to remove it?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- @ |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] getting segmentation fault..
Beacuse memory requird to store (1000 * 1000) bytes is more than stack can hold for the program..Dats y its giving segmentation fault... On Tue, Sep 20, 2011 at 7:29 AM, Deependra pratap singh dsdeependraprat...@gmail.com wrote: for n1000 , m1000... m getting the fault. but lesser than that code is working fine... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] stack
stfu ! On Tue, Sep 20, 2011 at 10:27 AM, prasanth n nprasnt...@gmail.com wrote: In the classic problem of the Towers of Hanoi, you have 3 rods and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending order of size from top to bottom (e.g., each disk sits on top of an even larger one). You have the following constraints: (A) Only one disk can be moved at a time. (B) A disk is slid off the top of one rod onto the next rod. (C) A disk can only be placed on top of a larger disk. Write a program to move the disks from the first rod to the last using Stacks. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: random function
for that u have rand() function in c programming just go through it On Mon, Sep 19, 2011 at 8:42 PM, prasanth n nprasnt...@gmail.com wrote: @don: suppose if give like random(5)- it must give any number between 0 and 5.. On Mon, Sep 19, 2011 at 8:22 PM, Don dondod...@gmail.com wrote: You mean a pseudo-random generator. Without special hardware you won't get a real random generator. Use Mersenne Twister. Don On Sep 19, 9:43 am, prasanth n nprasnt...@gmail.com wrote: anyone give an algorithm of how to generate a random number..probability of occurrence of each no should be the same.. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: random function
int i; i=random(5); int random(int x) { return (rand(x) % 5); } rand() is inbuilt function in c/c++; On Mon, Sep 19, 2011 at 9:24 PM, Don dondod...@gmail.com wrote: The most common way that it works would be that random(n) returns the equivalent of a random integer mod n, so 0=xn. But there is no standard for how they work, so know what you are dealing with. Don On Sep 19, 10:12 am, prasanth n nprasnt...@gmail.com wrote: @don: suppose if give like random(5)- it must give any number between 0 and 5.. On Mon, Sep 19, 2011 at 8:22 PM, Don dondod...@gmail.com wrote: You mean a pseudo-random generator. Without special hardware you won't get a real random generator. Use Mersenne Twister. Don On Sep 19, 9:43 am, prasanth n nprasnt...@gmail.com wrote: anyone give an algorithm of how to generate a random number..probability of occurrence of each no should be the same.. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *prasanth* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: prime factorization algo
@Tammana can u pls give me the logic of the above code ! On Tue, Sep 20, 2011 at 8:35 AM, Tamanna Afroze afroze...@gmail.com wrote: I don't know whether my one is good algorithm or not, but it gives somewhat good output. It is in Java. /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package prime; /** * * @author Tamanna Afroze */ import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.util.StringTokenizer; public class Prime { /** * @param args the command line arguments */ boolean haveFactor(int iNumber){ int iFactors[] = new int[1]; int iIndex = 0; iFactors[iIndex] = 1; iIndex++; iFactors[iIndex] = iNumber; iIndex++; if(iNumber != 2 (iNumber%2)==0){ iFactors[iIndex] = 2; iIndex++; iNumber /=2; if( iNumber != 2 ){ iFactors[iIndex] = iNumber; iIndex++; } int iLoop = 2; if( iNumber != 2 ){ while((iNumber%2) != 1){ iFactors[iIndex] = 2*iLoop; //System.out.println(Here : + iFactors[iIndex]); iIndex++; iNumber /= 2; iFactors[iIndex] = iNumber; iIndex++; iLoop *= 2; } } if(iNumber != 3 (iNumber%3)==0){ iFactors[iIndex] = 3; iIndex++; iNumber /=3; if( iNumber != 3 ){ iFactors[iIndex] = iNumber; iIndex++; } iLoop = 3; if( iNumber != 3 ){ while((iNumber%3) != 1){ iFactors[iIndex] = 3*iLoop; //System.out.println(Here : + iFactors[iIndex]); iIndex++; iNumber /= 3; if( iNumber != 3 ){ iFactors[iIndex] = iNumber; iIndex++; } iLoop *= 3; } } } for(int i =0; iiIndex; i++){ //System.out.println(iFactors[i]); } return true; } else if(iNumber != 3 (iNumber%3)==0){ iFactors[iIndex] = 3; iIndex++; iNumber /=3; if( iNumber != 3 ){ iFactors[iIndex] = iNumber; iIndex++; } int iLoop = 3; while(iNumber != 3 (iNumber%3) != 1){ iFactors[iIndex] = 3*iLoop; //System.out.println(Here : + iFactors[iIndex]); iIndex++; iNumber /= 3; if( iNumber != 3 ){ iFactors[iIndex] = iNumber; iIndex++; } iLoop *= 3; } for(int i =0; iiIndex; i++){ //System.out.println(iFactors[i]); } return true; } else{ return false; } } public void Operation(){ String number,numberofinput,first,second; int index = 0,iFirst = 0,iSecond = 0, iNumberOfInput = 0; try{ File file = new File(input.txt); FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); FileWriter fileWriter = new FileWriter(output.txt); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter); while((number = bufferedReader.readLine()) != null){ if(index == 0){ numberofinput = number; iNumberOfInput = Integer.parseInt(numberofinput); } else{ StringTokenizer tokenizer = new StringTokenizer(number); while(tokenizer.hasMoreTokens()){ first = tokenizer.nextToken(); second = tokenizer.nextToken(); System.out.println(First: + first + Second: + second); iFirst = Integer.parseInt(first); iSecond = Integer.parseInt(second); } System.out.println(Integer Version First: + iFirst + Second: + iSecond); if(iFirst = 1 iSecond = iFirst iSecond = 10 iSecond-iFirst = 10){ for(int k = iFirst; k=iSecond ; k++ ){
Re: [algogeeks] Plz explain the output..........
@yogesh :ya u right. On Sat, Sep 17, 2011 at 11:58 AM, sukran dhawan sukrandha...@gmail.comwrote: x== 9 is not an error !!! it simply returns a non zero value if its true and 0 if its false On Sat, Sep 17, 2011 at 11:39 AM, praveen raj praveen0...@gmail.comwrote: This will show syntax error due to x==9 and otherwise since memory address given at the declarAtion there fore x value will. Change at every assignment , but i m not sure printf will give an error or not . Plz reply. On 17-Sep-2011 1:13 AM, Anshul AGARWAL anshul.agarwa...@gmail.com wrote: #includestdio.h int main() {float t; long x; t=98; printf(%d\n,t); printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); } --- Anshul Agarwal Nit Allahabad Computer Science -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Math Puzzle
Above expression will be (p^3+q^3+r^3)/pqr if a+b+c=0, then a^3+b^3+c^3 = 3abc so, 3pqr/pqr=3 On Thu, Sep 15, 2011 at 10:59 AM, rahul sharma rahul23111...@gmail.comwrote: hw? On Thu, Sep 15, 2011 at 10:57 AM, Tamanna Afroze afroze...@gmail.comwrote: yah the ans is 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Math Puzzle
Shut up...its 3,, On Thu, Sep 15, 2011 at 9:43 AM, Don dondod...@gmail.com wrote: It might be 3, but it doesn't have to be 3. Don On Sep 14, 11:56 pm, NAGARAJAN SIVARAMAN naga4...@gmail.com wrote: if P+Q+R= 0 then P2 /QR + Q2/PR + R2/PQ = ?? how to solve this?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Math Puzzle
u cnt divide a number by 0..that thing is self undrstod On Thu, Sep 15, 2011 at 9:49 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: Don is right if R = 0, P = 1 and Q = -1 then the given expression is UNDEFINED!!! On Thu, Sep 15, 2011 at 10:16 PM, abhinav gupta guptaabhinav...@gmail.com wrote: Shut up...its 3,, On Thu, Sep 15, 2011 at 9:43 AM, Don dondod...@gmail.com wrote: It might be 3, but it doesn't have to be 3. Don On Sep 14, 11:56 pm, NAGARAJAN SIVARAMAN naga4...@gmail.com wrote: if P+Q+R= 0 then P2 /QR + Q2/PR + R2/PQ = ?? how to solve this?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Math Puzzle
dude dats outside the domain of the qs...dont be oversmart. On Thu, Sep 15, 2011 at 9:49 AM, Don dondod...@gmail.com wrote: No, not at all. Here is a trivial counterexample: P = Q = R = 0 Don On Sep 15, 11:46 am, abhinav gupta guptaabhinav...@gmail.com wrote: Shut up...its 3,, On Thu, Sep 15, 2011 at 9:43 AM, Don dondod...@gmail.com wrote: It might be 3, but it doesn't have to be 3. Don On Sep 14, 11:56 pm, NAGARAJAN SIVARAMAN naga4...@gmail.com wrote: if P+Q+R= 0 then P2 /QR + Q2/PR + R2/PQ = ?? how to solve this?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- @ |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 coming to PEC on 19th, any specific pattern for written test
y u all r worried abt MS...open up ur own cmpny... On Thu, Sep 15, 2011 at 10:13 AM, vivek goel vivek.thapar2...@gmail.comwrote: hey ankur. wat's eligibility criteria.. and eligible branches... *mca* is eligible ??. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Interview Questions
Runtime error.. x pointing to unintialised memory..and then initialised,,, On Thu, Sep 15, 2011 at 11:02 AM, SAMMM somnath.nit...@gmail.com wrote: #includecstdio #includeiostream using namespace std; int main() { int w=10; int *p=w; int *x; *x=1000; int *y; *y=100; printf(%d %d %d,*x,*p,*y); return 0; } Wht is the o/p ?? 1)1000 10 100 2)1000 10 10 3)Compilation Error 4)Run Time Error -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Interview Questions
Runtime error On Thu, Sep 15, 2011 at 11:16 AM, SAMMM somnath.nit...@gmail.com wrote: OK Now try this ... #includecstdio #includeiostream using namespace std; int main() { int w=10; int *p=w; int *x; *x=1000; printf(%d %d ,*x,*p); return 0; } Wht is the o/p ?? 1)1000 10 2)1000 100 3)Compilation Error 4)Run Time Error Any Difference ?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Interview Questions
I dont knw man wat d hell is dis? On Thu, Sep 15, 2011 at 11:19 AM, SAMMM somnath.nit...@gmail.com wrote: No check It once more in G++ Compiler -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 the error
file not closed. On Wed, Sep 14, 2011 at 5:56 PM, ravi maggon maggonr...@gmail.com wrote: Something like this was asked in written test of Tally. We had to find the cause why this program crased during run time. File *f; int count=0; if(f=fopen(file.txt,r)) { while(f.get()!=EOF) { count++; } } -- Regards Ravi Maggon B.E. CSE, Final Year Thapar University www.algorithmguru.com *Failure is the opportunity to begin again more intelligently* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] program
Create a structure with num,count(of num) and link parse the array and create nodes (nodes are created with id=num). when the no of nodes == 3 print the nodes data and count. On Wed, Sep 14, 2011 at 5:13 PM, parag khanna khanna.para...@gmail.comwrote: find the frequencies of each alphabet ... n store it in an array corressponding to the ascii value of the alphabet as a index of array ... n store its count ... then sort the array in decreasing order ... and return the top 3 index value of the array in integer form -- 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. -- @ |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: informatica pattern and question of interview
Informatica sucks.I have topped in its offcampus written test still they din call me. On Wed, Sep 14, 2011 at 7:05 PM, ravi maggon maggonr...@gmail.com wrote: In Thapar Criteria was BE CSE and I think MCA was also eligible but for interviews only BE CSE were shortlisted. Package: 7.75 lpa On Wed, Sep 14, 2011 at 6:56 PM, sush57 sushaant...@gmail.com wrote: many i know what's the criteria and package for the company... regards sushaanth BE-computer science Madras Institute of technology On Sep 14, 3:02 pm, Ankit Agarwal ankuagarw...@gmail.com wrote: 2 question numbers are (a1+1)*a2*a3... an = a1*a2*a3...an + a2*a3...an the first term is same... for second term is (a1*a2...an)/(a1) now we have to find max of ( ((a1*a2..an)/a1), (a1*a2...an)/a2) so the question of max becomes min of( a1, a2, a3... an) -- Ankit Agarwal Computer Science Engg. Integrated Dual Degree, V yr Department of Electronics Computer Engineering Indian Institute of Technology Roorkee Ph. no. +91-9580098805 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 B.E. CSE, Final Year Thapar University www.algorithmguru.com *Failure is the opportunity to begin again more intelligently* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: branching factor when BFS and DFS of a graph is same
@siddharam: i think the above example is isomorphic because in isomopic we check for the degree of each node in one tree to the corresponding degree of another tree is present or not . like eg:- p-q--r---s is isomorphic with a--b--c---d On Thu, Sep 15, 2011 at 10:15 AM, siddharam suresh siddharam@gmail.comwrote: as per your example preorder inorder tree1: ab ba tree2: ab ab both are not isomorphic. its easy to extend preorder/DFS to replace two calls to children with for loop considering the graph is N-array tree. Thank you, Sid. On Wed, Sep 14, 2011 at 5:50 PM, bugaboo bharath.sri...@gmail.com wrote: @siddharam: Performing inorder and pre/postorder will still have false positives. Consider 2 trees one with root node a with node b as left child, another tree with root node a with node b as its right child. Anyway, for binary trees, I am aware of a recursive solution to find out similarity or isomorphism. Not sure how this extends for a graph. Always thought a DFS and/or BFS should suffice but apparently not. On Sep 14, 1:43 am, siddharam suresh siddharam@gmail.com wrote: bharath.sriram, perform inorder traversal and peorder/postorder traversal on both tree then compare both the result of two tree. Thank you, Sid. On Wed, Sep 14, 2011 at 10:22 AM, bugaboo bharath.sri...@gmail.com wrote: This brings up another interesting question. How do you find out if 2 graphs are identical? (By identical, I mean exact similarity and NOT isomorphism). Clearly, checking to see if both the DFS traversal and BFS traversal match seem to have false positives as Bharathkumar mentioned. On Sep 13, 12:50 am, bharatkumar bagana bagana.bharatku...@gmail.com wrote: @nishaanth: ex: 1 23 4 5 bfs:12345 dfs:12345 branching factor of this tree is not 1 .. On Tue, Sep 13, 2011 at 9:38 AM, nishaanth nishaant...@gmail.com wrote: yes branching factor should be 1. it can be not equal to 1 only for the penultimate node. by penultimate node i mean whose children are the leaves of the tree. rest all cases it should be 1. On Tue, Sep 13, 2011 at 9:24 AM, siddharam suresh siddharam@gmail.com wrote: cant say if there more than one leaf element still both the algo give same result Thank you, Sid. On Tue, Sep 13, 2011 at 7:52 AM, Sundi sundi...@gmail.com wrote: if the dfs and bfs of a graph is same, does it mean that if the branching factor of a graph is one? abcd example: both dfs abd bfs are same here -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com . To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **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 http://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
Re: [algogeeks] plzzzzzzzz heeeppppp!!!!!!!!!!1
in my opinion developer profile is better than testing...one On Thu, Sep 15, 2011 at 10:57 AM, rahul sharma rahul23111...@gmail.comwrote: hey guys plz tell the difference b/w testing n develp. profile ??? n joing i n testing profile has growth as much as in develpoer???plz tell soon..?should i go in testing profile in lagre industry or in developer in medium scale...plz hepl -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] samsung engineering lab interview..
they'll ask question on mostly on c programming and O.S. on thread, process concepts On Tue, Sep 13, 2011 at 6:46 PM, sourabh jain sourabhjain...@gmail.comwrote: if any one who have selected for samsung ,please tell me the type of ques.that can be ask by tech interview.. -- 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 INDIA SOFTWARE OPERATIONS PVT LTD (SISO)
NIT ALLAHABAD... On Tue, Sep 13, 2011 at 7:45 PM, navneet kumar kumarnavneet@gmail.comwrote: which college?? On Tue, Sep 13, 2011 at 7:41 PM, abhinav gupta abhinav@gmail.comwrote: any one plzz tell me what they will ask in written test... and which type of question...basically?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Department of Information Technology, Indian Institute of Information Technology and Management Gwalior, MP, INDIA Contact no.:+91-9977935740 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] String
First reverse the whole string then reverse the individual words .Simple ! On Mon, Sep 12, 2011 at 11:08 AM, guna sekaran vgun...@gmail.com wrote: String Reverse: input : welcome to all output: all to welcome -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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
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] 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] 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] 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.