[algogeeks] Regarding Jobs in NCR for my cousin
Hi Guys, PFA the resume of Priyanka Lohia. She got placed in TCS(Pune) and has just finished her training. She is looking to make a switch to NCR as soon as possible. Please forward her resume to your respective companies AND/OR to your friends who are in other companies. Do keep me in bcc whenever you forward. Regards, Sandeep Jain Computer Scientist, Adobe Systems, India -- Forwarded message -- From: priyankalohia19 priyankalohi...@gmail.com Date: Tue, Mar 25, 2014 at 11:07 PM Subject: Resume To: sandeep6...@gmail.com Dear sir, Herein I am attaching my resume as asked by you. Please forward it. Thanks and regards, Priyanka Lohia -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. Priyanka_Lohia_resume2.docx Description: application/vnd.openxmlformats-officedocument.wordprocessingml.document
[algogeeks] Adobe India is Hiring
Hi, *Please drop in your resumes to sanj...@adobe.com sanj...@adobe.com. *or *forward this mail *to your respective college/school/office groups. The hiring events have been scheduled to happen on: - 18th January in Bangalore - 25th January in Noida *Position* *Skill* *Exp Range* *Specifications* *Location* Developer JAVA 1-5 yrs B.Tech/M.Tech/M.C.A from Premiere Institutes Noida Developer C/C++ 1-6 yrs B.Tech/M.Tech/M.C.A from Premiere Institutes Noida Testing JAVA/C Whitebox 1-4 yrs B.Tech with Good CGPA Noida Sr. Developer JAVA 10-14 yrs B.Tech / M.Tech/ M.C.A from Premiere Institutes Bangalore Production Specialist Graphic/Web Design 3+ yrs B.Des or M.Des preferable Noida Regards, Sandeep Jain Computer Scientist, Adobe Systems, India -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com.
Re: [algogeeks] what wil be o/p
When you refer to an array name, it is usually interpreted as the address of the first element of the array, (try not calling it pointer to the first element its less confusing that ways) However there are exceptions, 1) When used as a parameter to sizeof, it returns the total number of bytes allocated to that array 2) When address-of operator is used with an array name, it returns the address of the entire array i.e. arr is address of the array(which is numerically the same value as the address of the first element) And when you say sizeof(arr), its similar to sizeof(--some address--) all addresses/pointers have same size irrespective of type to which the pointer points. Regards, Sandeep Jain On Wed, Aug 3, 2011 at 2:42 PM, Arun Vishwanathan aaron.nar...@gmail.comwrote: hi i have a slight confusion..i got the above explanation but i have a doubt as in when u say int arr[5], arr is also the pointer to the first element of the array right?..so size(arr) shudnt be the size of pointer (which is int 4 byte address it holds of the first array element?) ..is it not interpreted this way?and sizeof(arr) looks like address of the pointer itself which also will be int (4 bytes)?? On Wed, Aug 3, 2011 at 5:59 AM, Thavasi Subramanian sktthav...@gmail.comwrote: Ur compiler might have supported 4 bytes to store an integer value sizeof(arr) Since the array is capable of holding 5 integer values at the most total byes required=4*5=20 byte. Now, sizeof(arr) Here you referred the starting address of the array and the addresses are integer values the output is as same as sizeof(int)=4 byte So you get 20 4 as output Hope you got it :) On 3 August 2011 01:45, Anuj kumar anonymize...@gmail.com wrote: #includestdio.h #includeconio.h int main() { int arr[5]; printf(%d %d\n,sizeof(arr),sizeof(arr)); getch(); return 0; } o/p 204 anybody can tell me how 20 is coming plzz -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Thavasi -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Amazon Aptitude questions
1) p q can be checked for null i.e. to handle the condition when malloc fails, otherwise I don't see any thing wrong in it. 3) Only cppp=cp is valid. because any pointer to some const type can be assigned pointer to a non-const type but not vice versa. 4) Different for different OS, on Windows you can use DIR /S *.java 5) 2 *((12/24)*(11/23)) = 11/23 Regards, Sandeep Jain On Wed, Aug 3, 2011 at 10:43 PM, Dave dave_and_da...@juno.com wrote: @Kamakshii: Yes. 11/23 is correct. Whatever the color of the first sock chosen, there are 11 mates in the 23 remaining socks. Dave On Aug 3, 12:01 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote: i think answer for 5th should be 11/23. Am i right? On Wed, Aug 3, 2011 at 10:26 PM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: i think dere is nothing wrong in ques 1.is there any error? On Wed, Aug 3, 2011 at 9:46 PM, cegprakash cegprak...@gmail.com wrote: 2 is pretty easy.. 3: both 5: 6/12 * 6/11 = 3/11 am i right? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- Regards, Kamakshi kamakshi...@gmail.com- 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] Call by reference
I'd say C language is a truly call-by-value language. C++ supports call-by-reference. However in C we can simulate call-by-reference using pointers and address-of operator. Regards, Sandeep Jain On Wed, Aug 3, 2011 at 11:27 PM, NITIN SHARMA coolguyinat...@gmail.comwrote: As we say in C that we do call by reference but i thk call by reference is something different like we do through void pointer in c ++ but it should be call by address in C is it so? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Call by reference
We can say call-by-reference is where changes in formal parameters are reflected in actual parameters. call-by-value is where changes in formal parameters are not reflected in actual parameters. However when u have something like int x=10; f(x); void f(int *p){ *p = 20;} changes in p(formal parameter) won't be reflected in x (actual parameter) However changes in *p are reflected in x, using this the caller's variable is getting modified by the callee. Regards, Sandeep Jain On Thu, Aug 4, 2011 at 10:19 AM, Shashank Jain shashan...@gmail.com wrote: @sandeep, i dint get what do you mean by simulate here, as in an example wud be gud. Shashank Jain Delhi College of Engineering On Wed, Aug 3, 2011 at 11:34 PM, Sandeep Jain sandeep6...@gmail.comwrote: I'd say C language is a truly call-by-value language. C++ supports call-by-reference. However in C we can simulate call-by-reference using pointers and address-of operator. Regards, Sandeep Jain On Wed, Aug 3, 2011 at 11:27 PM, NITIN SHARMA coolguyinat...@gmail.comwrote: As we say in C that we do call by reference but i thk call by reference is something different like we do through void pointer in c ++ but it should be call by address in C is it so? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Re: Is it possible to determine an n-ary tree nodes depth given its index?
Log(N+1) works only for binary tree(lg(N+1). For N-ary tree the formula is a little different. Height of node K = floor( Log N ( (N-1)*K ) ) For binary tree it translates to floor(lgN) Note: I've assumed node index begin from 1 rather than 0 Regards, Sandeep Jain On Mon, Aug 1, 2011 at 5:43 PM, Ram Shankar iitr.go...@gmail.com wrote: If you want to find out the depth of node number N then it would be log (N +1 ).. Explanation: Number of terms at each level follows GP i.e., 1 2 4 8 16 32 . and so on. Number of nodes in tree till depth 'i': Take the sum of GP till 'ith' term. So your task is to find the 'i' such that sum of first 'i' terms of GP is greater than your N. On Mon, Aug 1, 2011 at 4:56 PM, Douglas douglas.han...@gmail.com wrote: Thanks Ankit, but I am not looking for an iterative solution. I am looking for a formula, if possible, rather than a funtion. If I can't find an analytical formula I will revert to an iterative/recursive function. On Aug 1, 11:55 am, ankit sambyal ankitsamb...@gmail.com wrote: @Douglas: Here is my approach: Suppose index is the index given and we have to find its depth .Also the tree is N ary int i=1; while(index 0) { index=index-N^i; i++;} return index; -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Ram -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 output
hi is string constant in both cases... However using p[] allocates memory and copies the string hi in it. On Aug 3, 2011 2:17 AM, Radhika Renganathan radi.coo...@gmail.com wrote: thks ravinder.. ! char p[]=hi char *p = hi are both string constants? On Wed, Aug 3, 2011 at 2:08 AM, Ravinder Kumar ravinde...@gmail.com wrote: ++*p++ This statement changing the value of read only memory of string constant *p=hai friends ; -- *With Regards :* Ravinder Kumar B.Tech Final Year Computer Science and Engineering 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. -- radhika .. :) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] what wil be o/p
Size of an array is calculated as the number of bytes occupied by the array. On Aug 3, 2011 2:02 AM, Ram CEG honest...@gmail.com wrote: array size is 5. so 5*4(size of int)=20. On Wed, Aug 3, 2011 at 1:45 AM, Anuj kumar anonymize...@gmail.com wrote: #includestdio.h #includeconio.h int main() { int arr[5]; printf(%d %d\n,sizeof(arr),sizeof(arr)); getch(); return 0; } o/p 20 4 anybody can tell me how 20 is coming plzz -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Interview ques
Overridden functions and virtual functions are two different concepts... 1) Two functions in the same scope having same but different signatures = Over Loading 2) Two functions having same signatures but one defined in parent class and the other defined in child class == Overriding 3) Virtual functions, allow for run time polymorphism among overridden functions.(only when invoked using pointer) btw I'm still trying to think if preventing function over-riding is possible... Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:13 PM, Ankit Minglani ankit.mingl...@gmail.comwrote: @aditi : in C++ you define a function virtual to let the derived class give its own definition for the same. and in that case the functions are overridden. unlike in JAVA where no virtual keyword is needed .. so if you write the same code as above in java .. that may be referred to as Method overriding .. but not in cpp. On Sun, Jul 31, 2011 at 9:34 AM, aditi garg aditi.garg.6...@gmail.comwrote: @ Ankit: Wat is overriding actually thn? On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain anika.jai...@gmail.comwrote: ohkk.. m so sorry On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @anika: This is not function overriding i think .. you cannot call the f() function of the base class from the derived class object .. what you are doing is creating a object of the derived class and calling the version of f() that belong to derived class B .. ie is the same class object is calling the same class function . correct me if i m wrong . On Sun, Jul 31, 2011 at 8:42 AM, Anika Jain anika.jai...@gmail.comwrote: @ muthu : not declaring tht function as virtual wont save overriding class A { int a; public: void f() {} int f2(){} }; class B:public A { public: void f() { coutabc\n; } }; int main() { B ob; ob.f(); return 0; } in this output is abc.. so overriding occured On Sun, Jul 31, 2011 at 8:41 PM, muthu raj muthura...@gmail.comwrote: Using friend functions we can only invoke already defined private functions. We cannot override or prevent overriding using friend functions. The problem here is how to prevent base class function from being overridden in derived class. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 8:04 AM, Anika Jain anika.jai...@gmail.comwrote: what if we write that function as private of base class.. and make a function in derived class that is friend function of the base class do that it can call tht private function of base.?? On Sun, Jul 31, 2011 at 8:25 PM, muthu raj muthura...@gmail.comwrote: Yeah but there is no equivalent of final keyword in c++.So to prevent member function from overriding in derived class in c++ dont declare the member function as virtual. Then it cannot be overridden in derived class. There is no other way of preventing a member function of base class from being overridden. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:38 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think there is no keyword known as final in c++.maybe u are talking with respect to java On Sun, Jul 31, 2011 at 8:03 PM, muthu raj muthura...@gmail.comwrote: By declaring the function a static final f(). *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal himanshukansal...@gmail.com wrote: sry i thinki misspelled d ques d ques was how will you protect a derived class to override base class's member function in c++ say if there is a function f() in base class then derived should not be able to override f() to provide its own definition. but The function must be accessible in derived class. PS:dont try to make the function private in base class( it will be become inaccessible in derived class). On Sun, Jul 31, 2011 at 7:49 PM, himanshu kansal himanshukansal...@gmail.com wrote: how will you protect a base class to override its member function in derived class say if there is a function f() in base class then derived cannot override f() to provide its own definition. The function must be accessible in derived class. PS:dont try to make the function private in base class( it will be become inaccessible in derived class). -- Regards Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group
Re: [algogeeks] Re: Interview ques
@Pandharinath: Please consider the following e.g. class A { public: void func(){ /* A'simplementation */} }; class B:public A { public: void func(){/* B's implementation*/ } }; What is B's func() doing? Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:36 PM, pandharinath gorde pandharinath.go...@gmail.com wrote: sandeep ur misguiding all things are,. for overriding virtual keyword is used that means virtual functions only overriden. In c++ u require to add virtual keyword. and in java every non static function is by default virtual. On Sun, Jul 31, 2011 at 10:23 PM, Sandeep Jain sandeep6...@gmail.comwrote: Overridden functions and virtual functions are two different concepts... 1) Two functions in the same scope having same but different signatures = Over Loading 2) Two functions having same signatures but one defined in parent class and the other defined in child class == Overriding 3) Virtual functions, allow for run time polymorphism among overridden functions.(only when invoked using pointer) btw I'm still trying to think if preventing function over-riding is possible... Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:13 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @aditi : in C++ you define a function virtual to let the derived class give its own definition for the same. and in that case the functions are overridden. unlike in JAVA where no virtual keyword is needed .. so if you write the same code as above in java .. that may be referred to as Method overriding .. but not in cpp. On Sun, Jul 31, 2011 at 9:34 AM, aditi garg aditi.garg.6...@gmail.comwrote: @ Ankit: Wat is overriding actually thn? On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain anika.jai...@gmail.comwrote: ohkk.. m so sorry On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @anika: This is not function overriding i think .. you cannot call the f() function of the base class from the derived class object .. what you are doing is creating a object of the derived class and calling the version of f() that belong to derived class B .. ie is the same class object is calling the same class function . correct me if i m wrong . On Sun, Jul 31, 2011 at 8:42 AM, Anika Jain anika.jai...@gmail.comwrote: @ muthu : not declaring tht function as virtual wont save overriding class A { int a; public: void f() {} int f2(){} }; class B:public A { public: void f() { coutabc\n; } }; int main() { B ob; ob.f(); return 0; } in this output is abc.. so overriding occured On Sun, Jul 31, 2011 at 8:41 PM, muthu raj muthura...@gmail.comwrote: Using friend functions we can only invoke already defined private functions. We cannot override or prevent overriding using friend functions. The problem here is how to prevent base class function from being overridden in derived class. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 8:04 AM, Anika Jain anika.jai...@gmail.com wrote: what if we write that function as private of base class.. and make a function in derived class that is friend function of the base class do that it can call tht private function of base.?? On Sun, Jul 31, 2011 at 8:25 PM, muthu raj muthura...@gmail.comwrote: Yeah but there is no equivalent of final keyword in c++.So to prevent member function from overriding in derived class in c++ dont declare the member function as virtual. Then it cannot be overridden in derived class. There is no other way of preventing a member function of base class from being overridden. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:38 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think there is no keyword known as final in c++.maybe u are talking with respect to java On Sun, Jul 31, 2011 at 8:03 PM, muthu raj muthura...@gmail.com wrote: By declaring the function a static final f(). *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal himanshukansal...@gmail.com wrote: sry i thinki misspelled d ques d ques was how will you protect a derived class to override base class's member function in c++ say if there is a function f() in base class then derived should not be able to override f() to provide its own definition. but The function must be accessible in derived class. PS:dont try to make the function private in base class( it will be become inaccessible in derived class). On Sun, Jul 31, 2011 at 7:49 PM, himanshu kansal himanshukansal...@gmail.com wrote: how will you protect a base class to override its member function in derived class say if there is a function f() in base class then derived cannot override f() to provide its own definition. The function must be accessible
Re: [algogeeks] Re: Interview ques
Yup.. actually we never get to make proper usage of overridden functions without making them virtual. Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:55 PM, muthu raj muthura...@gmail.com wrote: Function overriding gains significance only when functions are declared virtual. Otherwise Overriding does not serve any purpose. the main idea behind virtual functions and method overloading is to implement Dynamic Polymorphism i.e decide which version of function(base or derived) to be invoked during runtime. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 10:22 AM, Sandeep Jain sandeep6...@gmail.comwrote: @Pandharinath: Please consider the following e.g. class A { public: void func(){ /* A'simplementation */} }; class B:public A { public: void func(){/* B's implementation*/ } }; What is B's func() doing? Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:36 PM, pandharinath gorde pandharinath.go...@gmail.com wrote: sandeep ur misguiding all things are,. for overriding virtual keyword is used that means virtual functions only overriden. In c++ u require to add virtual keyword. and in java every non static function is by default virtual. On Sun, Jul 31, 2011 at 10:23 PM, Sandeep Jain sandeep6...@gmail.comwrote: Overridden functions and virtual functions are two different concepts... 1) Two functions in the same scope having same but different signatures = Over Loading 2) Two functions having same signatures but one defined in parent class and the other defined in child class == Overriding 3) Virtual functions, allow for run time polymorphism among overridden functions.(only when invoked using pointer) btw I'm still trying to think if preventing function over-riding is possible... Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:13 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @aditi : in C++ you define a function virtual to let the derived class give its own definition for the same. and in that case the functions are overridden. unlike in JAVA where no virtual keyword is needed .. so if you write the same code as above in java .. that may be referred to as Method overriding .. but not in cpp. On Sun, Jul 31, 2011 at 9:34 AM, aditi garg aditi.garg.6...@gmail.com wrote: @ Ankit: Wat is overriding actually thn? On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain anika.jai...@gmail.comwrote: ohkk.. m so sorry On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @anika: This is not function overriding i think .. you cannot call the f() function of the base class from the derived class object .. what you are doing is creating a object of the derived class and calling the version of f() that belong to derived class B .. ie is the same class object is calling the same class function . correct me if i m wrong . On Sun, Jul 31, 2011 at 8:42 AM, Anika Jain anika.jai...@gmail.com wrote: @ muthu : not declaring tht function as virtual wont save overriding class A { int a; public: void f() {} int f2(){} }; class B:public A { public: void f() { coutabc\n; } }; int main() { B ob; ob.f(); return 0; } in this output is abc.. so overriding occured On Sun, Jul 31, 2011 at 8:41 PM, muthu raj muthura...@gmail.comwrote: Using friend functions we can only invoke already defined private functions. We cannot override or prevent overriding using friend functions. The problem here is how to prevent base class function from being overridden in derived class. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 8:04 AM, Anika Jain anika.jai...@gmail.com wrote: what if we write that function as private of base class.. and make a function in derived class that is friend function of the base class do that it can call tht private function of base.?? On Sun, Jul 31, 2011 at 8:25 PM, muthu raj muthura...@gmail.com wrote: Yeah but there is no equivalent of final keyword in c++.So to prevent member function from overriding in derived class in c++ dont declare the member function as virtual. Then it cannot be overridden in derived class. There is no other way of preventing a member function of base class from being overridden. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:38 AM, himanshu kansal himanshukansal...@gmail.com wrote: i think there is no keyword known as final in c++.maybe u are talking with respect to java On Sun, Jul 31, 2011 at 8:03 PM, muthu raj muthura...@gmail.com wrote: By declaring the function a static final f(). *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 7:28 AM, himanshu kansal himanshukansal...@gmail.com wrote: sry i thinki misspelled d ques d ques was how will you protect a derived class
Re: [algogeeks] Re: Interview ques
So, what you are saying is Overriding == virtual functions As per this logic: Simply remove the virtual keyword from the function definition in base class, which would mean they will not be overridden by the derived class. And this answers the original question asked in this thread. Regards, Sandeep Jain PS: I remember having interview questions such as, What happens when you override a virtual function? On Sun, Jul 31, 2011 at 11:51 PM, pandharinath gorde pandharinath.go...@gmail.com wrote: and one more thing B is containg A's object inside which conatin noramlly vptr if any virtual fun in A otherwise data member of it So A::Func() and *B::func() * are diifent u require to access A's func() by A::func() in B. chk it by coding also and debugging On Sun, Jul 31, 2011 at 11:46 PM, pandharinath gorde pandharinath.go...@gmail.com wrote: @sandeep @sandeep class A { public: void func(){ /* A'simplementation */} }; class B:public A { public: void func(){/* B's implementation*/ } }; whatever is happening in this one is not overriding and not overloading For overloading function should be is same scope but see below both func are in different scope void A::func(); void B::func(); For fun overriding vptr table is used for entry in vptr table, for entry in vptr table function should be virtual. On Sun, Jul 31, 2011 at 11:42 PM, Amol Sharma amolsharm...@gmail.comwrote: ok...i agree with the explanation given by sandeep regarding overloading,overriding and virtual fns. but i am not able to think if there exist any method to do the required task !! -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 10:59 PM, coder dumca coder.du...@gmail.comwrote: @ muthuraj see here display in derived is overriding display() in base and also has purpose class A { int a; public : void dispaly() { couta; } }; class B:public A { int b; public : void display() { A::dispaly(); coutb; } }; On Sun, Jul 31, 2011 at 10:25 AM, muthu raj muthura...@gmail.comwrote: Function overriding gains significance only when functions are declared virtual. Otherwise Overriding does not serve any purpose. the main idea behind virtual functions and method overloading is to implement Dynamic Polymorphism i.e decide which version of function(base or derived) to be invoked during runtime. *Muthuraj R IV th Year , ISE PESIT , Bangalore* On Sun, Jul 31, 2011 at 10:22 AM, Sandeep Jain sandeep6...@gmail.com wrote: @Pandharinath: Please consider the following e.g. class A { public: void func(){ /* A'simplementation */} }; class B:public A { public: void func(){/* B's implementation*/ } }; What is B's func() doing? Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:36 PM, pandharinath gorde pandharinath.go...@gmail.com wrote: sandeep ur misguiding all things are,. for overriding virtual keyword is used that means virtual functions only overriden. In c++ u require to add virtual keyword. and in java every non static function is by default virtual. On Sun, Jul 31, 2011 at 10:23 PM, Sandeep Jain sandeep6...@gmail.com wrote: Overridden functions and virtual functions are two different concepts... 1) Two functions in the same scope having same but different signatures = Over Loading 2) Two functions having same signatures but one defined in parent class and the other defined in child class == Overriding 3) Virtual functions, allow for run time polymorphism among overridden functions.(only when invoked using pointer) btw I'm still trying to think if preventing function over-riding is possible... Regards, Sandeep Jain On Sun, Jul 31, 2011 at 10:13 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @aditi : in C++ you define a function virtual to let the derived class give its own definition for the same. and in that case the functions are overridden. unlike in JAVA where no virtual keyword is needed .. so if you write the same code as above in java .. that may be referred to as Method overriding .. but not in cpp. On Sun, Jul 31, 2011 at 9:34 AM, aditi garg aditi.garg.6...@gmail.com wrote: @ Ankit: Wat is overriding actually thn? On Sun, Jul 31, 2011 at 9:58 PM, Anika Jain anika.jai...@gmail.com wrote: ohkk.. m so sorry On Sun, Jul 31, 2011 at 9:41 PM, Ankit Minglani ankit.mingl...@gmail.com wrote: @anika: This is not function overriding i think .. you cannot call the f() function of the base class from the derived class object .. what you are doing is creating a object of the derived class and calling the version of f() that belong to derived class B .. ie is the same class object is calling the same class function . correct me if i m wrong . On Sun, Jul 31, 2011 at 8:42 AM, Anika Jain anika.jai...@gmail.com wrote: @ muthu : not declaring tht function as virtual wont save overriding
Re: [algogeeks] Re: Amazon- Most Common Three sequence
This is similar to Frequent Pattern algorithms studied under data mining. You may refer FP Growth tree. Regards, Sandeep Jain On Mon, Jul 25, 2011 at 3:46 PM, sravanreddy001 sravanreddy...@gmail.comwrote: how about traversing the list once.. but.. looking at the user level. now.. we make a hashtable kind of entry.. adding 1 to the count for each of the combinations that comes in. if the logs are tricky.. like.. joe's 3rd page comes after sam's 1st page in the log. then.. the logs first have to be arranged in as per the user.. which takes some time for sorting.. and then following the above approach. -- 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/-/SimPOhEme6kJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 output
This should help you out. http://msdn.microsoft.com/en-us/library/f90831hc.aspx Regards, Sandeep Jain On Fri, Jul 15, 2011 at 11:15 AM, abhishek kumar mailatabhishekgu...@gmail.com wrote: @Sandeep Jain sandeep, please be more clear about lvalue rvalue assignment. -- 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/-/42bIvZNRPRYJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 output
Yup... *In C++* Pre-Increment Pre-Decrement return LValue Post-Increment Post-Decrement return RValue *In C* Pre-Increment Pre-Decrement return RValue Post-Increment Post-Decrement return RValue Regards, Sandeep Jain On Thu, Jul 14, 2011 at 4:08 PM, T3rminal piyush@gmail.com wrote: @ all This code is error in C as pre-increment operator in C returns rvalue but it will work fine in C++ as it returns lvalue in C++ which is required as LHS of assignment operator -- 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/-/ocLDsmszdZoJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 output
@ALL: Turbo C is one of the most pathetic compilers I've seen. It has tremendous skills to ruin your concepts. Regards, Sandeep Jain On Fri, Jul 15, 2011 at 10:35 AM, abhishek kumar mailatabhishekgu...@gmail.com wrote: @Gaurav Jain in turbo c++,(this was a c program). it is giving output 36. -- 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/-/uuO64oNqACMJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Minimum/Maximum Sum path in A Binary Tree
If we need to find the maximum sum the above code is fine. But from the subject it appears we need to print the path, which contains the maximum sum, as well. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 8:01 PM, Piyush Kapoor pkjee2...@gmail.com wrote: I agree with anonymous procrastination On Wed, Jul 13, 2011 at 12:38 PM, anonymous procrastination opamp1...@gmail.com wrote: int maxsum(NODEPTR root) { if(root==NULL) return 0; else return MAX(maxsum(root-left),maxsum(root-right))+root-data; } This should work. Please comment. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Minimum/Maximum Sum path in A Binary Tree
@Vaibhav: How do you intend to populate the array? Regards, Sandeep Jain On Wed, Jul 13, 2011 at 9:45 PM, vaibhav shukla vaibhav200...@gmail.comwrote: @sandeep : then can we just store the nodes in the array.. and as soon as we reach the leaf ,we print the array . what say ? On Wed, Jul 13, 2011 at 8:08 PM, Sandeep Jain sandeep6...@gmail.comwrote: If we need to find the maximum sum the above code is fine. But from the subject it appears we need to print the path, which contains the maximum sum, as well. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 8:01 PM, Piyush Kapoor pkjee2...@gmail.comwrote: I agree with anonymous procrastination On Wed, Jul 13, 2011 at 12:38 PM, anonymous procrastination opamp1...@gmail.com wrote: int maxsum(NODEPTR root) { if(root==NULL) return 0; else return MAX(maxsum(root-left),maxsum(root-right))+root-data; } This should work. Please comment. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Improve upon O(m^2)
@Ravindra: Since both the array contain m elements, you can assume that all elements lie from index [0] to index [m-1] However, because in your example we can consider 0, as a valid value of the sorted array. PS: Still, if you are suggesting that we should not consider 0 as a value. Then you can perform an compaction operation on 2nd array. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:18 PM, ravindra patel ravindra.it...@gmail.comwrote: @Bittu, Vaibhav Can you please illustrate your algo for below arrays. Array1 - {1, 3, 5, 7} Array2 - {0,0,0,2,0,4,6,8} Thanks, - Ravindra On Wed, Jul 13, 2011 at 9:47 PM, vaibhav shukla vaibhav200...@gmail.comwrote: start from the end of both the arrays... and try simple merge process not from the start but from where the last element is... and keep inserting the greater element at the end of the larger array. On Wed, Jul 13, 2011 at 8:41 PM, bittu shashank7andr...@gmail.comwrote: @dumanshu check it Algo is simply start putting elemnt in bigger array by comparing then from last logic is same as merge part of merg sort :) void merge(int[] a, int[] b, int n, int m) { int k = m + n - 1; // Index of last location of array b int i = n - 1; // Index of last element in array b int j = m - 1; // Index of last element in array a // Start comparing from the last element and merge a and b while (i = 0 j = 0) { if (a[i] b[j]) { a[k--] = a[i--]; } else { a[k--] = b[j--]; } } while (j = 0) { a[k--] = b[j--]; } //no need to do for a array as its alraedy filled in B array :) } Time O(N) Thanks Shashank Mani Narayan Computer Science Engg. Birla Institute of Technlogy Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Precedence of operators
Because ++i returns non -ve i.e. true, and since || operator exhibits short circuit. There was no need to evaluate j++ k++ Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:21 PM, shady sinv...@gmail.com wrote: has higher precedence than || but why does j and k didn't increase after the statement l= ++i || j++ k++; got executed ? On Wed, Jul 13, 2011 at 10:07 PM, sagar pareek sagarpar...@gmail.comwrote: For more clarificationtry this :- int i=1,j=1,k=1,l; l= ++i || j++ k++; printf(%d %d %d %d,i,j,k,l); o/p will be 2 1 1 1 because as vaibhav wrote the equation evaluate as l= ++i || (j++ k++); only ++i evaluate not other two increments :) On Sun, Jul 10, 2011 at 11:31 PM, rShetty rajeevr...@gmail.com wrote: Got it Thanks . On Jul 10, 10:40 pm, vaibhav shukla vaibhav200...@gmail.com wrote: associativity comes into play when operators are of same precedence. On Sun, Jul 10, 2011 at 11:08 PM, vaibhav shukla vaibhav200...@gmail.comwrote: has higher precedence than || the expression is evaluated as z=j || ( k i ); hence the output i.e 1 ;) On Sun, Jul 10, 2011 at 11:06 PM, rShetty rajeevr...@gmail.com wrote: #includestdio.h int main() { int i=0,j=1,k=1,z=0; z = j || k i ; printf(%d,z); return 0; } The output is 1 for the above program . But according to associativity of logical operators , the evaluation should be from left to right , But is it taking from right to left ? What is the exact concept for the program behavior above? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- **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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Improve upon O(m^2)
@Ravindra: Dude, so far in this question, I've always seen 2nd array to contain all elements on one side of the array, as this avoids any constraints on the values allowed within the array. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:53 PM, ravindra patel ravindra.it...@gmail.comwrote: @Sandeep, If we do compaction then it becomes the same algo what Ankit suggested earlier. Compaction will require 2 pass on the bigger array. Can we do it in a single pass? P.S. - I can not say for sure if doing it in one pass is really feasible. I am still trying to work it out :-). Thanks, - Ravindra On Wed, Jul 13, 2011 at 10:22 PM, Sandeep Jain sandeep6...@gmail.comwrote: @Ravindra: Since both the array contain m elements, you can assume that all elements lie from index [0] to index [m-1] However, because in your example we can consider 0, as a valid value of the sorted array. PS: Still, if you are suggesting that we should not consider 0 as a value. Then you can perform an compaction operation on 2nd array. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:18 PM, ravindra patel ravindra.it...@gmail.com wrote: @Bittu, Vaibhav Can you please illustrate your algo for below arrays. Array1 - {1, 3, 5, 7} Array2 - {0,0,0,2,0,4,6,8} Thanks, - Ravindra On Wed, Jul 13, 2011 at 9:47 PM, vaibhav shukla vaibhav200...@gmail.com wrote: start from the end of both the arrays... and try simple merge process not from the start but from where the last element is... and keep inserting the greater element at the end of the larger array. On Wed, Jul 13, 2011 at 8:41 PM, bittu shashank7andr...@gmail.comwrote: @dumanshu check it Algo is simply start putting elemnt in bigger array by comparing then from last logic is same as merge part of merg sort :) void merge(int[] a, int[] b, int n, int m) { int k = m + n - 1; // Index of last location of array b int i = n - 1; // Index of last element in array b int j = m - 1; // Index of last element in array a // Start comparing from the last element and merge a and b while (i = 0 j = 0) { if (a[i] b[j]) { a[k--] = a[i--]; } else { a[k--] = b[j--]; } } while (j = 0) { a[k--] = b[j--]; } //no need to do for a array as its alraedy filled in B array :) } Time O(N) Thanks Shashank Mani Narayan Computer Science Engg. Birla Institute of Technlogy Mesra -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] c code bst mirror prob
Your swap function is not correct. You are swapping p q locally. Since you are using c++, make the following changes. void swap*(node* p,node* q)* { node *t; t=p; p=q; q=t; } Regards, Sandeep Jain On Thu, Jul 14, 2011 at 1:45 AM, Anika Jain anika.jai...@gmail.com wrote: n sorry i have wriiten it in c++ not c.. On Thu, Jul 14, 2011 at 1:44 AM, Anika Jain anika.jai...@gmail.comwrote: by using swap function is pointer to a pointer used then?? On Thu, Jul 14, 2011 at 1:36 AM, Piyush Kapoor pkjee2...@gmail.comwrote: u need a pointer to a pointer to swap the pointers... On Thu, Jul 14, 2011 at 1:21 AM, Anika Jain anika.jai...@gmail.comwrote: can some body tell me that: void swap(node *p,node *q) { node *t; t=p; p=q; q=t; } void mirror(node *p) { if (p==NULL) return; else {mirror(p-r); mirror(p-l); swap(p-r,p-l); } } in this the swapping is occuring but if i do : void mirror(node *p) { if (p==NULL) return; else {mirror(p-r); mirror(p-l); node *t; t=p-r; p-r=p-l; p-l=t; } } here it is not getting done .. why?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] microsoft ques
If we just have to give the depth as in count then, I believe we can use stack to push/pop curly braces. While maintaining the maximum depth observed And if we have to display/print line numbers or code itself, then converting the code in a tree structure should help. Each node can contain the line/col position of starting/closing braces. Each node will have its nested braces as child nodes. PS: In either case make sure you ignore comments and strings literals Regards, Sandeep Jain On Tue, Jul 12, 2011 at 4:43 PM, shilpa gupta shilpagupta...@gmail.comwrote: Write down the c code for finding out the maximum scope depth in a c code. A scope depth is increased by one with every '{' and decreases by one with every '}' -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] output
*const* in C++ is not exactly same as *final* in java. SO unlike java adding the keyword const to a function does not affect overriding. Infact, adding in C++ const functions == that they will not modify any member of the class. non-const functions cannot be invoked by const objects. Try making object 'a' as const i.e. const x a; and then invoke f(), it should invoke the correct version. Note that C++ allows function overloading based on const-ness. Refer (Const function section) http://www.cprogramming.com/tutorial/const_correctness.html Also, subscript operators generally come in pairs, Refer http://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-13.10 http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12 Regards, Sandeep Jain On Tue, Jul 12, 2011 at 10:09 PM, dheeraj tyagi dheeraj2...@gmail.comwrote: const means that it cannot be overloaded..i think due to that this is happening. On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.comwrote: #includeiostream using namespace std; class x{ public: x() {} int func() const{ coutit is const function\n; } int func() { coutit is simple functin\n; } }; int main() { x a; a.func(); return 0; } why cann't it take const function? explain it -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- With regards Dheeraj Tyagi 8197218001 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] output
*Case 1:* x g() { x b; *// Constructor* b.print(); return b; *// Optimized away* } int main() { x b; *// Constructor* x t=g(); *// Optimized away* } *Case 2:* x g(x b) *// Copy constructor* { b.print(); return b; *// Return by value destructor* } int main() { x b; *// Constructor* x t=g(b); *// Pass by value and return by value* } This has to do with optimization of local objects done by the compiler. Since in case 1 a local was to created/returned to initialize another local, so what the compiler does is that it creates object 'b' at a memory location where object t was to be created. (You may think of the compiler internally using placement new) Different compilers have different techniques of optimization. Refer http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.10 And as per the above link this should not work on MS C++.NET Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:35 AM, pawan yadav pawan1991ya...@gmail.comwrote: @rahul thanks for reply o/p (of 1st program) : constructor constructor print statement destructor destructor here copy constructor is not called ... that's why i have posted this program On Tue, Jul 12, 2011 at 10:42 PM, rahul rahulr...@gmail.com wrote: Hi, In first program,it will call copy constructor once, while returning object by value. In 2nd program it will call copy constructor twice, once when u pass an object to function by value, and 2nd time when you return an object by value from function. Thanks. On Tue, Jul 12, 2011 at 11:52 PM, segfault pawan1991ya...@gmail.comwrote: #includeiostream using namespace std; class x{ int p; public: x(){coutconstructor\n;} x(const x y) { coutcopy constructor\n; } ~x() { cout destructor\n; } void print() { coutprint statement\n; } }; x g() { x b; b.print(); return b; } int main() { x b; x t=g(); } #includeiostream using namespace std; class x{ int p; public: x(){coutconstructor\n;} x(const x y) { coutcopy constructor\n; } ~x() { cout destructor\n; } void print() { coutprint statement\n; } }; x g(x b) { b.print(); return b; } int main() { x b; x t=g(b); } why first one is not calling copy constructor in function g() while returning from it but second one is calling copy constructor in function g() while returning from it? in both program inside g() b is local but why giving different result. bruce ackel page number:467 please explain it. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: questions related to C
Try it. It should work fine. Regards, Sandeep Jain On Wed, Jul 13, 2011 at 10:40 AM, Aniket Dutta aniketdutt...@gmail.comwrote: what about a generic swap function which works for structures also? On Wed, Jul 13, 2011 at 2:23 AM, Don dondod...@gmail.com wrote: To check for overflow, use condition: if (b (maxuint-a)) return error; Where maxuint is the largest value which can be stored in an unsigned integer. Don On Jul 8, 5:50 am, vikas mehta...@gmail.com wrote: Q1 - write a generic macro to swap two values (int,float,double,pointers as well ) Q2 - Implement your own malloc() and free() function Q3 - Two unsigned ints given a, b you have add these numbers and return the sum ...Make sure in case of overflow return 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Yahoo Question
Option A: Works on all data types Option B: Works on numerical data, (best on integral data) but leads to overflow problem Option C: XOR would solve the problem of overflow, but afaik bitwise operators work on integral data Regards, Sandeep Jain On Mon, Jul 11, 2011 at 12:03 PM, sachin sharma sachin.bles...@gmail.comwrote: @vaibhav Overflow problem in case of big number in option b. the best and simple one is option a. Best Wishes Sachin Sharma | Software Trainee | Information Mosaic New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne | e-mail: sachinku...@informationmosaic.com Web:www.informationmosaic.comhttp://www.informationmosaic.com/ | t: www.twitter.com/infomosaic Winner 2009 Banking Technology Readers' Choice Award for Best Corporate Actions Automation Solution -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: remove duplicate chars in a string without using extra memory
Anika, look closely. Your code takes O(N^2) instead of O(N) Regards, Sandeep Jain On Mon, Jul 11, 2011 at 5:15 PM, Anika Jain anika.jai...@gmail.com wrote: YA.. N YA M USING 2 VARIABLES.. IS IT ALLOWED? On Mon, Jul 11, 2011 at 4:58 PM, saurabh singh saurab...@gmail.comwrote: A similar solution has been proposed above if I am not misinterpreting the code,You are creating a bitmap from the 2 variables.? On Mon, Jul 11, 2011 at 4:55 PM, Anika Jain anika.jai...@gmail.comwrote: A c code for this is: int main() { int a[2] = {0}; char str[50]; int i,ind=0; scanf (%s, str); for(i=0;istrlen(str);i++) { if(str[i]='a' str[i]='z') { if(!(a[0] 1str[i]-'a')) { a[0] = a[0] | 1str[i]-'a'; str[ind]=str[i]; ind++; } } else if(str[i]='A' str[i]='Z') { if(!(a[1] 1str[i]-'a')) { a[1] = a[1] | 1str[i]-'a'; str[ind]=str[i]; ind++; } } } str[ind]='\0'; printf(%s\n,str); return 0; } is it fine 2 use 2 integers for this? or not allowed?? On Mon, Jul 11, 2011 at 9:35 AM, Yaw yawbrob...@gmail.com wrote: Quite new to java what do you think of mine? import java.util.*; public class RemoveDuplicates { public static void main(String[] args){ while(true) { System.out.println(Enter String); Scanner input = new Scanner(System.in); String str = input.nextLine(); System.out.println(RemoveDup(str)); } } public static String RemoveDup(String str){ str = str.toLowerCase(); String temp = ; for (int i=0; istr.length(); i++){ if (!temp.contains(Character.toString(str.charAt(i{ temp+=str.charAt(i); } } return temp; } } -- 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/-/vD7vwu7Fz_oJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 doubt
Sunny is right. Try to observe the binary representation, and you shall get your answers. Regards, Sandeep Jain On Mon, Jul 11, 2011 at 5:54 PM, Piyush Kapoor pkjee2...@gmail.com wrote: Can anybody give a full explanation On Sat, Jul 9, 2011 at 10:49 PM, sunny agrawal sunny816.i...@gmail.comwrote: try to find out the binary representation of float value 5.2 On Sat, Jul 9, 2011 at 10:46 PM, Sangeeta sangeeta15...@gmail.comwrote: int main(){ int i; float a=5.2; char *ptr; ptr=(char *)a; for(i=0;i=3;i++) printf(%d ,*ptr++); } output: 102 102 -90 64.explain? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Sunny Aggrawal B-Tech IV year,CSI Indian Institute Of Technology,Roorkee -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Regards,* *Piyush Kapoor,* *CSE-IT-BHU* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: remove duplicate chars in a string without using extra memory
Hint: What is the time complexity of strlen?? Regards, Sandeep Jain On Mon, Jul 11, 2011 at 8:00 PM, Anika Jain anika.jai...@gmail.com wrote: @sandeep sir: i didnt get it how is it takin o(n^2) ?? On Mon, Jul 11, 2011 at 5:18 PM, Sandeep Jain sandeep6...@gmail.comwrote: Anika, look closely. Your code takes O(N^2) instead of O(N) Regards, Sandeep Jain On Mon, Jul 11, 2011 at 5:15 PM, Anika Jain anika.jai...@gmail.comwrote: YA.. N YA M USING 2 VARIABLES.. IS IT ALLOWED? On Mon, Jul 11, 2011 at 4:58 PM, saurabh singh saurab...@gmail.comwrote: A similar solution has been proposed above if I am not misinterpreting the code,You are creating a bitmap from the 2 variables.? On Mon, Jul 11, 2011 at 4:55 PM, Anika Jain anika.jai...@gmail.comwrote: A c code for this is: int main() { int a[2] = {0}; char str[50]; int i,ind=0; scanf (%s, str); for(i=0;istrlen(str);i++) { if(str[i]='a' str[i]='z') { if(!(a[0] 1str[i]-'a')) { a[0] = a[0] | 1str[i]-'a'; str[ind]=str[i]; ind++; } } else if(str[i]='A' str[i]='Z') { if(!(a[1] 1str[i]-'a')) { a[1] = a[1] | 1str[i]-'a'; str[ind]=str[i]; ind++; } } } str[ind]='\0'; printf(%s\n,str); return 0; } is it fine 2 use 2 integers for this? or not allowed?? On Mon, Jul 11, 2011 at 9:35 AM, Yaw yawbrob...@gmail.com wrote: Quite new to java what do you think of mine? import java.util.*; public class RemoveDuplicates { public static void main(String[] args){ while(true) { System.out.println(Enter String); Scanner input = new Scanner(System.in); String str = input.nextLine(); System.out.println(RemoveDup(str)); } } public static String RemoveDup(String str){ str = str.toLowerCase(); String temp = ; for (int i=0; istr.length(); i++){ if (!temp.contains(Character.toString(str.charAt(i{ temp+=str.charAt(i); } } return temp; } } -- 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/-/vD7vwu7Fz_oJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] C OUTPUT HELP
I'll put it in simple words, when printf is executed, it expects the arguments to be of the same type and in the same order as they appear in the format string. Otherwise, it starts to exhibit random behavior whenever a first mismatch occurs. Regards, Sandeep Jain On Tue, Jul 12, 2011 at 1:32 AM, nicks crazy.logic.k...@gmail.com wrote: @sandeep u mean whenever printf will demand for %f then it will print 2.0.is it random behavior or always going to happen ?? anyone else having better idea regarding 1st and 2nd problem... On Mon, Jul 11, 2011 at 9:51 AM, Sandeep Jain sandeep6...@gmail.comwrote: TurboC has many flaws, one of the simplest examples would be char *p; scanf(%s, p); In gcc/g++ this will surely lead to segmentation fault as memory has not been allocated. Whereas in TC it will execute fine in most of the cases. Infact this will crash when your code is really large. As for input, 2 will automatically be treated as 2.0 when scanf demands a floating value. However, if you enter characters in place of numbers or vice versa. You may experience weird behavior. Regards, Sandeep Jain On Mon, Jul 11, 2011 at 9:37 AM, nicks crazy.logic.k...@gmail.comwrote: @sandeep,kamakshiithanks both...your replies were really helpfuli understood my fault in 3,4,5...they are clea now..but i am still stuck with problem 1 and 2 @sandeepwhat if i am using turbo C...though i am using gcc on terminal in my linux system. moreover acc. t KR printf uses it's first argument to decide how many arguments follow and what their types are. it will get confused,and you will get wrong answers,if there are not enough arguments or if they are the wrong type it's fine it will give the wrong answer then it's only the value we provide in input ??? @kamakshii...can explain your point related to macro in detail.is it related to linking or something which is done after creating object file... On Mon, Jul 11, 2011 at 1:37 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: probelm 5:It must be giving runtime error not segmentation fault coz it is an infinite recursion On Mon, Jul 11, 2011 at 1:09 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: for the first question...it will take #ifdef getchar to be '1' only when it is defined as a MACRO in your program..if u dont define macro it will not take it into consideration even if it is defined in header file. On Mon, Jul 11, 2011 at 12:38 AM, nicks crazy.logic.k...@gmail.comwrote: Someone please help me in understanding the following output - Problem *1.* #includestdio.h #ifdef getchar //this expression is evaluated to zero.why is so happening ??getchar is defined as macro in stdio.h.i mean else part shouldn't be executed which is happening #undef getchar #else #define getchar scanf(%c,ch); #endif main() { char ch; int c; c=getchar; printf(%d,c); } *OUTPUT- 1* * * * * *2.* #includestdio.h void main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%ld\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); } *OUTPUT(INPUT IS 2) -* *2* *0* *90* *2.00* *2.00* *2.00* *2.00* * * In this problem i failed to Understand why t is printed as 0 (though float is converted to integer by truncation of the fractional part) and how the value of t is transferred to xlooks very strange to me !! *3.* #includestdio.h main() { printf(\nACM-CIC+3); printf(4+\nACM-CIC); } *OUTPUT -* *M-CIC-CIC* * * What does +3 and +4 doing and does it matter to use them before the format string or after it ?? *4.* #includestdio.h main() { long long i=50; i==1000; printf(i=%d\n\n%lld,sizeof(i),i); //system(pause); } *OUTPUT -* *i=8* * * *50* * * Assigning very large value to i isn't changing it's value.why is so happening ?? and the last one *5.* #includestdio.h main() { static int i=0; if(i=-1) printf(\nBull's Eye); else { main(); _exit(1); } i++; } *OUTPUT -* *segementation fault* * * What's Wrong with the above Code due to which it is giving Runtime errorplz help me pointing it out !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- Regards, Kamakshi kamakshi...@gmail.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks
Re: [algogeeks] c++ doubt
The reason is... that when u write a obj1=14; it is same as writing a obj1 = a(14); So first a temporary object is created using the constructor a(int i) And this temporary object is passed in the copy constructor. BUT since it is temp object it must be referred by a const alias. Regards, Sandeep Jain On Sun, Jul 10, 2011 at 11:52 PM, himanshu kansal himanshukansal...@gmail.com wrote: a obj3(obj1);but this statement works fine.so it means it is calling copy constt. perfectly... On Sun, Jul 10, 2011 at 11:49 PM, rahul rahulr...@gmail.com wrote: my badadd const in copy construcori think...that compiler expect... On Sun, Jul 10, 2011 at 11:48 PM, rahul rahulr...@gmail.com wrote: use a(int arg) { x = arg; } ur call will work...:) On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal himanshukansal...@gmail.com wrote: class a { int x; public: a() { } a(int i){x=i;coutin a xendl;} a(a obj){coutin copy cons of aendl;} }; a obj1=14; //error no matching call to a::a(a) why. and just adding a const in the constructor saves me from error...but how -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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++ doubt
http://www.parashift.com/c++-faq-lite/virtual-functions.html Its one of my favorite sites... :) Regards, Sandeep Jain On Mon, Jul 11, 2011 at 12:02 AM, himanshu kansal himanshukansal...@gmail.com wrote: thanku sir...sir 1 more thngcn u gv a link or some pdf for studying virtual inheritance elaborating the vptr mechanism more clearly... On Sun, Jul 10, 2011 at 11:56 PM, Sandeep Jain sandeep6...@gmail.comwrote: The reason is... that when u write a obj1=14; it is same as writing a obj1 = a(14); So first a temporary object is created using the constructor a(int i) And this temporary object is passed in the copy constructor. BUT since it is temp object it must be referred by a const alias. Regards, Sandeep Jain On Sun, Jul 10, 2011 at 11:52 PM, himanshu kansal himanshukansal...@gmail.com wrote: a obj3(obj1);but this statement works fine.so it means it is calling copy constt. perfectly... On Sun, Jul 10, 2011 at 11:49 PM, rahul rahulr...@gmail.com wrote: my badadd const in copy construcori think...that compiler expect... On Sun, Jul 10, 2011 at 11:48 PM, rahul rahulr...@gmail.com wrote: use a(int arg) { x = arg; } ur call will work...:) On Sun, Jul 10, 2011 at 11:46 PM, himanshu kansal himanshukansal...@gmail.com wrote: class a { int x; public: a() { } a(int i){x=i;coutin a xendl;} a(a obj){coutin copy cons of aendl;} }; a obj1=14; //error no matching call to a::a(a) why. and just adding a const in the constructor saves me from error...but how -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 Himanshu Kansal Msc Comp. sc. (University of Delhi) -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C OUTPUT HELP
*Problem 2:* I think u are using TurboC, since you have written void main() Secondly, printf (since based on macros) scans through the format string. And the it process arguments one by one depending on the format specifiers given in this string. I've observed that whenever there is a mismatch between the argument passed the format specifier, all subsequent values printed exhibit undefined behavior. *Problem 3:* String literals are equivalent to char*. Now when you write something like hello+1, it is treated as a string beginning from the second character i.e. ello So in your case \nACM-CIC+3 == M-CIC and 4+\nACM-CIC == \nACM-CIC+4 == -CIC It has nothing to do with format string, rather char* (string literals themselves) *Problem 4:* you are not assigning anything to i Regards, Sandeep Jain On Mon, Jul 11, 2011 at 12:38 AM, nicks crazy.logic.k...@gmail.com wrote: Someone please help me in understanding the following output - Problem *1.* #includestdio.h #ifdef getchar //this expression is evaluated to zero.why is so happening ??getchar is defined as macro in stdio.h.i mean else part shouldn't be executed which is happening #undef getchar #else #define getchar scanf(%c,ch); #endif main() { char ch; int c; c=getchar; printf(%d,c); } *OUTPUT- 1* * * * * *2.* #includestdio.h void main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%ld\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); } *OUTPUT(INPUT IS 2) -* *2* *0* *90* *2.00* *2.00* *2.00* *2.00* * * In this problem i failed to Understand why t is printed as 0 (though float is converted to integer by truncation of the fractional part) and how the value of t is transferred to xlooks very strange to me !! *3.* #includestdio.h main() { printf(\nACM-CIC+3); printf(4+\nACM-CIC); } *OUTPUT -* *M-CIC-CIC* * * What does +3 and +4 doing and does it matter to use them before the format string or after it ?? *4.* #includestdio.h main() { long long i=50; i==1000; printf(i=%d\n\n%lld,sizeof(i),i); //system(pause); } *OUTPUT -* *i=8* * * *50* * * Assigning very large value to i isn't changing it's value.why is so happening ?? and the last one *5.* #includestdio.h main() { static int i=0; if(i=-1) printf(\nBull's Eye); else { main(); _exit(1); } i++; } *OUTPUT -* *segementation fault* * * What's Wrong with the above Code due to which it is giving Runtime errorplz help me pointing it out !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] C OUTPUT HELP
TurboC has many flaws, one of the simplest examples would be char *p; scanf(%s, p); In gcc/g++ this will surely lead to segmentation fault as memory has not been allocated. Whereas in TC it will execute fine in most of the cases. Infact this will crash when your code is really large. As for input, 2 will automatically be treated as 2.0 when scanf demands a floating value. However, if you enter characters in place of numbers or vice versa. You may experience weird behavior. Regards, Sandeep Jain On Mon, Jul 11, 2011 at 9:37 AM, nicks crazy.logic.k...@gmail.com wrote: @sandeep,kamakshiithanks both...your replies were really helpfuli understood my fault in 3,4,5...they are clea now..but i am still stuck with problem 1 and 2 @sandeepwhat if i am using turbo C...though i am using gcc on terminal in my linux system. moreover acc. t KR printf uses it's first argument to decide how many arguments follow and what their types are. it will get confused,and you will get wrong answers,if there are not enough arguments or if they are the wrong type it's fine it will give the wrong answer then it's only the value we provide in input ??? @kamakshii...can explain your point related to macro in detail.is it related to linking or something which is done after creating object file... On Mon, Jul 11, 2011 at 1:37 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: probelm 5:It must be giving runtime error not segmentation fault coz it is an infinite recursion On Mon, Jul 11, 2011 at 1:09 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: for the first question...it will take #ifdef getchar to be '1' only when it is defined as a MACRO in your program..if u dont define macro it will not take it into consideration even if it is defined in header file. On Mon, Jul 11, 2011 at 12:38 AM, nicks crazy.logic.k...@gmail.comwrote: Someone please help me in understanding the following output - Problem *1.* #includestdio.h #ifdef getchar //this expression is evaluated to zero.why is so happening ??getchar is defined as macro in stdio.h.i mean else part shouldn't be executed which is happening #undef getchar #else #define getchar scanf(%c,ch); #endif main() { char ch; int c; c=getchar; printf(%d,c); } *OUTPUT- 1* * * * * *2.* #includestdio.h void main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%ld\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); } *OUTPUT(INPUT IS 2) -* *2* *0* *90* *2.00* *2.00* *2.00* *2.00* * * In this problem i failed to Understand why t is printed as 0 (though float is converted to integer by truncation of the fractional part) and how the value of t is transferred to xlooks very strange to me !! *3.* #includestdio.h main() { printf(\nACM-CIC+3); printf(4+\nACM-CIC); } *OUTPUT -* *M-CIC-CIC* * * What does +3 and +4 doing and does it matter to use them before the format string or after it ?? *4.* #includestdio.h main() { long long i=50; i==1000; printf(i=%d\n\n%lld,sizeof(i),i); //system(pause); } *OUTPUT -* *i=8* * * *50* * * Assigning very large value to i isn't changing it's value.why is so happening ?? and the last one *5.* #includestdio.h main() { static int i=0; if(i=-1) printf(\nBull's Eye); else { main(); _exit(1); } i++; } *OUTPUT -* *segementation fault* * * What's Wrong with the above Code due to which it is giving Runtime errorplz help me pointing it out !! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Kamakshi kamakshi...@gmail.com -- Regards, Kamakshi kamakshi...@gmail.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com
Re: [algogeeks] Amazon
How about this?? Since we have the distances between all pairs of nodes, so first we find the largest distance. They nodes which are the maximum distance are terminal nodes. So in the given e.g. we get a-d at a distance of 10 units. Now with this we know that the remaining nodes will lie between the two nodes selected in step one. We can apply the above logic again on the reduced set that we obtained. In our e.g we get b-c at a distance of 5. All we need to decide now is that which of b or c is near a. This is already given in terms of a-b a-c. Seems ok to me? Regards, Sandeep Jain On Thu, Jul 7, 2011 at 3:23 PM, Navneet Gupta navneetn...@gmail.com wrote: Can we do this? Start with a node, take an edge say between x1 and x2 of length k1. Take another node x3 and check distance between x1 and x3 (k13) and x2 and x3 (k23) Depending on whether k13 or k23 is bigger, the node x3 between x1 and x2 or away from x1 and after x2. Proceeding in this way should get you the correct order i guess. Thoughts? On Thu, Jul 7, 2011 at 2:07 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: But the problem arises in setting the order On Thu, Jul 7, 2011 at 2:06 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: I think for initial start it should be the minimum n values for n milestones On Thu, Jul 7, 2011 at 1:53 PM, Akshata Sharma akshatasharm...@gmail.com wrote: There is a straight roads with 'n' number of milestones. You are given an array with the distance between all the pairs of milestones in some random order. Find the position of milestones. Example: Consider a road with 4 milestones(a,b,c,d) : a --- 3Km ---b--- 5Km ---c--- 2Km ---d Distance between a and b = 3 Distance between a and c = 8 Distance between a and d = 10 Distance between b and c = 5 Distance between b and d = 7 Distance between c and d = 2 All the above values are given in a random order say 7, 10, 5, 2, 8, 3. The output must be 3,5,2 or 2,5,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. -- Piyush Sinha IIIT, Allahabad +91-8792136657 +91-7483122727 https://www.facebook.com/profile.php?id=10655377926 -- Piyush Sinha IIIT, Allahabad +91-8792136657 +91-7483122727 https://www.facebook.com/profile.php?id=10655377926 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Regards, Navneet -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Amazon
@Sachin: What if the milestones were, A1-A3-A2-A0 in this order? Regards, Sandeep Jain On Thu, Jul 7, 2011 at 6:00 PM, sachin sharma sachin.bles...@gmail.comwrote: What about this: First you have the list of distances between two milestones. Let’s form a table Start milestone End Milestone Distances A1 A0 7 A0 A3 10 A1 A2 5 A2 A3 2 A0 A2 8 A0 A1 3 I have taken above variable A0, A1, A2, A3 for a, b, c, d respectively. Now we sort the first column. If we find two entries same then sort also on based on second column. After processing you will get the following table Start milestone End Milestone Distances A0 A1 3 A0 A2 8 A0 A3 10 A1 A0 7 A1 A2 5 A2 A3 2 When you get this table: 1) Start with A0 and search for next milestone which is A1. Add this to your milestone list or just print. 2) Move to A1 in the first column and add the first entry which does not contains previously visited milestone. That is A2 whose distance is 5. You cannot add A1-A0 since it is already visited. 3) Repeat the above process till the end of list in table. Now following this step you come to A2 and you add A3 in the milestone list whose distance is 2. 4) Now you get the list of milestone…and distances. Output you get is 3-5-2 or 2-5-3. I hope this will work. Best Wishes Sachin Sharma | Software Trainee | Information Mosaic New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne | e-mail: sachinku...@informationmosaic.com Web:www.informationmosaic.comhttp://www.informationmosaic.com/ | t: www.twitter.com/infomosaic Winner 2009 Banking Technology Readers' Choice Award for Best Corporate Actions Automation Solution -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Amazon
@Sachin: What if the milestones were, A1-A3-A2-A0 in this order? Regards, Sandeep Jain On Thu, Jul 7, 2011 at 6:00 PM, sachin sharma sachin.bles...@gmail.comwrote: What about this: First you have the list of distances between two milestones. Let’s form a table Start milestone End Milestone Distances A1 A0 7 A0 A3 10 A1 A2 5 A2 A3 2 A0 A2 8 A0 A1 3 I have taken above variable A0, A1, A2, A3 for a, b, c, d respectively. Now we sort the first column. If we find two entries same then sort also on based on second column. After processing you will get the following table Start milestone End Milestone Distances A0 A1 3 A0 A2 8 A0 A3 10 A1 A0 7 A1 A2 5 A2 A3 2 When you get this table: 1) Start with A0 and search for next milestone which is A1. Add this to your milestone list or just print. 2) Move to A1 in the first column and add the first entry which does not contains previously visited milestone. That is A2 whose distance is 5. You cannot add A1-A0 since it is already visited. 3) Repeat the above process till the end of list in table. Now following this step you come to A2 and you add A3 in the milestone list whose distance is 2. 4) Now you get the list of milestone…and distances. Output you get is 3-5-2 or 2-5-3. I hope this will work. Best Wishes Sachin Sharma | Software Trainee | Information Mosaic New York | Dublin | London | Luxembourg | New Delhi | Singapore | Melbourne | e-mail: sachinku...@informationmosaic.com Web:www.informationmosaic.comhttp://www.informationmosaic.com/ | t: www.twitter.com/infomosaic Winner 2009 Banking Technology Readers' Choice Award for Best Corporate Actions Automation Solution -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] function overloading in inheritance
This happens because the Derived class's member *hides* the base class's member. Irrespective of the number/type of parameters. The solution to solve this problem is to either add an using declaration in the derived class. e.g. *using A::f;* this will bring f(int) of class A within the scope of class B, and thus allowing the overload to work or you need to use the scope resolution operator to explicitly call class A's hidden function. e.g. *b.A::f(4);* Hope this helps. Regards, Sandeep Jain Member of Technical Staff, Adobe Systems, India On Mon, Jul 4, 2011 at 12:42 PM, himanshu kansal himanshukansal...@gmail.com wrote: class A { public: void g(int i) { coutin a; } }; class B:public A { public: void f() { coutin b; } }; int main() { B b; b.f(); //vl call b::f() b.g(4); //vl call a::g() } but class A { public: void f(int i) { coutin a; } }; class B:public A { public: void f() { coutin b; } }; int main() { B b; b.f(); //vl call b::f() b.f(4); //bt here errror occurs not a matching protoype... } my ques is that cant we overload function in inheritance(which vary in parameters)..??? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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 doubt
If you try to visualize the internal representation. You've allocated 10 bytes. | h | e | l | l | o | | h | i |\0 |\0 |\0 | Since these are stored in linear form, so the actual representation would be | h | e | l | l | o | h | i |\0 |\0 |\0 | Now a[0] points to 'h' in the first row, and printf starts to print characters one by one till it finds null, i.e. \0 Thus it prints from hellohi And similarly printing a[1] prints only hi Regards, Sandeep Jain On Mon, Jul 4, 2011 at 1:48 PM, Sangeeta sangeeta15...@gmail.com wrote: #includestdio.h #includestring.h void main() { char a[2][5]= { hellodear, hi}; printf(%s%s,a[0],a[1]); } output:hellohi hi explain? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Implementing QUEUE with Singly link list
How bout I say, the insertion and deletion functions have the following prototype? void enqueue(NODEPTR q, int data) int deque(NODEPTR q) You are not allowed to maintain two pointers, i.e. no front and no rare pointers... Regards, Sandeep Jain Member of Technical Staff, Adobe Systems, India On Mon, Jul 4, 2011 at 10:20 PM, surender sanke surend...@gmail.com wrote: always maintain front and rear pointers, updating them accordingly during insertion and deletion can achieve this in O(1) surender On Mon, Jul 4, 2011 at 9:59 PM, vaibhav shukla vaibhav200...@gmail.comwrote: How to implement a QUEUE using a singly link list such that the operations ENQUEUE and DEQUEUE takes O(1) time ? -- best wishes!! Vaibhav Shukla -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] Implementing QUEUE with Singly link list
Its the queue in which you want to add a an element. Small correction in the enqueue signature. void enqueue(NODEPTR q, int data) // made it a reference, I missed it And the usage would be something like NODEPTR myQueue = NULL; enqueue(myQueue, 10); enqueue(myQueue, 20); coutdeque(myQueue); Regards, Sandeep Jain On Tue, Jul 5, 2011 at 8:30 AM, vaibhav agarwal vibhu.bitspil...@gmail.comwrote: @sandeep what is ptr q in case of enqueue? On Mon, Jul 4, 2011 at 12:53 PM, Sandeep Jain sandeep6...@gmail.comwrote: How bout I say, the insertion and deletion functions have the following prototype? void enqueue(NODEPTR q, int data) int deque(NODEPTR q) You are not allowed to maintain two pointers, i.e. no front and no rare pointers... Regards, Sandeep Jain Member of Technical Staff, Adobe Systems, India On Mon, Jul 4, 2011 at 10:20 PM, surender sanke surend...@gmail.comwrote: always maintain front and rear pointers, updating them accordingly during insertion and deletion can achieve this in O(1) surender On Mon, Jul 4, 2011 at 9:59 PM, vaibhav shukla vaibhav200...@gmail.comwrote: How to implement a QUEUE using a singly link list such that the operations ENQUEUE and DEQUEUE takes O(1) time ? -- best wishes!! Vaibhav Shukla -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Implementing QUEUE with Singly link list
OOPS... I missed again, my bad... both enqueue and deque can take reference. (Sincere apologies...) NO separate data structure is needed. And both operations can definitely be done, in O(n). BTW even if you don't take the reference variable in deque, it can be solved. :) :) Regards, Sandeep Jain On Tue, Jul 5, 2011 at 10:24 AM, Kunal Patil kp101...@gmail.com wrote: @Sandeep: Without storing explicit pointer to last element, how would you be able to access last element in a Singly Linked List in O(1) ??? Is there any parallel data structure that needs to be maintained ?? and if it is larger than size of 2 explicit pointers to last and first elements then 2 pointer strategy is obviously better !! On Tue, Jul 5, 2011 at 10:11 AM, Sandeep Jain sandeep6...@gmail.comwrote: Its the queue in which you want to add a an element. Small correction in the enqueue signature. void enqueue(NODEPTR q, int data) // made it a reference, I missed it And the usage would be something like NODEPTR myQueue = NULL; enqueue(myQueue, 10); enqueue(myQueue, 20); coutdeque(myQueue); Regards, Sandeep Jain On Tue, Jul 5, 2011 at 8:30 AM, vaibhav agarwal vibhu.bitspil...@gmail.com wrote: @sandeep what is ptr q in case of enqueue? On Mon, Jul 4, 2011 at 12:53 PM, Sandeep Jain sandeep6...@gmail.comwrote: How bout I say, the insertion and deletion functions have the following prototype? void enqueue(NODEPTR q, int data) int deque(NODEPTR q) You are not allowed to maintain two pointers, i.e. no front and no rare pointers... Regards, Sandeep Jain Member of Technical Staff, Adobe Systems, India On Mon, Jul 4, 2011 at 10:20 PM, surender sanke surend...@gmail.comwrote: always maintain front and rear pointers, updating them accordingly during insertion and deletion can achieve this in O(1) surender On Mon, Jul 4, 2011 at 9:59 PM, vaibhav shukla vaibhav200...@gmail.com wrote: How to implement a QUEUE using a singly link list such that the operations ENQUEUE and DEQUEUE takes O(1) time ? -- best wishes!! Vaibhav Shukla -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Re: Interview Question
I was thinking the same, BUT here the question is that we have two *SETS* and that's the catch. So, XORing all elements of SET A with SET B should result in ZERO only when both the set have same elements. Regards, Sandeep Jain On Sun, Jul 3, 2011 at 11:25 AM, Pranav Agarwal meetpranav...@gmail.comwrote: I think that the above algo will fail for the following two arrays: a={2,2,3,3} b={4,4,1,1} sum(a)=sum(b); a^b=0; len(a)=len(b); Correct me if i am wrong! Pranav On Sun, Jul 3, 2011 at 7:43 AM, varun pahwa varunpahwa2...@gmail.comwrote: @aditya. xor all elements mean that. take xor of each element of 1st array store in a variable that take xor of variable and each element of the second array if all elements are common then the variable will be 0 some where. var = a[0]; for(i = 1; i sizeof(a)/sizeof(a[0]); i++) var = var ^ a[i]; for(i = 0; i sizeof(b)/sizeof(b[0]); i++) var = var ^ b[i]; On Sat, Jul 2, 2011 at 2:19 PM, aditya kumar aditya.kumar130...@gmail.com wrote: @mohit..:i dint get the logic behind XOR plz explain ..nd ya i dont think dat you can find second largest in less than O(n). On Sun, Jul 3, 2011 at 2:43 AM, mohit mittal mohitm.1...@gmail.comwrote: Dont think that the corresponding elements should be same. XOR Should do it anyway. Btw other question How would you find the second largest element in an array using minimum no of comparisons?Any thing better than O(n).? On Sun, Jul 3, 2011 at 2:41 AM, aditya kumar aditya.kumar130...@gmail.com wrote: xor will only result if corresponding elements are same . what if in both the array set of integers are same but they arnt corresponding to each other ?? On Sun, Jul 3, 2011 at 2:37 AM, Dumanshu duman...@gmail.com wrote: xor all the elements of both arrays ==0 sum of 1st array == sum of 2nd array no. of elements in 1st == no. of elements in 2nd if the above conditions are met, they have the same set. m i missin sth? On Jul 3, 1:23 am, mittal mohitm.1...@gmail.com wrote: Given two arrays of numbers, find if each of the two arrays have the same set of ntegers ? Suggest an algo which can run faster than NlogN without extra space? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Mohit Mittal 4th year , Computer Engineering Student-Coordinator , DTU WebTeam 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group
Re: [algogeeks] Re: Interview Question
Agreed, BUT if you don't add a stipulation. You won't be able to reduce the complexity. For a 100% general solution, I don't think you can reduce the complexity more than O(nLgn.) There are variations of this question: -- All numbers are non-zero and distinct. -- All numbers belong to given range -- You can also have character's in place of numbers In all the above cases, you will have time complexity O(n) PS: I'm definitely looking forward to learn a solution, better than O(nLgn) Regards, Sandeep Jain On Sun, Jul 3, 2011 at 1:09 PM, sunny agrawal sunny816.i...@gmail.comwrote: @sandeep SET A - {0,3,4,7} SET B - {1,2,5,6} xor of all elements is zero sum of both the sets is same no of elements in both are same overall result : all Algorithm posted above Fails On Sun, Jul 3, 2011 at 12:59 PM, Sandeep Jain sandeep6...@gmail.comwrote: I was thinking the same, BUT here the question is that we have two *SETS* and that's the catch. So, XORing all elements of SET A with SET B should result in ZERO only when both the set have same elements. Regards, Sandeep Jain On Sun, Jul 3, 2011 at 11:25 AM, Pranav Agarwal meetpranav...@gmail.comwrote: I think that the above algo will fail for the following two arrays: a={2,2,3,3} b={4,4,1,1} sum(a)=sum(b); a^b=0; len(a)=len(b); Correct me if i am wrong! Pranav On Sun, Jul 3, 2011 at 7:43 AM, varun pahwa varunpahwa2...@gmail.comwrote: @aditya. xor all elements mean that. take xor of each element of 1st array store in a variable that take xor of variable and each element of the second array if all elements are common then the variable will be 0 some where. var = a[0]; for(i = 1; i sizeof(a)/sizeof(a[0]); i++) var = var ^ a[i]; for(i = 0; i sizeof(b)/sizeof(b[0]); i++) var = var ^ b[i]; On Sat, Jul 2, 2011 at 2:19 PM, aditya kumar aditya.kumar130...@gmail.com wrote: @mohit..:i dint get the logic behind XOR plz explain ..nd ya i dont think dat you can find second largest in less than O(n). On Sun, Jul 3, 2011 at 2:43 AM, mohit mittal mohitm.1...@gmail.comwrote: Dont think that the corresponding elements should be same. XOR Should do it anyway. Btw other question How would you find the second largest element in an array using minimum no of comparisons?Any thing better than O(n).? On Sun, Jul 3, 2011 at 2:41 AM, aditya kumar aditya.kumar130...@gmail.com wrote: xor will only result if corresponding elements are same . what if in both the array set of integers are same but they arnt corresponding to each other ?? On Sun, Jul 3, 2011 at 2:37 AM, Dumanshu duman...@gmail.com wrote: xor all the elements of both arrays ==0 sum of 1st array == sum of 2nd array no. of elements in 1st == no. of elements in 2nd if the above conditions are met, they have the same set. m i missin sth? On Jul 3, 1:23 am, mittal mohitm.1...@gmail.com wrote: Given two arrays of numbers, find if each of the two arrays have the same set of ntegers ? Suggest an algo which can run faster than NlogN without extra space? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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. -- Mohit Mittal 4th year , Computer Engineering Student-Coordinator , DTU WebTeam 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. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Varun Pahwa B.Tech (IT) 7th Sem. Indian Institute of Information Technology Allahabad. Ph : 09793899112 ,08011820777 Official Email :: rit2008...@iiita.ac.in Another Email :: varunpahwa.ii...@gmail.com People who fail to plan are those who plan to fail. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email
Re: [algogeeks] Optimisation to reduce time...
Can you give an insight to what exactly this code does? That may help quiet a lot. Regards, Sandeep Jain On Sun, Jul 3, 2011 at 1:17 PM, rajeevrvis rajeev.open.1...@gmail.comwrote: Hi Here is the code . I want to optimize it to run faster . Can Anyone help me??? #includestdio.h void main() { int n,q,a[10]={0},b[10],c[10],d[10],i,count,j; scanf(%d%d,n,q); for(i=0;iq;i++) scanf(%d%d%d,b[i],c[i],d[i]); for(i=0;iq;i++) if(b[i]==0) { for(j=c[i];j=d[i];j++) a[j]=a[j]+1; } else { count =0; for(j=c[i];j=d[i];j++) if(a[j]%3==0) count++; printf(%d\n,count); } } Regards rajeevrvis -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] find output
Apoorve, please explain the reason for this output as well Regards, Sandeep Jain On Mon, Jul 4, 2011 at 1:06 AM, Apoorve Mohan apoorvemo...@gmail.comwrote: 5 On Mon, Jul 4, 2011 at 1:01 AM, amit the cool amitthecoo...@gmail.comwrote: int main() { int a[]={5,10,15,8}; int *x=a; int y; y=*x++; printf(%d,y); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- regards Apoorve Mohan -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: 2 D array(dynamic allocation)
Here's my solution. int** allocateMatrix(int m, int n) { int **rowList = (int**)malloc(sizeof(int)*m*n + sizeof(int*)*m); int *colList = (int*)(rowList+m); int i; for(i=0; im; i++) { rowList[i] = colList+i*n; } return rowList; } And here's the main method to test/understand the allocation. int main() { int m=3, n=4; int **mat = allocateMatrix(m,n); int i, j, c=0; int wordCount= m*n+m; //sizeof(int)*4*5 + sizeof(int*)*4; counting words so sizeof is not needed int* memMap = (int*)mat; // Fill array elements with some values to be able to test for(i=0; im; i++) for(j=0; jn; j++) mat[i][j] = c++; printf(\nAddress\tValue\n); for(i=0; iwordCount; i++) printf(\n%u\t== %u, memMap+i, memMap[i]); getchar(); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] output plzzzz
One thing to remember is that, *sizeof* operator does not evaluate the expression used as the parameter, it only evaluates type of the parameter. So, in case 2, sizeof(a) == sizeof(int) == 4. We never actually access 'a' Regards, Sandeep Jain Member of Technical Staff, Adobe Systems, India On Sun, Jul 3, 2011 at 3:13 AM, HARSH PAHUJA hpahuja.mn...@gmail.comwrote: thanx i got it :) On Sat, Jul 2, 2011 at 1:57 PM, santosh mahto santoshbit2...@gmail.comwrote: this will help -sizeof operator only need declaration not definition.since sizeof operator calculates size at compile time. At compile time code doesnot seek for definition.it only need declaration.if any variable is declared with extern,it thinks that its definition will be found at linking time. In ur question: 1 case. when a =20 is done compiler see that its value is declared.so its OK .but at link time since def of a is not found so linker error. since linker tries to find the actual memory address where the def of a is. see after compilation the symbol table for a will be as symbolname| memory location| value a |find later(garbage)| 20 so there is no problem with compiler .but at link time garbage value need to be filled with actual memory address since def is not there so linker error. case2. there will be noentry in the symbol table for a. as code doesnot include any defintion related operation. iF anything helps you, dont forget to say thanks Thanks Santosh On Sun, Jul 3, 2011 at 1:38 AM, HARSH PAHUJA hpahuja.mn...@gmail.comwrote: will ny1 xplain this extern concept y this is a linker error? On Sat, Jul 2, 2011 at 12:49 PM, HARSH PAHUJA hpahuja.mn...@gmail.comwrote: @piyush plz explain how are u getting this.. On Sat, Jul 2, 2011 at 12:10 PM, Piyush Sinha ecstasy.piy...@gmail.com wrote: i) [Linker error] undefined reference to `a' ii) 4 On 7/3/11, HARSH PAHUJA hpahuja.mn...@gmail.com wrote: 1) #includestdio.h int main() { extern int a; a=20; printf(%d,sizeof(a)); return 0; } 2) #includestdio.h int main() { extern int a; printf(%d,sizeof(a)); return 0; } -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=10655377926 * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- HARSHIT PAHUJA M.N.N.I.T. ALLAHABAD -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: Y shaped linklist
Here is one solution http://geeksforgeeks.org/?p=2405 On Fri, Oct 9, 2009 at 9:00 AM, sharad kumar aryansmit3...@gmail.comwrote: space comp O(n) time o(2n) both in terms of worst case On Fri, Oct 9, 2009 at 8:46 PM, ankur aggarwal ankur.mast@gmail.comwrote: @sharad wat about space ?? extra space ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: birthday panga
How about a hash? On Fri, Aug 28, 2009 at 10:43 AM, Chonku cho...@gmail.com wrote: I think a linked list structure should suffice for this. Since insertions/deletions will not be too frequent. Memory consumption will also be optimum. On Thu, Aug 27, 2009 at 2:49 PM, ankur aggarwal ankur.mast@gmail.comwrote: Implement the birthday diary calendar to keep records of all birthdays of your friends 1) what underlying data structure(s) you will use so that the memory consumption should be optimum [i.e if you have only 12 birthday entries you should not hold memory for all 365 days of the year]. 2) You should be able view the data (birthdays) with closest birthday first [i.e 7th July should come before 11 Aug]. 3) How will you keep this data sorted (for question 2)everytime you insert a new birthday entry. This sorting should be as optimum as possible [mergesort etc will not be very beneficial bcoz ideally you won't have thousands or millions of birthday] 4) How will you handle 2 or N number of birthdays on same day --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Algo to find all the possible subsets in a set
Please see http://geeksforgeeks.org/?p=588 Well explained and coded solution. On Thu, Aug 27, 2009 at 5:28 AM, Dave dave_and_da...@juno.com wrote: If the set has fewer elements than an integer has bits, just count from 1 to MAXINT. If bit i is 0, the element is not in the set, and if bit i is 1, the element is in the set. Dave On Aug 26, 2:20 pm, AKS abhijeet.k.s...@gmail.com wrote: Hello fellas, i am lookin for an algorithm to find all the possible subsets in a given set So, if the Set is say, A={a,b,c} omit the null set o/p: --- {a} {b} {c} {a,b} {b,c} {a,c} {a,b,c} omit the null set regards, Abhijeet --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---
[algogeeks] Re: Check divisibility by 3
Richa, Did you see http://geeksforgeeks.org/?p=511 I think, above link provides the kind of solution you are looking for On Thu, Aug 20, 2009 at 11:33 PM, Ralph Boland rpbol...@gmail.com wrote: On Aug 16, 7:29 pm, Ralph Boland rpbol...@gmail.com wrote: On Aug 14, 1:45 am, richa gupta richa.cs...@gmail.com wrote: can we check the divisibility of a given number by 3 withoutusing operators like '/' or '%'. I want the efficient solution to this problem .. can someone help ?? -- Richa Gupta (IT-BHU,India) If the number is an arbitrarily large binary number then 0) Let X be the input number. 1) Add the binary values of each byte of X. Let result be X. 2) If X 255 goto step 1). 3) Look up the answer in a table or b1) treat X as a base 16 number and add digits. Let the result be X. b2) if X 16 go to step b1. 16 should be 15 here. That is: if X 15 go to step b1. b3) The original number is divisible by 3 IFF X is divisible by 3 (X in {0,3,6,9,12,15}). Note that the rule of 3s and the rule of 9s for decimal numbers is be being applied here but for the the number 255 and its factors; that is 3, 5, 15, 17, 51, and 85. It works for the same reason that the rule of 9's (and its factor rules; i.e. rule of 3's) works for decimal numbers. We could call these rules for base 256 numbers the rule of 3s base 256, the rule of 5's base 256, the rule of 15's base 256 etc. The above algorithm can be modified to use 16 bit numbers or 32 bit numbers instead of bytes. For 16 bit numbers for the digit base the method can be applied to factors of 2^16 -1, that is 3,5,17, and 257. However step 3 cannot be applied to 17 or 257. For 32 bit numbers you have the additional factor 2^16 + 1 (and the numbers in its prime factorization but unfortunately 2^ 16 + 1 is prime). It can also be modified to determine if the input number is divisible by 5,6,7,9,12, 14, or 15. To do digits 7 or 9 one has to use base 64 digits instead of base 256. (7 * 9 = 63 = 64 - 1). I believe divisibility by 13 can also be done but a different algorithm is needed. Ralph Boland Ralph Boland --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/algogeeks -~--~~~~--~~--~--~---