분류 전체보기(18)
-
react-router-dom Switch component, NotFound
Switch component 작성방법 1. 좁은 범위의 컴포넌트부터 넓은 범위의 컴포넌트 순서로 작성한다. 다음 2. Root경로에는 exact를 추가 3. NotFound는 제일 아래
2021.07.27 -
Dynamic Routing에서 props 가져올 때
https://localhost:3000/about?name=mark 에서 mark를 가져오고 싶을 때 1. URLSearchParams 사용(브라우저에 따라 동작 안할 수 있음) const searchParams = props.loacation.search; const obj = new URLSearchParams(searchParams); console.log(obj.get("name")); 2. query-string 사용 설치 npm i query-string -S 사용법 const query = queryString.parse(searchParams); console.log(query.name);
2021.07.27 -
React State Handling
React에서 state을 변경할 때는 setState를 이용해야 rendering됨 componentDidMount() { setTimeout(() => { this.state.count = this.state.count + 1; }, 1000); } 동작X componentDidMount() { setTimeout(() => { this.setState({ count: this.state.count + 1; }); }, 1000); } 동작O
2021.07.24 -
BFS 너비 우선 탐색
인접한 이웃 노드를 모두 방문한 다음에 이웃의 이웃 노드들을 방문한다. Point: Queue 사용 Pseudocode 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 void search(Node root) { Queue queue = new Queue(); root.marked = true; queue.enqueue(root); while(!queue.isEmpty()) { Node r = queue.dequeue(); visit(r); foreach(Node n in r.adjacent) { if(n.marked == false) { n.marked = true; queue.enqueue(n); } } } } Colored ..
2021.01.09 -
DFS 깊이 우선 탐색
분기를 전부 탐색한 뒤에 이웃 노드의 분기를 탐색 Point: 재귀, 노드 방문했는지 체크 Pseudocode void search(Node root){ if(root == null) return; root.visited = true; foreach(node in root.adjacent) { if(node.visited == false) { search(node); } } }
2021.01.09 -
이진트리(Binary Tree) 이진 탐색 트리(Binary Search Tree)
이진 트리는 각 노드가 최대 두개의 자식을 갖는 트리를 말한다. 이진 탐색 트리는 '모든 왼쪽 자식(child)
2021.01.08