본문 바로가기

Javascript

(15)
Bubble Sort Sotring is the process of rearranging the itmes in a collection so that the items are in some kind of order. it is common task. may different ways to sort thing and each has own defferent pros and cons. Built-In JavaScript Sorting it always doesn't work how we expect it should JavaScript Sort() method takes evety item that array is converted to a string and then the Unicode value of that is take..
Searching Algorithms Intro to Linear Search -> Checking every single thing at a set interval on item at a time -> many different search methods on arrays in JavaScript - indexOf, includes, find, findIndex Linear Search Pseudocode Loop through the array and check if the current array element is equal to the value If it is, return the index at which the element is found If the value is never found, return -1 Linear Se..
Recursion basic idea is taking one problem and doing it over and over on a smaller piece or on a chaning piece until you hit some endpoint which we call the base case. Recursion is different way of thinking about writing solution. can choose a solution iterative way or recursive way. A process that calls itself. ex) JSON.parse / JSON.stringify document.getElementById Object traversal the call stack - it i..
Problem Solving Patterns cs.slides.com/colt_steele/problem-solving-patterns Frequency Counter This pattern uses objects or sets to collect values/frequencies of values can often avoid nested loop or O(n^2) operations with arrays/strings function same(arr1, arr2){ if(arr1.length !== arr2.length){ return false; } for(let i = 0; i < arr1.length; i++){ let correctIndex = arr2.indexOf(arr1[i] ** 2) if(correctIndex === -1) { ..
Problem Solving Approach cs.slides.com/colt_steele/problem-solving-patterns Problem Solving Patterns A presentation created with Slides. cs.slides.com Basic approaches, Steps you can take to make it solvable define what an algorithm is devise a plan to solve algorithms compare and contrast problem solving Algorithm - A process or set of steps to accomplish a certain task. How to improve the skill? Devise a plan for solv..
The Big O of Objects and Array https://cs.slides.com/colt_steele/built-in-data-structures-25 When to use objects, don’t need order Need fast access O(1) / insertion O(1) / removal O(1) in constant time. Searching O(N) in linear time Big O of Object Methods Object.key O(N) Object.values O(N) Object.entries O(N) hasOwnProperty O(1) Big O of Array Searching O(N) Access O(1) Insertion depends on where to put. It has to re-index e..
Introducing Big O https://cs.slides.com/colt_steele/big-o-notation How the runtime of an algorithm grows as the inputs grow. It is a way of describing the relationship between the input to a function or as it grows and how that changes the runtime of that function. The relationship between the input size and then the time relative to that input. As the input and the number of n grows how does that change to refle..