[algogeeks] Difference between memcpy and memmove
As far as I could understand, memcpy just iterate through the memory( byte by byte or word by word) and blindly copies 'n' number of bytes from source to destination without considering whether source and destination memory overlaps. While memmove first copies n number of bytes to intermediate buffer and then copies the buffer content to destination address. consider the following example: #include cstdio #include memory.h #include iostream using namespace std; int main() { char a[20] = weather is good; memcpy(a+1, a, strlen(a) ); cout a; return 0; } it produces the o/p: wweather is good But as per definition of memcpy, o/p should be : www. Its because, after writing 'w' at a[1], memcpy tries to copy a[1] to a[2] , but now we have 'w' at a[1]. so effectively w should be copied on subsequent locations (from a[2] onwards) strlen(a) times. can anybody explain the o/p wweather is good to me? Can you give me an example when just replacing memmove by memcpy produces different output? -- Vipin Delhi College of Engineering -- 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/-/QG9qW4hwkloJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: SEEK advice very urgent
On Thu, Sep 1, 2011 at 12:32 PM, raj kumar megamonste...@gmail.com wrote: I am from Delhi College of Engineering[now DTU] i don't think it's on us to chose the location where we want to work , they will ask our preferences if possible then only they will send us to singapore otherwise we will have to go tokyo... By the way is there anyone else who have cleared the exam please reply asap thanks friends -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. @raj Can you please tell me something abt there written test. They are also coming in our college. *Regards,* *Vipin Vishvkarma* *M.Tech, IIT Bombay* * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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: SEEK advice very urgent
On Tue, Sep 6, 2011 at 9:21 AM, Vipin Vishvkarma vipinvi...@gmail.comwrote: On Thu, Sep 1, 2011 at 12:32 PM, raj kumar megamonste...@gmail.comwrote: I am from Delhi College of Engineering[now DTU] i don't think it's on us to chose the location where we want to work , they will ask our preferences if possible then only they will send us to singapore otherwise we will have to go tokyo... By the way is there anyone else who have cleared the exam please reply asap thanks friends -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. @raj Can you please tell me something abt there written test. They are also coming in our college. *Regards,* *Vipin Vishvkarma* *M.Tech, IIT Bombay* * * @raj Can you please tell me something abt their written test. They are also coming in our college. -- *Regards,* *Vipin Vishvkarma* *M.Tech,IIT Bombay* * * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from 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] probability ques
range of 'a' will be [3,47] so in this way 45/98 On Tue, Aug 23, 2011 at 10:36 PM, aayush jain ajain...@gmail.com wrote: @priya give the logic -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- *VpN Vishvkarma vpnvi...@cse.iitb.ac.in @IITB* -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Re: Amazon Question
take an example 3 3 3 5 5 5 7 8 I think this would fail On Mar 3, 8:22 pm, Ankit Sinha akki12...@gmail.com wrote: It is funny but right input is as mentioned earlier to rahul. 0,2,3,8, 10, 12, 14., 15 :).. Sorry for unnecessarily flooding your mail accounts. Please ignore previous post thanks, ankit!! On Thu, Mar 3, 2011 at 8:15 PM, rajul jain rajuljain...@gmail.com wrote: i think he is wrong bcoz this array in not sorted one. so solution of Ankit is right. On Thu, Mar 3, 2011 at 7:33 PM, nishaanth nishaant...@gmail.com wrote: Ignore the previous post..there is a small error in the code.. @Ankit..your algm is O(n)...you should split the problem size to n/2 at every stage...rather you are again computing both the subarrays.. Here is the correct code... int BsearchElemEqualIndex (int *a, int start, int end) { int mid = (((end - start) 1) + start); if (a[mid] == mid) return a[mid]; else if (a[mid] != mid) { if (mid == start || mid == end) { return -1; } else { if(a[mid] mid ) BsearchElemEqualIndex (a, start, mid); else BsearchElemEqualIndex (a, mid + 1, end); } } } int _tmain(int argc, _TCHAR* argv[]) { int a[SIZE] = {5,9,3,8,1,2,6,7}; int x = BsearchElemEqualIndex (a, 0, SIZE); printf (%d, x); system (PAUSE); return 0; } S.Nishaanth, Computer Science and engineering, IIT Madras. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.