2. 우당탕탕 개발자111 30Dec2019 TIL Today I learned : bubble sort algorithm & Time complexity Bubble sort는 데이터를 규칙있게 배열하는 알고리즘의 한 방식이다. 지난 toy 문제 중 bubblesort 구현한 적이 있다. 함수 이름에 담긴 출제자의 의도와 다른 방식으로 문제를 해결했기 때문에, 이번엔 출제자의 의도에 맞게 bubblesort를 구현해보고자 한다. 더불어 bubble sort로 나열하게 될 경우 시간 복잡도는 어떻게 되는지도 살펴볼 예정이다. 나의 생각 우선, 출제자의 의도를 무시한 채, 배열의 엘리먼트를 오름차순으로 나열한 나의 코드는 다음과 같다. 배열 내 최소값을 찾고, 새 배열에 담은 후, 해당 엘리먼트는 삭제한다 -> 배열 내 최솟값을 찾고....(반복)하는 식으.. 2019. 12. 31. 29Dec2019 TIL Today I learned : toy 07 (Tree Depth-first Search Selection) toy 08 (Largest Product of Three) Tree Depth-first Search Selection 의 구현 Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. One starts at the root and explores as far as possible along each branch before backtracking. (출처 : 위키피디아) Tree.prototype.DFSelect = function (filter) {};구조로 되어 있다... 2019. 12. 29. 28Dec2019 TIL Today I learned : inheritance Pattern (Pseudo-classical / ES6 class) .bind //functional var makeDancer = (timeBetweenSteps) => { const dancer = {}; dancer.step = () => { setTimeout(dancer.step, timeBetweenSteps); }; } //pseudo-classical var Dancer = function (timeBetweenSteps) { this.timeBetweenSteps = timeBetweenSteps; }; Dancer.prototype.step = function () { setTimeout(this.step.bind(step, thi.. 2019. 12. 29. 24Dec2019 TIL Today I learned : ES6 (Destructing Assignment / Spread Operators / Rest Operators / Default Parameters) Destructing Assignment let user = { name : 'monkey', age : 30 }; function greeting ({name, age}) { console.log(`hi ${name}! Your age is ${age}`); }; greeting(user); // 'hi monkey! Your age is 30' Spread Operators let sum = (a, b, c, d) => a+b+c+d; let arr = [1, 2, 3, 4]; sum(...arr);// 10 Rest.. 2019. 12. 24. 23Dec2019 TIL Today I learned : toy 05, 06 bubbleSort() 구현하기 (Array.prototype.sort() 사용하지 않고) : bubbleSort ([1,0,-3,10]) 하면 작은 순서대로 [-3, 0, 1, 10] 의 배열을 리턴하는 함수 구현하기 배열의 가장 작은 숫자를 찾는다. 가장 작은 숫자를 빈 배열 'result'에 담고, 배열 내의 그 숫자는 지운다. 남은 배열의 가장 작은 숫자를 찾는다. 가장 작은 숫자를 빈 배열에 담고, 배열 내의 그 숫자는 지운다. ...... 반복 배열이 빈배열이 되면 가장 작은 숫자들을 담아왔던 배열'result'를 리턴한다. var bubbleSort = function(array) { let result = []; let recurse = .. 2019. 12. 24. 22Dec2019 TIL Today I learned : FAKE airbnb 구현 (html css DOM) document.createElement() : 새로운 엘리먼트를 생성하는 것. 생성하고자 하는 엘리먼트의 종류를 스트링 형식으로 괄호에 입력하면 된다. ex) document.createElement('DIV') .setAttribute(속성, 값) : 엘리먼트에 원하는 속성을 부여하는 매소드. id / class 지정이나 style 지정도 가능하다. ex) let div = document.createElement('DIV') div.setAttribute("class", "user"); 부모노드.appendChild(자식노드) : 원하는 노드를 다른 노드의 자식으로 만드는 매소드. 해당 자식 노드는 이 매소드를 통.. 2019. 12. 23. 이전 1 ··· 12 13 14 15 16 17 18 19 다음