[Tutor] lists+sort

Danny Yoo dyoo at hashcollision.org
Mon Jan 4 17:35:10 EST 2016


On Jan 4, 2016 11:00 AM, "Pooja Bhalode" <poojabhalode11 at gmail.com> wrote:
>
> Hi, I wanted to check if this program can be used to merge the lists
> together and sort them. This seems to work, but i wanted to check if there
> are drawbacks in writing it in this manner.

You may be missing some important details or misunderstanding a crucial
detail.

For example, the term "merge" in this context usually had a very specific
technical meaning.

Are your two input lists already sorted?

The use of the term "linear" in the function definition:

> def linear_merge(list1, list2):

has a particular meaning in terms of algorithmic complexity, and the first
implementation does not satisfy it: it does not perform linearly due to the
internal use of the sort().

If you have questions, please feel free to ask.


More information about the Tutor mailing list