- Write a function called reverseArray which takes an array as an argument. Without utilizing any of the built-in methods available to your language, return an array with elements in reversed order.
- array.reverse
function reverseArray(arr) {
return arr.reverse();
};
Get a count of the array, divide it by two and then round up, splice-in the new number at that index
- Research binary Search
- write a while loop and divide each search in half until the key is found or not found
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier
- https://medium.com/@jeffrey.allen.lewis/javascript-algorithms-explained-binary-search-25064b896470
- https://www.geeksforgeeks.org/binary-search-in-javascript/
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, Seid MO
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, Seid MO
- Method adapted from stackoverflow: https://stackoverflow.com/questions/2598348/how-to-find-nth-element-from-the-end-of-a-singly-linked-list
- Write a function called zipLists which takes two linked lists as arguments. Zip the two linked lists together into one so that the nodes alternate between the two lists and return a reference to the head of the zipped list. Try and keep additional space down to O(1). You have access to the Node class and all the properties on the Linked List class as well as the methods created in previous challenges.
- Big O: space O(n^3)/time O(n^3)
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, Seid MO
- TA Assistance from Sarah
- Define a method called push which takes any value as an argument and adds a new node with that value to the top of the stack with an O(1) Time performance.
- Define a method called pop that does not take any argument, removes the node from the top of the stack, and returns the node’s value.
- Should raise exception when called on empty stack
- Define a method called peek that does not take an argument and returns the value of the node located on top of the stack, without removing it from the stack.
- Should raise exception when called on empty stack
- Define a method called isEmpty that takes no argument, and returns a boolean indicating whether or not the stack is empty.
- Define a method called enqueue which takes any value as an argument and adds a new node with that value to the back of the queue with an O(1) Time performance.
- Define a method called dequeue that does not take any argument, removes the node from the front of the queue, and returns the node’s value.
- Should raise exception when called on empty queue
- Define a method called peek that does not take an argument and returns the value of the node located in the front of the queue, without removing it from the queue.
- Should raise exception when called on empty queue
- Big O: space O(1) for each step
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, William Moreno, Seid MO
-
Create a brand new PseudoQueue class. Do not use an existing Queue. Instead, this PseudoQueue class will implement our standard queue interface (the two methods listed below), but will internally only utilize 2 Stack objects. Ensure that you create your class with the following methods:
-
enqueue(value) which inserts value into the PseudoQueue, using a first-in, first-out approach.
-
dequeue() which extracts a value from the PseudoQueue, using a first-in, first-out approach.
- Enqueue - Space: O(1) - Time: O(1)
- Dequeue - Space: O(n^2) - Time: O(n^2)
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, Seid MO
- Create a class called AnimalShelter which holds only dogs and cats. The shelter operates using a first-in, first-out approach.
- Implement the following methods:
- enqueue(animal): adds animal to the shelter. animal can be either a dog or a cat object.
- dequeue(pref): returns either a dog or a cat. If pref is not "dog" or "cat" then return null.
- Enqueue - Space: O(1) - Time: O(1)
- Dequeue - Space: O(n^2) - Time: O(n^2)
- Collaborated with: Carly Dekock, Jason Quaglia, Jason Dormier, Seid MO, William Moreno
-
Create a Node class that has properties for the value stored in the node, the left child node, and the right child node.
-
Create a BinaryTree class
-
Define a method for each of the depth first traversals called preOrder, inOrder, and postOrder which returns an array of the values, ordered appropriately.
-
Create a BinarySearchTree class
-
Define a method named add that accepts a value, and adds a new node with that value in the correct location in the binary search tree.
-
Define a method named contains that accepts a value, and returns a boolean indicating whether or not the value is in the tree at least once.
- Find: O(log n)
- Insert: O(log n)
- Geeks for Geeks: https://www.geeksforgeeks.org/implementation-binary-search-tree-javascript/
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Write an instance method called find-maximum-value. Without utilizing any of the built-in methods available to your language, return the maximum value stored in the tree. You can assume that the values stored in the Binary Tree will be numeric.
- FindMax: O(log n)
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Write a breadth first traversal method which takes a Binary Tree as its unique input. Without utilizing any of the built-in methods available to your language, traverse the input tree using a Breadth-first approach, and return a list of the values in the tree in the order they were encountered.
- O(log n)
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
Implement a Hashtable with the following methods:
- add: takes in both the key and value. This method should hash the key, and add the key and value pair to the table, handling collisions as needed.
- get: takes in the key and returns the value from the table.
- contains: takes in the key and returns a boolean, indicating if the key exists in the table already.
- hash: takes in an arbitrary key and returns an index in the collection.
- Separate Chaining Method
- Time Efficiency: O(1)
- Space Efficiency:
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Collaborated with Jason Quaglia, Carly Dekock, Jason Dormier, Seid Mohamed
- Write a function that accepts a lengthy string parameter.
- Without utilizing any of the built-in library methods available to your language, return the first word to occur more than once in that provided string.
- O(1) Space / O(1) Time
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Collaborated with Jason Quaglia, Carly Dekock, Jason Dormier, Seid Mohamed
- Write a function called tree_intersection that takes two binary tree parameters.
- Without utilizing any of the built-in library methods available to your language, return a set of values found in both trees.
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Collaborated with Jason Quaglia, Carly Dekock
Implement your own Graph. The graph should be represented as an adjacency list, and should include the following methods:
- AddNode()
- AddEdge()
- GetNodes()
- GetNeighbors()
- Size()
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Collaborated with Jason Quaglia, Carly Dekock, William Moreno, Seid Mohamed, Jason Dormier
-
Extend your graph object with a breadth-first traversal method that accepts a starting node. Without utilizing any of the built-in methods available to your language, return a collection of nodes in the order they were visited. Display the collection.
-
Write at least three test assertions for each method that you define.
- Udemy js-algorithms-and-data-structures-masterclass by Colt Steel: https://www.udemy.com/course/js-algorithms-and-data-structures-masterclass/
- Collaborated with Jason Quaglia, Carly Dekock, William Moreno, Seid Mohamed, Jason Dormier