Skip to content

Arrays, Hash Tables, Linked Lists, Binary Trees, Graphs, Quick Sort, Merge Sort, Bubble Sort, Insertion Sort, Selection Sort, Priority Queues, Binary Heaps, Breadth First Search, Depth First Search

Notifications You must be signed in to change notification settings

clean-code-studio/data-structures-algorithms-101

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRs Welcome dependencies Open Source Love svg1 Maintenance

Adjacency Graph

--

Array

--

Binary Heaps

--

Binary Search Tree

--

Hash Table

--

Priority Queue

--

Queue

--

Singley Linked List

--

Stack

--

Binary Search

--

/*----------------------------------------------------------
 |   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

--

/*----------------------------------------------------------
 |   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')

Official Apis



Contribute


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.


Release Pre-Alpha


"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

Versioning


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

License


MIT © Zachary Horton (Clean Code Studio)

About

Arrays, Hash Tables, Linked Lists, Binary Trees, Graphs, Quick Sort, Merge Sort, Bubble Sort, Insertion Sort, Selection Sort, Priority Queues, Binary Heaps, Breadth First Search, Depth First Search

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%