Skip to content

cxwang001/Computer-Science-Fundamentals

Repository files navigation

computer-science-fundamentals

binarySearch.js:

Search a sorted array by repeatedly dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

selectionSort.js:

Scat through the list and find the smallest number possible. (This would require looping through and checking which number is greater than 0, but smaller than all other numbers) We would then say that this is our 1st number. We would then loop through and check which number is bigger than this smallest number, but smaller than any other number. This would then be our second number

insertionSort.js:

Insertion sort moves elements into their desired location more quickly. It doesn't have to loop through the entire set of numbers each time to move a single element.

quickSort.js:

Select an element from the array. This element is called the pivot. Choosing a pivot – we can choose one at random. Next, begin sorting by iterating through the array. Rearrange the array's elements such that: Every element less than the pivot comes before it; and Every element greater than the pivot comes after it. This puts the pivot in the right place—i.e., this is where the pivot will appear when the array is finally sorted.

stack.js:

A linear data structure. If this statement holds marginal value to you, as it originally did with me, consider this alternative: A stack organizes data into sequential order. This sequential order is commonly described as a stack of dishes at a cafeteria. When a plate is added to a stack of dishes, the plate retains the order of when it was added; moreover, when a plate is added, it is pushed towards the bottom of a stack. Every time we add a new plate, the plate is pushed towards the bottom of the stack, but it also represents the top of the stack of plates.

queue.js

quere is a linear data structure. Unlike a stack, a queue deletes only the oldest added data. To help you conceptualize how this would work, let's take a moment to use an analogy. Imagine a queue being very similar to the ticketing system of a deli. Each customer takes a ticket and is served when their number is called. The customer who takes the first ticket should be served first.

About

CS fundamentals: data structures and algorithms

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published