From e59f1ed1fceda8f4e0216f57a66b491bf626fb79 Mon Sep 17 00:00:00 2001 From: Francis Yang Date: Tue, 9 Jan 2024 05:46:00 -0800 Subject: [PATCH] starting on readme --- README.md | 2 +- src/algorithms/search/twin-pointers/README.md | 14 ++++++++++++++ .../search/twin-pointers/twinPointers.js | 0 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 src/algorithms/search/twin-pointers/README.md create mode 100644 src/algorithms/search/twin-pointers/twinPointers.js diff --git a/README.md b/README.md index 00d0682f..a6a72908 100644 --- a/README.md +++ b/README.md @@ -124,9 +124,9 @@ a set of rules that precisely define a sequence of operations. * **Searches** * `B` [Linear Search](src/algorithms/search/linear-search) * `B` [Jump Search](src/algorithms/search/jump-search) (or Block Search) - search in sorted array - * `B` [Twin Pointers](src/algorithms/search/twin-pointers) - search sorted array * `B` [Binary Search](src/algorithms/search/binary-search) - search in sorted array * `B` [Interpolation Search](src/algorithms/search/interpolation-search) - search in uniformly distributed sorted array + * `B` [Twin Pointers](src/algorithms/search/twin-pointers) * **Sorting** * `B` [Bubble Sort](src/algorithms/sorting/bubble-sort) * `B` [Selection Sort](src/algorithms/sorting/selection-sort) diff --git a/src/algorithms/search/twin-pointers/README.md b/src/algorithms/search/twin-pointers/README.md new file mode 100644 index 00000000..4bf54b47 --- /dev/null +++ b/src/algorithms/search/twin-pointers/README.md @@ -0,0 +1,14 @@ +# Twin Pointers + +The twin pointers method, also known as the two pointers method, is a searching algorithm that can be used on both + +![Binary Search](https://upload.wikimedia.org/wikipedia/commons/8/83/Binary_Search_Depiction.svg) + +## Complexity + +**Time Complexity**: `O(n)` - since we only need to look over every element of our array a single time when comparing, time complexity is O(n). + +## References + +- [Wikipedia](https://en.wikipedia.org/wiki/Binary_search_algorithm) +- [YouTube](https://www.youtube.com/watch?v=P3YID7liBug&index=29&list=PLLXdhg_r2hKA7DPDsunoDZ-Z769jWn4R8) diff --git a/src/algorithms/search/twin-pointers/twinPointers.js b/src/algorithms/search/twin-pointers/twinPointers.js new file mode 100644 index 00000000..e69de29b