전체 글
-
[백준] 1992번 : 쿼드트리 - 자바(JAVA)알고리즘/백준 2022. 3. 29. 00:01
https://www.acmicpc.net/problem/1992 1992번: 쿼드트리 첫째 줄에는 영상의 크기를 나타내는 숫자 N 이 주어진다. N 은 언제나 2의 제곱수로 주어지며, 1 ≤ N ≤ 64의 범위를 가진다. 두 번째 줄부터는 길이 N의 문자열이 N개 들어온다. 각 문자열은 0 또 www.acmicpc.net 문제 해석 2차원 배열에 0과 1로 이루어져 있는데 흑백 영상을 압축하여 표현하는 데이터 구조로 쿼드 트리라는 방법이 존재한다. 주어진 영상이 모두 0으로만 되어 있으면 압축결과는 "0"이 되고 모두 1로만 되어 있으면 압축결과는 "1"이 된다. 만약 0과 1이 섞여 있으면 전체를 한 번에 나타내지 못하고 왼쪽 위, 오른쪽 위, 왼쪽 아래, 오른쪽 아래 영상을 나누어 압축하게 됩니다...
-
Database Sharding(샤딩)이란?CS/데이터베이스 2022. 3. 28. 14:03
DB Sharding이란? shard의 사전적 의미는 (유리·금속 등의) 조각, 파편입니다. 데이터베이스의 측면에서 본다면 sharding은 데이터베이스를 조각으로 나누는 것으로 생각해볼 수 있습니다. 샤딩(Sharding)은 수평 분할(Horizontal Partitioniong)과 관련된 데이터베이스 아키텍처 중 하나로써 한 테이블의 row들을 여러 개의 서로 다른 테이블, 즉 파티션으로 분리하는 방식입니다. DB Sharding을 하는이유? 하나의 DB에 데이터가 늘어나면 용량 이슈도 생기고, 느려지는 CRUD는 자연스럽게 서비스 성능에 영향을 주게 됩니다. 따라서 애플리케이션이 얼마나 인기를 끌지 또는 얼마나 오랫동안 그 인기를 유지할지 예측을 하기 어렵기 때문에 데이터베이스를 동적으로 확장할 수..
-
4012. [모의 SW 역량테스트] 요리사알고리즘/SW Expert Academy 2022. 3. 28. 00:01
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWIeUtVakTMDFAVH SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 문제 해석 두 명의 손님에게 음식을 제공 두 손님은 식성이 비슷해서, 최대한 비슷한 맛의 음식으로 제공하고자 함 N개의 식재료가 존재 식재료를 각각 N/2 씩 나누어 요리하려고 함 (N = 짝수) 음식의 맛은 음식을 구성하는 식재료의 조합에 따라 달라짐 조합이라는 시너지가 존재하며 시너지 배열을 통해 계산하여 이 시너지가 최소가 되도록 구현해야 한다. 예를 들어 음식 A를 위해 식재료 2, 3, 6..
-
[백준] 11725번 : 트리의 부모 찾기 - 자바(JAVA)알고리즘/백준 2022. 3. 27. 00:01
https://www.acmicpc.net/problem/11725 11725번: 트리의 부모 찾기 루트 없는 트리가 주어진다. 이때, 트리의 루트를 1이라고 정했을 때, 각 노드의 부모를 구하는 프로그램을 작성하시오. www.acmicpc.net 문제 해석 루트가 없는 트리가 주어집니다. 이때 트리의 루트를 1이라고 정했을 때, 각 노드의 부모를 구하는 프로그램을 작성하시오 문제 풀이 전 설계 우선 그래프 탐색 문제라고 생각을 했습니다. 따라서 2차원 배열 graph [i][j]를 선언하고 정점 i와 정점 j가 연결되어있으면 1 그렇지 않으면 0으로 표기합니다. 문제 풀이 하면서 생각한 점 하지만 우리가 원하는 것은 부모의 노드를 찾아야 합니다. 단순히 graph 2차원 배열에 정점이 연결된 것만으로는..
-
[백준] 1074번 : Z - 자바(JAVA)알고리즘/백준 2022. 3. 26. 00:01
https://www.acmicpc.net/problem/1074 1074번: Z 한수는 크기가 2N × 2N인 2차원 배열을 Z모양으로 탐색하려고 한다. 예를 들어, 2×2배열을 왼쪽 위칸, 오른쪽 위칸, 왼쪽 아래칸, 오른쪽 아래칸 순서대로 방문하면 Z모양이다. N > 1인 경우, 배열을 www.acmicpc.net 문제 해석 크기가 2^N x 2^N인 2차원 배열을 Z 모양으로 탐색하고자 합니다. N > 1 인 경우 , 배열의 크기가 2^(N-1) x 2^(N-1)로 4등분 한 뒤에 재귀적으로 순서대로 방문합니다. N=3일 때 예시 문제 풀이 전 설계 재귀 함수를 잘 작성해야 할 것 같다. 1. r x c 배열을 생성한 후 값을 0부터 하나씩 채워가기 -> array [r][c]의 값 출력 2. a..
-
가장 빠르게 소수를 찾는 방법알고리즘/알고리즘 2022. 3. 26. 00:01
소수란? 자신보다 작은 두 개의 자연수를 곱하여 만들 수 없는, 1보다 큰 자연수입니다. 방법 1: 가장 간단한 방법 N이 소수인지 판별하기 위해서는 2 ~ N-1까지 나누어서 하나라도 나누어 떨어지는가를 확인하는 방법이 있습니다. 이는 한개의 숫자에 대해 소수인지 파별하기 위해서는 O(N)의 시간 복잡도를 가지며 N개의 수에 대해서는 O(N^2)의 시간 복잡도를 가집니다. 방법 2 : 제곱근 만약 12에 대하여 소수를 판별하려고 합니다. 12의 약수는 1, 2, 3, 4, 6, 12를 가집니다. 가장 간단한 방법처럼 12를 2부터 N-1까지 나누어보려고 할 때 2* 6 = 6 * 2의 성질을 이용한 방법입니다. (xy = yx) 제곱근을 기준으로 제좁근까지 나누어 떨어지는지 여부를 조사하면 더 빠르게 ..
-
HTTP와 HTTPS의 차이점(HTTPS의 동작과정)CS/네트워크 2022. 3. 25. 17:00
HTTP란? HTTP는 HyperText Transfer Protocol의 약자로 HTML을 전송하는 프로토콜로 시작하였으나 현재는 모든 것을 HTTP 메시지를 통해 전송합니다. 즉, 웹 상에서 클라이언트와 서버가 서로 정보를 주고받을 수 있도록 하는 규약입니다. 다음 그림은 HTTP 메시지의 예시입니다. Message Header와 Message Body로 이루어져 있습니다. Message Header는 HTTP통신에 사용되는 여러 조건 또는 속성 등을 포함됩니다. Message Body는 실제 요청하거나 요청받는 내용이 포함됩니다. 조금 더 디테일하게 보고 싶다면 다음 글을 참고하시면 좋을 것 같습니다. https://junuuu.tistory.com/36?category=974977 HTTP 기본 ..
-
[백준] 2839번 : 설탕 배달 - 자바(JAVA)알고리즘/백준 2022. 3. 25. 00:01
https://www.acmicpc.net/problem/2839 2839번: 설탕 배달 상근이는 요즘 설탕공장에서 설탕을 배달하고 있다. 상근이는 지금 사탕가게에 설탕을 정확하게 N킬로그램을 배달해야 한다. 설탕공장에서 만드는 설탕은 봉지에 담겨져 있다. 봉지는 3킬로그 www.acmicpc.net 문제 해석 설탕을 정확하게 N 킬로그램 배달해야 한다. 설탕 봉지는 3kg 와 5kg 봉지가 있다. 최대한 적은 봉지를 들고 가려고 할 때 봉지 몇 개를 들고 가야 할까? 정확하게 N킬로그램을 만들 수 없다면 -1을 출력합니다. 문제 풀이 전 설계 N의 범위가 3~5000이기 때문에 완전탐색으로 하기는 힘들 것 같습니다. 최대한 적은 봉지를 들고가야 하기 때문에 5kg 봉지를 들고 가는 것이 제일 좋습니다...