Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ternary search #76

Merged
merged 4 commits into from
Oct 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
adding complexity
  • Loading branch information
Kyle-Ski committed Oct 12, 2019
commit dedde4035e0f601959a47b25e57b7755ef21c90c
7 changes: 6 additions & 1 deletion src/_Searching_/TernarySearch/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
/**
* Note: Array must be sorted for binary search
*/
* Complexity:
* Worst case time complexity: O(log N)
* Average case time complexity: O(log N)
* Best case time complexity: O(1)
* Space complexity: O(1)
*/
function ternarySearch(arr, key){
let left = 0;
let right = arr.length - 1;
Expand Down