목록2022/01/21 (5)
Developer_Neo
https://www.acmicpc.net/problem/2309 2309번: 일곱 난쟁이 아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다. www.acmicpc.net 문제 왕비를 피해 일곱 난쟁이들과 함께 평화롭게 생활하고 있던 백설공주에게 위기가 찾아왔다. 일과를 마치고 돌아온 난쟁이가 일곱 명이 아닌 아홉 명이었던 것이다. 아홉 명의 난쟁이는 모두 자신이 "백설 공주와 일곱 난쟁이"의 주인공이라고 주장했다. 뛰어난 수학적 직관력을 가지고 있던 백설공주는, 다행스럽게도 일곱 난쟁이의 키의 합이 100이 됨을 기억해 냈다. 아홉 난쟁이의 키가 주어졌을 때, 백설공주를 ..
링크드(연결) 리스트(Linked List) 왜? 배열의 경우로 데이터를 넣었을 때 미리 공간을 정해놓아야한다. 만약 데이터가 너무 커서 공간을 넘어가서 데이터가 끊어지게 되면 안되기 때문에 연결리스트가 나오게 된 이유가 있다. - 노드를 연결시킨 자료구조 - 노드가 데이터와 포인터를 가지고 한 줄로 연결되어 있는 방식으로 데이터를 저장하는 자료 구조 위 그림처럼 데이터를 담고 있는 노드들이 연결되어 있는데, 노드의 포인터가 다음이나 이전의 노드와의 연결을 담당함. C언어에서는 주요한 데이터 구조이지만, 파이썬은 리스트 타입이 링크드 리스트의 기능을 모두 지원 노드(Node): 데이터 저장 단위 (데이터값, 포인터) 로 구성 포인터(pointer): 각 노드 안에서, 다음이나 이전의 노드와의 연결 정보를..
스택(Stack) 제한적으로 접근할 수 있는 나열 구조 (데이터를 제한적으로 접근할 수 있는 구조) 접근 방법은 언제나 목록의 끝에서만 일어난다 (한쪽 끝에서만 자료를 넣거나 뺄 수 있는 구조) 가장 나중에 쌓은 데이터를 가장 먼저 빼낼 수 있는 데이터 구조 LIFO(Last In, Fisrt Out) 또는 FILO(First In, Last Out) 데이터 관리 방식 LIFO: 마지막에 넣은 데이터를 가장 먼저 추출하는 방식 FILO: 처음에 넣은 데이터를 가장 마지막에 추출하는 방식 활용 컴퓨터 내부의 프로세스 구조의 함수 동작 방식 프로세스 메모리 구조 - stack 영역 컴퓨터에서 포인터라고 하는 자료의 위치 표시자와 넣고 빼는 명령어를 사용해서 스택을 이용 장단점 장점 구조가 단순해 구현이 쉽다..
큐(Queue) 먼저 집어 넣은 데이터가 먼저 나오는 FIFO(First In First Out)구조로 저장하는 형식 또는 반대로 LILO(Last-In, Last-Out) 방식 넣는 데이터가 같은 자료형이 아니어도 됨. 표를 사러 일렬로 늘어선 사람들로 이루어진 줄을 말하기도 하며, 먼저 줄을 선 사람이 먼저 나갈 수 있는 상황을 연상하면 된다. (출처) 스택과 꺼내는 순서가 반대 장단점 데이터 접근, 삽입, 삭제가 빠르다. 큐 역시 스택과 마찬가지로 중간에 위치한 데이터에 대한 접근이 불가능하다 큐(Queue)의 핵심 연산 Enqueue 큐에 데이터를 넣는 기능 반환 X Dequeue 큐에서 데이터를 꺼내는 기능 데이터 반환 다른 연산들 QueueInit 큐의 초기화를 진행한다. (큐 생성 후 제일 ..
2022.01.16 - [분류 전체보기] - [python] 인덱싱(indexing), 슬라이싱(slicing) with 문자열, 리스트, 튜플 [python] 인덱싱(indexing), 슬라이싱(slicing) with 문자열, 리스트, 튜플 인덱싱(indexing) - 시퀀스 자료형인 문자열, 리스트, 튜플에 사용가능 - 시퀀스 자료형에 부여된 번호를 의미한다. 특징 양수 인덱스 앞에서부터 시작하는 것으로 0부터 시작 음수 인덱스 뒤에서부 devloper-dreaming.tistory.com 배열 연관된 데이터를 하나의 변수에 그룹핑해서 관리하기 위한 방법 같은 종류의 데이터를 효율적, 순차적으로 관리, 저장하기 위해 사용한다. 파이썬에서는 리스트자료형이 배열 기능을 제공한다. 장점 - 인덱스 번호로..