Rediet8abere / CS-1.3-Core-Data-Structures

MIT License
0 stars 0 forks source link

Submission 1: Number bases and binary search #1

Closed Sukhrobjon closed 4 years ago

Sukhrobjon commented 4 years ago
  1. Number base: Your code works well and passes all the tests, but it is hard to read, if you add comments where you use complex, it makes it easier to read and follow for others and later for you to understand what you did. For example this line:
    frac += str(round(x-int(x), (len(digits)-1) - len(str(int(x)))))

    Also, instead of mapping all letters to numbers you could have used ord() function.

  2. Binary search: The iterative solution is working. but the recursive binary search is failing and throwing RecursionError: maximum recursion depth exceeded in comparison this is because you are not checking your bounds. add this line somewhere at the beginning of the recursive binary search.
    if low > high:
        return None

    this stops the infinite recursive call.

Rediet8abere commented 4 years ago

Thank you for your feedback!