전체 글
-
[자료구조] Tree 개념/정의코딩(Coding)/자료구조 2021. 1. 5. 13:26
Tree 트리(Tree)는 하나 이상의 노드들로 구성된 유한집합이다. 트리는 가장 최상위에 존재하는 Root 노드와 그 노드서부터 내려가는 하위노드들의 구성으로 표현된다. 아래 그림을 보자 그림처럼 Tree를 표현하면 위 그림같이 될 것이다. Root노드인 A는 하위 노드인 B,C,D노드가 있고 각각의 하위노드들은 또 자신들만의 하위노드들이 있다. 여기서 A에 대해 subTree는 B노드와 그의 하위 노드들과 C,D노드와 각각의 하위노드들이 될 것이다. Tree 설계 그렇다면 Tree는 어떻게 설계하면 좋을까? 생각해보자 일단 노드 A는 data와 sub-Node를 저장할 Node변수 3개가 필요할 것이다. 그렇다면 아래 그림 처럼 Tree의 노드구조를 설명할 수 있겠다. 자 그럼 문제는 다음이다. 가령..
-
[백준] 10871번: X보다 작은 수코딩(Coding)/백준 문제풀이 2021. 1. 4. 16:42
링크: www.acmicpc.net/problem/10871 10871번: X보다 작은 수 첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다. www.acmicpc.net X보다 작은 수 문제 정수 N개로 이루어진 수열 A와 정수 X가 주어진다. 이때, A에서 X보다 작은 수를 모두 출력하는 프로그램을 작성하시오. 입력 첫째 줄에 N과 X가 주어진다. (1 ≤ N, X ≤ 10,000) 둘째 줄에 수열 A를 이루는 정수 N개가 주어진다. 주어지는 정수는 모두 1보다 크거나 같고, 10,000보다 작거나 같은 정수이다. 출력 X보다 작은 수를 입력받은 순서대..
-
[백준] 2739번: 구구단코딩(Coding)/백준 문제풀이 2021. 1. 4. 16:36
링크: www.acmicpc.net/problem/2739 2739번: 구구단 N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. www.acmicpc.net 구구단 성공분류 문제 N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다. 입력 첫째 줄에 N이 주어진다. N은 1보다 크거나 같고, 9보다 작거나 같다. 출력 출력형식과 같게 N*1부터 N*9까지 출력한다. 문제접근 해당 문제는 입력받은 n에대해 구구단을 출력하는 문제이다. 여기서 요구하는 것은 for 혹은 while로 반복문을 사용할 수 있는가 이다. 정말 간단하게 반복문을 사용해 해결이 가능하다. 코드 """ 백준 알고리즘 2739번: 구구단 h..
-
[백준] 14681번: 사분면 고르기코딩(Coding)/백준 문제풀이 2021. 1. 4. 16:31
링크: www.acmicpc.net/problem/14681 14681번: 사분면 고르기 점 (x, y)의 사분면 번호(1, 2, 3, 4 중 하나)를 출력한다. www.acmicpc.net 사분면 고르기 문제 흔한 수학 문제 중 하나는 주어진 점이 어느 사분면에 속하는지 알아내는 것이다. 사분면은 아래 그림처럼 1부터 4까지 번호를 갖는다. "Quadrant n"은 "제n사분면"이라는 뜻이다. 예를 들어, 좌표가 (12, 5)인 점 A는 x좌표와 y좌표가 모두 양수이므로 제1사분면에 속한다. 점 B는 x좌표가 음수이고 y좌표가 양수이므로 제2사분면에 속한다. 점의 좌표를 입력받아 그 점이 어느 사분면에 속하는지 알아내는 프로그램을 작성하시오. 단, x좌표와 y좌표는 모두 양수나 음수라고 가정한다. 입력..
-
[백준] 1436번: 영화감독 숌코딩(Coding)/백준 문제풀이 2021. 1. 4. 14:46
링크: www.acmicpc.net/problem/1436 1436번: 영화감독 숌 666은 종말을 나타내는 숫자라고 한다. 따라서, 많은 블록버스터 영화에서는 666이 들어간 제목을 많이 사용한다. 영화감독 숌은 세상의 종말 이라는 시리즈 영화의 감독이다. 조지 루카스는 스타 www.acmicpc.net 영화감독 숌 문제 666은 종말을 나타내는 숫자라고 한다. 따라서, 많은 블록버스터 영화에서는 666이 들어간 제목을 많이 사용한다. 영화감독 숌은 세상의 종말 이라는 시리즈 영화의 감독이다. 조지 루카스는 스타워즈를 만들 때, 스타워즈 1, 스타워즈 2, 스타워즈 3, 스타워즈 4, 스타워즈 5, 스타워즈 6과 같이 이름을 지었고, 피터 잭슨은 반지의 제왕을 만들 때, 반지의 제왕 1, 반지의 제왕 ..
-
[자료구조] Doubly Linked List코딩(Coding)/자료구조 2020. 12. 31. 13:40
Doubly Linked List 지난 포스팅에서 언급했던 Singly Linked List을 보완하여 정의된 Doubly Linked List이다. 단일 링크드 리스트와 다르게 한쪽 방향으로만 pointer가 있는 것이 아닌 좌우로 pointer가 존재한다. 좌우로 pointer를 표현했기 때문에 좀던 자유롭게 Node에 접근할 수 있다. 아래는 지난 글인 Single Linked List이다. jsy-coding-blog.tistory.com/9 [자료구조] Single Linked List Single Linked List Linked List는 많은 양의 자료이동이 필요할때 사용하는 자료구조이다. Linked List는 Node라는 단일된 객체들의 연결로 표현한다. 오늘 포스팅에서 소개할 Sing..
-
[백준] 1924번: 2007년코딩(Coding)/백준 문제풀이 2020. 12. 31. 12:27
링크: www.acmicpc.net/problem/1924 1924번: 2007년 첫째 줄에 빈 칸을 사이에 두고 x(1 ≤ x ≤ 12)와 y(1 ≤ y ≤ 31)이 주어진다. 참고로 2007년에는 1, 3, 5, 7, 8, 10, 12월은 31일까지, 4, 6, 9, 11월은 30일까지, 2월은 28일까지 있다. www.acmicpc.net 2007년 성공분류 문제 오늘은 2007년 1월 1일 월요일이다. 그렇다면 2007년 x월 y일은 무슨 요일일까? 이를 알아내는 프로그램을 작성하시오. 입력 첫째 줄에 빈 칸을 사이에 두고 x(1 ≤ x ≤ 12)와 y(1 ≤ y ≤ 31)이 주어진다. 참고로 2007년에는 1, 3, 5, 7, 8, 10, 12월은 31일까지, 4, 6, 9, 11월은 30일까지..
-
[백준] 1920번: 수 찾기코딩(Coding)/백준 문제풀이 2020. 12. 30. 12:15
www.acmicpc.net/problem/1920 1920번: 수 찾기 첫째 줄에 자연수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 N개의 정수 A[1], A[2], …, A[N]이 주어진다. 다음 줄에는 M(1 ≤ M ≤ 100,000)이 주어진다. 다음 줄에는 M개의 수들이 주어지는데, 이 수들 www.acmicpc.net 수 찾기 성공분류 문제 N개의 정수 A[1], A[2], …, A[N]이 주어져 있을 때, 이 안에 X라는 정수가 존재하는지 알아내는 프로그램을 작성하시오. 입력 첫째 줄에 자연수 N(1 ≤ N ≤ 100,000)이 주어진다. 다음 줄에는 N개의 정수 A[1], A[2], …, A[N]이 주어진다. 다음 줄에는 M(1 ≤ M ≤ 100,000)이 주어진다. 다음 ..