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 c...@zip.com.au wrote: On 30May2013 21:54, bhk...@gmail.com 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

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 ilen(lefthalf)

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, bhk...@gmail.com 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),

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

2013-05-30 Thread Wolfgang Maier
bhk755 at 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 function

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 code

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

2013-05-30 Thread Wolfgang Maier
bhk755 at 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 Chris Angelico
On Thu, May 30, 2013 at 8:19 PM, bhk...@gmail.com 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

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

2013-05-30 Thread Joshua Landau
On 30 May 2013 10:48, bhk...@gmail.com 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),

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

2013-05-30 Thread Joshua Landau
On 30 May 2013 11:19, bhk...@gmail.com 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]

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 that

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; and then we go

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; and then we go

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, bhk...@gmail.com 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

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

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: SNIP lots of double-spaced googlegroups nonsense. Please read this 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

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

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

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 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