11

BinarySearch The BinarySearch class should be public since it contains utility methods that are generally useful. To do this, write public class BinarySearch instead of class BinarySearch. The binSearch method should be static since it does not access any fields from the BinarySearch class. After all, that class doesn't have any fields that could be ...


6

Your code looks good but just wanted to suggest below if (mid >= start && mid <= end) - this condition will never fail because mid will either equal to start or end so you can skip this because this is taking unnecessary condition check time You can check if start is less than or equal to end otherwise you will end up with wrong mid value. By ...


4

Doc comments: You can be more clear in the doc comment about what the function does: What is the input? (string, path) Does it return anything? (no) Does it throw exceptions? (yes, because os.remove and shutil.rmtree may throw) What is the state after calling the function? (file/folder has been removed, except if there was a permission error or another ...


3

One significant issue that has not been addressed in previous answers (all of which make excellent points), is that of deterministic behaviour. Your code is going to produce unexpected, and inconsistent results if the data in the sorted array is not unique. You clearly indicate that the array is pre-sorted, but you do not specify any restraints on the ...


3

I have some suggestions for you. 1) In the search method, extract the sortedArray[mid] into a variable. //[...] int currentMid = sortedArray[mid]; if (currentMid == key) { //[...] } else if (currentMid > key) { //[...] } else if(currentMid < key){ //[...] } For the array part, instead of passing an array, you can use the varargs. In my opinion, it ...


2

This is an interesting code. Criticism: def testConfigStackYaml(self): Can we rename these functions to snake_case such as test_config_stack_yaml maybe. assert not bad_list, "Expected config/<stack_name>.yaml files to exist: %s" % bad_list You can access unit test asserts from `TestCas How: self.assertTrue(expr, msg=None) self.assertFalse(expr, ...


Only top voted, non community-wiki answers of a minimum length are eligible