- adjacency-graph
- array
- binary-heap
- binary-search-tree
- hash-table
- priority-queue
- queue
- singley-linked-list
- stack
--
--
--
--
--
--
--
--
--
--
/*----------------------------------------------------------
| Binary Search
*----------------------------------------------------------
|
| Time Complexity
| . Best: O(1)
| . Aver: O(log n)
| . Worst: O(log n)
|
| Space Complexity
| . O(1)
| Notes
| . Array Must be sorted for binary search to work
| . Binary Search is Uber Fast O(log n) is the fastest outside of Constant Time Complexity
|
*/
const BinarySearch = (sorted = [], key) => {
let lo = 0
let hi = sorted.length - 1
while (lo <= hi)
{
let mid = Math.floor((lo + hi) / 2)
if (key === sorted[mid]) return mid
else if (key < sorted[mid]) hi = mid - 1
else if (key > sorted[mid]) lo = mid + 1
}
return -1
}
--
/*----------------------------------------------------------
| Linear Search
*----------------------------------------------------------
|
| Time Complexity
| . Best: O(1)
| . Aver: O(n)
| . Worst: O(n)
|
| Space Complexity
| . O(1)
|
| Notes
| . Unlike Binary Search, Linear doesn't require sorted array
| . Much, much, much slower than binary search on large lists of items
|
*/
const LinearSearch = (items = [], key) => {
for (let i = 0; i < items.length; i++) {
if (items[i] === key) return i
}
return -1
---
## <img src='https://api.github.com/images/icons/emoji/point_down.png' height="50" width='50' alt='coffee icon data structures and algorithms 101'/> Installation
### Git
```bash
git clone https://github.com/zhorton34/data-structures-and-algorithms-101
cd data-structures-and-algorithms-101
npm install && npm run build
node
let Api = require('./dist/index.js')
PRs are welcomed to this project. If you want to improve the vuejs-form library, add functionality or improve the docs please feel free to submit a PR.
"Pre-alpha refers to all activities performed during the software project before formal testing. These activities can include requirements analysis, software design, software development, and unit testing. In typical open source development, there are several types of pre-alpha versions. Milestone versions include specific sets of functions and are released as soon as the feature is complete."
- Adding initial data structures
- Adding initial algorithms
Data Structures and Algorithms 101 (In JavaScript) will eventually implement semantic versioning
Code Status | Stage | Rule | Example Version |
---|---|---|---|
First release | New Product | Start with 1.0.0 | 1.0.0 |
Backward compatible bug fixes | Patch Release | Increment the third digit | 1.0.1 |
Backward compatible new features | Minor Release | Increment the middle digit and reset last digit to zero | 1.1.0 |
Changes that break backward compatibility | Major Release | Increment the first digit and reset middle and last digits to zero | 2.0.0 |