This repo goes through the coding challenges presented in Front End Master's Data Structures and Algorithms video course. Exercises can be found here.
constructors.js
Create a class, add methods to the class and create an instance of the class.
stacks/stackStringExercise.js
Create a 'storage' (stack) string on a class. Then add 'menu items' to the 'storage'. Create methods that allow you to push and pop strings on and off the stack as well as a method that returns the number of items on the stack.
This was difficult because the stack had to be a string.
stacks/stackExercise.js
Create a stack (Last in First out) with an object as the underlying data structure. Not allowed to use arrays or native push/pop methods.
stacks/queueExercise.js
Same rules apply as Stack Exercise. However, a queue is First in First Out.
recursion/*
This directory is filled with exercises and common interview whiteboard questions involving Recursion. Exercises include Factorials, Fibonnaci sequence, reversal of array and strings through recursion and more. I have not completed all "interview" exercises in this directory.
timeComplexity/TC.js
Code examples in which you must notate the time complexity of each algorithm. Slides and exercise can be found here.
sortingAlgorithms/*
Implement Bubble Sort. Average Complexity: O(n^2). Best Time Complexity: O(n).
Optional exercises(completed):
Make Algorithm Adaptive. If at any point the array is already sorted, break out of algorithm early.
Optimize algorithm by avoiding unnecessary comparisons. I solved this by not iterating to the end of the array after each iteration.
Implement Insertion Sort. Average Time Complexity: O(n^2). Best Time Complexity: O(n).
Optional Exercises(not completed yet):
Allow your algorithm to take a comparator function. Look at array.sort comparator function for an example (I'm still not sure what a comparator function is after looking at array.sort)
Use the comparator function to ensure your sort is stable.
Implement Selection Sort. Average Time Complexity: O(n^2). Best Time Complexity: 0(n).
Optional Exercises:
Make algorithm stable. (completed)
Allow your algorithm to take a comparator function, just like Insertion Sort. (I'm still not clear on what this is).
Implement merge sort recursively. Time complexity: 0(n*log(n)).
Implement quick sort recursively. Average Time Compleity: O(n*log(n)).
trees/
Implement a Linked List made out of a Class. Linked Lists are not inserted into arrays to be help keep track of placement.
Optimizations:
Implement a Doubly-Linked-List. I did this by adding a .prev key to the node to reference the previous node in the list.
Find a way to make the insert and remove methods Constant Time O(1) instead of iterating through all the nodes to find the one you want to remove or add. I did this by creating a key on the constructor with the value of the node being added. This way, I can simply perform a property look up (O(1)) to find the node.