+ 8
How to add time Complexity work?
Here is the code: https://code.sololearn.com/WAxgYfP5cdbN/?ref=app
7 Respuestas
+ 8
ODLNT why jump search take more time than linear and binary search?
+ 7
Idk but if this is what you're trying to do
https://code.sololearn.com/W1I0O4xozGBi/?ref=app
I guess you're calling that Date().getMili function before executing the actual function.
+ 2
🔫 Rick Grimes nice answer but it not work perfectly ...
If I use it Already ......Sometimes binary search take much time then linear search which is not possible.....
+ 2
Performance.now() maybe what you are looking for, due to the size of the array.
https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
https://code.sololearn.com/WhAzRCyBEdNF/#js
https://code.sololearn.com/WN10dh2f875Q/#js
+ 2
Coder
It appears the step in the jump search algorithm has to be an integer. I added Math.floor to Math.sqrt and now times are in line with the time complexity.
-or-(edit)
It may have something to do with the size of the array. In the second code, I posted I change the array length to 1000.
0
On an unsorted array Binary Search is almost twice as slow as Linear Search with worst Time Complexity of O(n²) and that is not even considering unbalanced trees.
In case of a sorted array, Binary Search is faster but the caveat here is also on how arrays are treated by the Language Translator.
You have to keep in mind, running code on this app is not a real world situation as this app uses a Server Machine on the other end and results can significantly differ from a real world test.
0
Where did you learn all this awesome coding..???