Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Computer Science Introduction to Data Structures The Merge Sort Algorithm Ensuring the Correctness of Merge Sort

Shouldn't the test condition of the verify_sort function be "equal to or less than"?

This is what my verify_sorted function looks like:

def verify_sorted(list):
  n = len(list)

  if n == 0 or n == 1:
    return True

  return list[0] <= list[1] and verify_sorted(list[1:])

I found that the function would sometimes return False even if the list was actually sorted if there were duplicate numbers.

Brandon Little
Brandon Little
30,417 Points

I experienced the same issue, and made the same change.

1 Answer

I believe it should be a <= instead of < as well