Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Reverse String and Binary Search of floating point values

Language: Layout:
+ ] Show input
Compilation time: 0.14 sec, absolute running time: 0.09 sec, cpu time: 0.08 sec, average memory usage: 16 Mb, average nr of threads: 4 
fork mode |  history  | discussion
Thanks for the opportunity!

Reverse string - tests:
~~~~~~~~~~~~~~~~~~~~~~~
Time complexity: O(n/2) and Space complexity: O(n), where n is the number of characters in the string. Space complexity would be O(1) if the input is given as a char[].

Assert:Pass.  reverses a small sentence
Assert:Pass.  reverses a 2 letter string
Assert:Pass.  reverses a 1 letter string
Assert:Pass.  returns string.Empty for null
Assert:Pass.  returns string.Empty for string.Empty
Assert:Pass.  handles unicode characters

Binary search of floating point values - tests:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Time complexity: O(log n) and Space complexity: O(1), where n is the number of elements in the input array.

Assert:Fail.  finds the straight match
Assert:Pass.  finds when greater is the closest
Assert:Pass.  finds when lower is the closest
Assert:Pass.  finds when the first is the closest by being greater
Assert:Pass.  finds when the first is the closest by being lesser
Assert:Pass.  finds when the last is the closest by being greater
Assert:Pass.  find swhen the last is the closest by being lesser
Assert:Pass.  returns -1 when the array is empty

Binary search of LARGE, PRECISE, DUPLICATE floating point values - tests:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Assert:Pass.  finds the straight match among large, precise numbers
Assert:Pass.  finds the highest index one when duplicate exists - test #1
Assert:Pass.  finds the highest index one when duplicate exists - test #2

    
                
λ
.NET NoSQL database for rapid development