edualgo/eduAlgo

Bug spotting

Opened this issue · 10 comments

No software package can be free of bugs practically, we would like you to point out the bugs you see in the package and create an issue first describing the bug.

You can also point the bugs out as a reply to this issue.

Some Bugs in Linear Search and Interpolation Search:

  1. In Linear Search If we find our searched elements then we need to break the loop, no further traversing required, same with Interpolation Search.
  2. In Interpolation search the condition is wrong while low <= high and array[low] <= array[high] it should be while low <= high and x >= array[low] and x <= array[high]:

Some Bugs in Linear Search and Interpolation Search:

  1. In Linear Search If we find our searched elements then we need to break the loop, no further traversing required, same with Interpolation Search.
  2. In Interpolation search the condition is wrong while low <= high and array[low] <= array[high] it should be while low <= high and x >= array[low] and x <= array[high]:

Your reported bugs have been forwarded to the concerned team. Thanks for reporting.

Some Bugs in Linear Search and Interpolation Search:

  1. In Linear Search If we find our searched elements then we need to break the loop, no further traversing required, same with Interpolation Search.
  2. In Interpolation search the condition is wrong while low <= high and array[low] <= array[high] it should be while low <= high and x >= array[low] and x <= array[high]:

@pragatipal, kindly solve this bug.

In line no. 448 of sort.py. return statement is missing in quick sort.

I have the following code:

from edualgo import algorithms as al
ping = al.search_algorithms()
arr = [10, 9, 4, 5, 7, 8]
ping.linear_search(arr, 5, True)

The script is saved as edualgo_try.py and I try to execute the script in Command Prompt as follows:

python edualgo_try.py > output.txt

As you can see, I am trying to save the output in a file called output.txt. But, I get an error which is as follows:

Traceback (most recent call last):
  File "edualgo_try.py", line 4, in <module>
    ping.linear_search(arr, 5, True)
  File "C:\Users\smv1999\AppData\Local\Programs\Python\Python36\lib\site-packages\edualgo\algorithms.py", line 1254, in linear_search
    self.linear_search_hint()
  File "C:\Users\smv1999\AppData\Local\Programs\Python\Python36\lib\site-packages\edualgo\algorithms.py", line 1297, in linear_search_hint
    print_msg_box(message)
  File "C:\Users\smv1999\AppData\Local\Programs\Python\Python36\lib\site-packages\edualgo\__init__.py", line 13, in print_msg_box
    print(box)
  File "C:\Users\smv1999\AppData\Local\Programs\Python\Python36\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-99: character maps to <undefined>

However if I remove the True parameter in the linear_search() method, I am getting the output saved in the file output.txt.
Linear Search Runtime = 0.0

Please have a look into this.

from edualgo import algorithms as al
ping = al.search_algorithms()
arr = [10, 9, 4, 5, 7, 8]
ping.linear_search(arr, 5, True)

Hey @smv1999 ,
Thank you for reaching out regarding the bug, which is actually a feature we would like to implement in our future updates.

True is passed as a parameter for the console hint methods as that method contains few characters used in the formatting of the console output, those characters need to be encoded into UTF-8 in order to get printed into a text file.

Moreover, the hint methods are designed for the console purpose only and the similar text methods will be added in our next update where you don't have to explicitly add $ python code_file.py > output.txt,
But you can just use our text function (coming in next update), and pass your file name as a parameter in order to get the work done.
Thank you for reporting this feature and as you have demanded it, out next version will have the text methods as direct applications.

Some icons are not visible

Some icons are not visible

That's another repo, where the website work is present, please contribute to that one.

image

No output will be print on binary search when target element is present at the end of the array.
I would like to contribute to your repository under WOC'24. I have also submitted my proposal for the same.