Re: Can anyone please help me in understanding the following python code

2013-06-01 Thread rusi
On May 30, 2:48 pm, bhk...@gmail.com wrote: > Code : > - > def mergeSort(alist): >     print("Splitting ",alist) >     if len(alist)>1: >         mid = len(alist)//2 >         lefthalf = alist[:mid] >         righthalf = alist[mid:] > >         mergeSort(lefthalf) >         mergeSort(righthalf)

Re: Can anyone please help me in understanding the following python code

2013-05-31 Thread Chris Angelico
On Fri, May 31, 2013 at 3:43 PM, Cameron Simpson wrote: > On 30May2013 21:54, bhk...@gmail.com wrote: > | One final question, Is there a way to edit the message once it has been > posted? > > Essentially, no. If there's some error in a post, reply to it > yourself with a correction. Transparency

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Cameron Simpson
On 30May2013 21:54, bhk...@gmail.com wrote: | One final question, Is there a way to edit the message once it has been posted? Essentially, no. If there's some error in a post, reply to it yourself with a correction. Transparency is a good thing. Revisionist history pretty much is not. -- Camer

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Got It!!!, Finally. Thanks Dave So, the control goes back to the place after the recursive function is called once the no. of element is equal to one and starts merging after which it will again start to split the remaining items. Thank you Chris for your multiple explanations. One final q

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Got It!!!, Finally. Thanks Dave So, the control goes back to the place after the recursive function is called once the no. of element is equal to one and starts merging after which it will again start to split the remaining items. Thank you Chris for your multiple explanations. It was also ve

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Dave Angel
On 05/30/2013 08:42 AM, bhk...@gmail.com wrote: http://wiki.python.org/moin/GoogleGroupsPython > In the above output, the control goes to "HERE AFTER SPLIT" after the "Merging" statement which is of-course the last statement in the function.On what condition this is happening. Ideally

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Thanks Chris, Wolfgang and Joshua for your replies. In step 2b, all the steps from 1 through 3 are executed again (twice). Soon, those calls will just output "Splitting" followed by "Merging"; and then we go back to 2c. That's why it *seems* that the code goes from

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Chris Angelico
On Thu, May 30, 2013 at 10:39 PM, wrote: > Chris, Can you please let me know what makes the control of the program code > go to 2c after the output "Merging". It goes like this: 1. [eight element list] 2a. [eight element list] 2b. 1. [four element list] 2b. 2a. [four element list] 2b.

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
On Thursday, May 30, 2013 6:09:20 PM UTC+5:30, bhk...@gmail.com wrote: > Thanks Chris, Wolfgang and Joshua for your replies. > > > > --- > > In step 2b, all the steps from 1 through 3 are executed again (twice). > > Soon, those calls will just output "Splitting" followed by "Merging"; > > a

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
On Thursday, May 30, 2013 6:09:20 PM UTC+5:30, bhk...@gmail.com wrote: > Thanks Chris, Wolfgang and Joshua for your replies. > > > > --- > > In step 2b, all the steps from 1 through 3 are executed again (twice). > > Soon, those calls will just output "Splitting" followed by "Merging"; > > a

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Thanks Chris, Wolfgang and Joshua for your replies. --- In step 2b, all the steps from 1 through 3 are executed again (twice). Soon, those calls will just output "Splitting" followed by "Merging"; and then we go back to 2c. That's why it *seems* that the code goes from 3 to 2c. You'll notice th

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Joshua Landau
On 30 May 2013 11:19, wrote: > Also, Can you please let me know how did you found out that I am using Python > 2 Interpreter. Do you have access to a Python3 interpreter? If so, try running it and your output will look like: Splitting [54, 26, 93, 17, 77, 31, 44, 55, 20] Splitting [54, 26, 9

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Joshua Landau
On 30 May 2013 10:48, wrote: > Question: > - > Function mergeSort is called only once, but it is getting recursively > executed after the printing the last statement "print("Merging ",alist)". But > don't recursion taking place except at these places "mergeSort(lefthalf), > mergeSort(r

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Chris Angelico
On Thu, May 30, 2013 at 8:19 PM, wrote: > Thanks for the reply Chris. > > I am newbie to python, so please excuse me if I am asking chilly questions. All questions are welcome! > Can you please explain more about the following sentence. > "When it says "Splitting" with a single-element list, it

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Wolfgang Maier
gmail.com> writes: > > Thanks for the reply Chris. > > I am newbie to python, so please excuse me if I am asking chilly questions. > > Can you please explain more about the following sentence. > "When it says "Splitting" with a single-element list, it then > immediately prints "Merging" and

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Thanks for the reply Chris. I am newbie to python, so please excuse me if I am asking chilly questions. Can you please explain more about the following sentence. "When it says "Splitting" with a single-element list, it then immediately prints "Merging" and returns (because all the rest of the c

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Wolfgang Maier
gmail.com> writes: > > > Function mergeSort is called only once, but it is getting recursively executed after the printing the last > statement "print("Merging ",alist)". But don't recursion taking place except at these places > "mergeSort(lefthalf), mergeSort(righthalf)" > > Sometimes the func

Re: Can anyone please help me in understanding the following python code

2013-05-30 Thread Chris Angelico
On Thu, May 30, 2013 at 7:48 PM, wrote: > Function mergeSort is called only once, but it is getting recursively > executed after the printing the last statement "print("Merging ",alist)". But > don't recursion taking place except at these places "mergeSort(lefthalf), > mergeSort(righthalf)" >

Can anyone please help me in understanding the following python code

2013-05-30 Thread bhk755
Code : - def mergeSort(alist): print("Splitting ",alist) if len(alist)>1: mid = len(alist)//2 lefthalf = alist[:mid] righthalf = alist[mid:] mergeSort(lefthalf) mergeSort(righthalf) i=0 j=0 k=0 while ihttp://mail.