Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46477
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-05-30 05:42 -0700 |
| References | <921173f3-21e7-46b4-a7b1-86660a3ebc72@googlegroups.com> <384a9b8f-40e0-4c8c-b15f-0c96512f67f1@googlegroups.com> |
| Message-ID | <ccb5c332-4b5e-44e3-ab9b-1d815c73548b@googlegroups.com> (permalink) |
| Subject | Re: Can anyone please help me in understanding the following python code |
| From | bhk755@gmail.com |
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 back to 2c. That's why it *seems* that the code goes > > from 3 to 2c. You'll notice that the call depth decreases when this > > happens > > > > Chris, Can you please let me know what makes the control of the program code go to 2c after the output "Merging". > > Also, please look into the following output for the same program with more print statements, > ---------------------------------------------- > before calling main mergesort > > Splitting [54, 26, 93, 17, 77, 31, 44, 55, 20] > > left half before split [54, 26, 93, 17] > > right half before split [77, 31, 44, 55, 20] > > Splitting [54, 26, 93, 17] > > left half before split [54, 26] > > right half before split [93, 17] > > Splitting [54, 26] > > left half before split [54] > > right half before split [26] > > Splitting [54] > > Merging [54] > > Splitting [26] > > Merging [26] > > > > HERE AFTER SPLIT > > > > left half after split [54] > > right half after split [26] > > Merging [26, 54] > > Splitting [93, 17] > > left half before split [93] > > right half before split [17] > > Splitting [93] > > Merging [93] > > Splitting [17] > > Merging [17] > > > > HERE AFTER SPLIT > > > > left half after split [93] > > right half after split [17] > > Merging [17, 93] > > > > HERE AFTER SPLIT > > > > left half after split [26, 54] > > right half after split [17, 93] > > Merging [17, 26, 54, 93] > > Splitting [77, 31, 44, 55, 20] > > left half before split [77, 31] > > right half before split [44, 55, 20] > > Splitting [77, 31] > > left half before split [77] > > right half before split [31] > > Splitting [77] > > Merging [77] > > Splitting [31] > > Merging [31] > > > > HERE AFTER SPLIT > > > > left half after split [77] > > right half after split [31] > > Merging [31, 77] > > Splitting [44, 55, 20] > > left half before split [44] > > right half before split [55, 20] > > Splitting [44] > > Merging [44] > > Splitting [55, 20] > > left half before split [55] > > right half before split [20] > > Splitting [55] > > Merging [55] > > Splitting [20] > > Merging [20] > > > > HERE AFTER SPLIT > > > > left half after split [55] > > right half after split [20] > > Merging [20, 55] > > > > HERE AFTER SPLIT > > > > left half after split [44] > > right half after split [20, 55] > > Merging [20, 44, 55] > > > > HERE AFTER SPLIT > > > > left half after split [31, 77] > > right half after split [20, 44, 55] > > Merging [20, 31, 44, 55, 77] > > > > HERE AFTER SPLIT > > > > left half after split [17, 26, 54, 93] > > right half after split [20, 31, 44, 55, 77] > > Merging [17, 20, 26, 31, 44, 54, 55, 77, 93] > > > > after calling main mergesort > > > > [17, 20, 26, 31, 44, 54, 55, 77, 93] > > ------------------------------------------------------- > > 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 as per my understanding, after the last statement of a function the control should come out of the function. > > Please correct me if I am wrong here. > > There is something with respect-to functions in python that I am not able to understand.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 02:48 -0700
Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 20:01 +1000
Re: Can anyone please help me in understanding the following python code Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-05-30 10:17 +0000
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 03:19 -0700
Re: Can anyone please help me in understanding the following python code Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2013-05-30 10:43 +0000
Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 20:47 +1000
Re: Can anyone please help me in understanding the following python code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-30 12:11 +0100
Re: Can anyone please help me in understanding the following python code Joshua Landau <joshua.landau.ws@gmail.com> - 2013-05-30 12:03 +0100
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:39 -0700
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:42 -0700
Re: Can anyone please help me in understanding the following python code Dave Angel <davea@davea.name> - 2013-05-30 09:29 -0400
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 05:42 -0700
Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-30 22:55 +1000
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 06:01 -0700
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 21:53 -0700
Re: Can anyone please help me in understanding the following python code bhk755@gmail.com - 2013-05-30 21:54 -0700
Re: Can anyone please help me in understanding the following python code Cameron Simpson <cs@zip.com.au> - 2013-05-31 15:43 +1000
Re: Can anyone please help me in understanding the following python code Chris Angelico <rosuav@gmail.com> - 2013-05-31 17:13 +1000
Re: Can anyone please help me in understanding the following python code rusi <rustompmody@gmail.com> - 2013-06-01 10:43 -0700
csiph-web