sortvis icon indicating copy to clipboard operation
sortvis copied to clipboard

Maximum Recursion Depth Reached in Timsort for N=1400

Open osilkin98 opened this issue 7 years ago • 0 comments

I was trying to find an implementation of Timsort in Python, and came across the one in this repository. I decided to clone the sorting algorithms in the repo to benchmark an algorithm I came up with against others, and found that your implementation reaches a maximum recursion depth at N=1400.

	Time to sort N=1400 randomly generated values between 0 and 256 using skipsort: 0.023 secs

	Time to sort N=1400 randomly generated values between 0 and 256 using quicksort: 0.050 secs

	Time to sort N=1400 randomly generated values between 0 and 256 using mergesort: 0.085 secs

	Time to sort N=1400 randomly generated values between 0 and 256 using radixsort: 0.092 secs

Traceback (most recent call last):

  < omits unnecessary trace >

  File "/home/oleg/CLionProjects/CFastSort/src/sorting_algorithms.py", line 317, in timsort
    sorted_array = timsort_merge(sorted_array, run)
  File "/home/oleg/CLionProjects/CFastSort/src/sorting_algorithms.py", line 281, in timsort_merge
    return [left[0]] + timsort_merge(left[1:], right)
  File "/home/oleg/CLionProjects/CFastSort/src/sorting_algorithms.py", line 281, in timsort_merge
    return [left[0]] + timsort_merge(left[1:], right)
  File "/home/oleg/CLionProjects/CFastSort/src/sorting_algorithms.py", line 281, in timsort_merge
    return [left[0]] + timsort_merge(left[1:], right)
  [Previous line repeated 985 more times]
  File "/home/oleg/CLionProjects/CFastSort/src/sorting_algorithms.py", line 280, in timsort_merge
    if left[0] < right[0]:
RecursionError: maximum recursion depth exceeded in comparison

osilkin98 avatar Sep 12 '18 00:09 osilkin98