분류 전체보기
-
Node.js와 Mysql 연동 에러Programming/react native 2020. 11. 23. 08:33
Connection.connect를 추가 후 실행을 하면 다음과 같은 오류가 발생하였다. 더보기 Error: ER_NOT_SUPPORTED_AUTH_MODE: Client does not support authentication protocol requested by server; consider upgrading MySQL client 해결책은 다음과 같았다. 1. Mysql installer 실행 2. server 옆에 위치한 reconfigure -> Auth 설정 3. legacy 선택
-
react native AVD로 구동 시 axios network errorProgramming/react native 2020. 11. 19. 03:41
node express로 서버 API를 구축한 후 axios로 데이터를 get 하려 했으나 계속해서 Netword Error가 발생하였다. https://github.com/axios/axios/issues/973 Axios doesn't work with Android (emulator) raising a Network Error · Issue #973 · axios/axios I'n new with React Native, and I was playing around with components and http ajax request, and all went fine with iOs emulator, until I thought to test on Android emulator. This is my ..
-
위상 정렬(Topology sort)Programming/알고리즘 2020. 11. 17. 15:36
위상 정렬은 순서가 정해져 있는 작업을 차례로 수행해야할 때 그 순서를 결정해주기 위해 사용하는 알고리즘이다. 위와 같은 경우 필요한 절차를 순서대로 밟아야 가능한 경우이며 이럴 때 사용되는 정렬이 위상 정렬이다. 위상 정렬 : 대학생 되기 -> 교수님 컨펌 -> 주제 선정 -> 개발하기 -> 졸작 완성 -> 졸작 전시 -> 졸업 ▷위상 정렬은 시작점을 알아야하기 때문에 위와 같이 사이클이 형성된 그래프에는 위상 정렬을 적용할 수 없다. 대학생의 졸업 과정을 번호를 부여하여 그래프로 나타내면 위상 정렬을 구현하는데 벡터와 큐를 사용하였다. 차수를 나타내는 배열을 선언하여 차수가 0인 것을 우선 전부 큐에 넣고 각 노드마다 인접 노드를 방문하며 차수를 1씩 감소시키며 큐가 빌 때까지 반복문을 사용하였다. ..
-
플로이드 와샬 알고리즘Programming/알고리즘 2020. 11. 16. 18:19
다익스트라 알고리즘은 한 정점에서 모든 정점으로의 최단 경로를 구하는 알고리즘인데 반해 플로이드 와샬 알고리즘은 모든 정점에서 모든 정점으로의 최단 경로를 구하는 알고리즘이다. 다익스트라 알고리즘은 최소의 비용을 가지는 간선을 선택하였다면, 플로이드 와샬 알고리즘은 특정 노드를 거쳐가는 경로에 대한 알고리즘이다. 그래프가 위와 같이 형성되었다고 가정하면 소스코드는 #include #define INF 1e9 using namespace std; int number = 4; int a[4][4] = { {0, 5, INF, 8}, {7, 0, 9, INF}, {2, INF, 0, 4}, {INF, INF, 3, 0} }; void floyd() { int result[4][4]; // 결과값을 담는 배열 ..
-
다익스트라(Dijkstra) 알고리즘Programming/알고리즘 2020. 11. 16. 02:08
다익스트라(Dijkstra) 알고리즘은 다니아닉 프로그래밍을 활용한 대표적인 최단 경로 탐색 알고리즘이다. 다익스트라 알고리즘은 특정한 하나의 정점에서 다른 모든 정점으로 가는 최단 경로를 알려준다(이때 음의 간선은 포함될 수 없다). 현실세계에서는 음의 간선이 존재하지 않기 때문에 다익스트라 알고리즘은 현실 세계에서 적용하기에 매우 적합한 알고리즘이라고 할 수 있다. 다익스트라 알고리즘이 다이나믹 프로그래밍 문제인 이유는 '최단 거리는 여러 개의 최단 거리로 이루어져있기 때문이다.' --> 현재까지 알고 있던 최단 경로를 계속해서 갱신한다! 이번 게시물에서의 그래프 예시는 위와 같이 정했다. 먼저, 배열을 사용해서 다익스트라 알고리즘을 완성해보자. #include using namespace std; ..
-
에라토스테네스의 체Programming/알고리즘 2020. 11. 15. 13:01
에라토스테네스의 체는 대표적인 소수(Prime Number) 판별 알고리즘이다. 에라토스테네스의 체 알고리즘은 한 두개의 소수를 판별하는 경우가 아닌 대량의 소수를 한꺼번에 판별할 때 사용한다. 에라토스테네스의 체는 우선 예를 들어 1부터 100까지의 수에서 소수를 판별한다고 하면 크기가 101인 int형 배열을 선언한다. 그리고 초기에 각 인덱스는 인덱스의 값으로 초기화를 시켜준다. 그 후 반복문을 통해 2의 배수, 3의 배수 ,4의 배수, ... 에 해당하는 인덱스의 값을 0으로 바꿔주는데 시간 복잡도를 줄이기 위해 이미 0인 부분은 continue를 사용하여 스킵되도록 한다. #include using namespace std; int number = 100; int a[101]; void isPr..
-
[c++] 백준 2133번 - 타일 채우기Programming/알고리즘 문제 2020. 11. 15. 10:50
#백준 2133번 URL 2133번: 타일 채우기 3×N 크기의 벽을 2×1, 1×2 크기의 타일로 채우는 경우의 수를 구해보자. www.acmicpc.net 이번에는 3*N 크기의 벽을 2*1, 1*2 크기의 타일로 채우는 경우의 수를 구하는 문제이다. 마찬가지로 다이나믹 프로그래밍을 이용하여 문제를 해결해보자. n=1일 경우, 타일을 채울 수 있는 경우의 수가 0이다. 즉, d[1] = 0. n=2일 경우, 아래와 같이 3가지의 방법이 있다. 즉, d[2] = 3이다. n=3일 경우는 3*1의 타일이 세개가 연달아 나타나는 모양이므로 d[3]=0이다. n=4일 경우는 n=2일 경우에 3*2 타일을 배치하는 경우이므로 d[4] = 3*d[2]의 경우의 수가 있다고 할 수 있다. 또한, n=6일 경우 d..
-
[c++] 백준 11726번 - 2*n 타일링Programming/알고리즘 문제 2020. 11. 7. 21:56
# 백준 11726번 URL 11726번: 2×n 타일링 2×n 크기의 직사각형을 1×2, 2×1 타일로 채우는 방법의 수를 구하는 프로그램을 작성하시오. 아래 그림은 2×5 크기의 직사각형을 채운 한 가지 방법의 예이다. www.acmicpc.net 다이나믹 프로그래밍 문제의 기본이라고 할 수 있는 '타일링' 문제이다. 기본적으로 다이나믹 프로그래밍에서는 규칙성을 찾아서 점화식을 찾는게 관건이라고 할 수 있다. 먼저, 수많은 타일이 이미 쌓여있고 1만큼 추가한다고 가정해보자! 위와 같은 경우, 이미 이전에 d(n-1)가짓 수로 타일을 배치한 상태에서 1가지의 방법으로 밖에 타일을 놓지 못한다. 두번째로, 2만큼 타일을 추가한다고 생각해보자. 이렇게 타일을 쌓는 방식은 앞서 고려했던 경우와 같으므로 고려..