목록2022/01/28 (2)
Developer_Neo
정렬이란 어떤 데이터들이 주어졌을 때 이를 정해진 순서대로 나열하는 것 정렬 종류 버블 정렬 삽입 정렬 선택 정렬 퀵 정렬 병합 정렬 평균 시간복잡도 최악의 시간복잡도 최선의 시간복잡도 O(n) O(n) Runtime (60,000개 입력시) 단위 : sec 22.894 7.438 10.842 0.014 0.026 버블 정렬 (bubble sort) 란? 두 인접한 데이터를 비교해서, 앞에 있는 데이터가 뒤에 있는 데이터보다 크면, 자리를 바꾸는 정렬 알고리즘 서로 비교해서 큰 값을 뒤로 보내는 것이다. (오름차순으로) 핵심 SWAP 방식 2021.09.04 - [프로그래밍/알고리즘 with Java] - [자바] 정렬 알고리즘 - 버블정렬 [자바] 정렬 알고리즘 - 버블정렬 버블 정렬(Bubble So..
힙 (Heap) 트리를 기반으로 해 어떠한 목적에 따라 변환시킨 자료구조이다. 데이터에서 최대값과 최소값을 빠르게 찾기 위해 고안된 완전 이진 트리(Complete Binary Tree) 완전 이진 트리: 노드를 삽입할 때 최하단 왼쪽 노드부터 차례대로 삽입하는 트리 사용하는 이유 배열에 데이터를 넣고, 최대값과 최소값을 찾으려면 O(n) 이 걸림 이에 반해, 힙에 데이터를 넣고, 최대값과 최소값을 찾으면, O(logn) 이 걸림 우선순위 큐와 같이 최대값 또는 최소값을 빠르게 찾아야 하는 자료구조 및 알고리즘 구현 등에 활용됨 구조의 조건 각 노드의 값은 해당 노드의 자식 노드가 가진 값보다 크거나 같다. (최대 힙의 경우) 최소 힙의 경우는 각 노드의 값은 해당 노드의 자식 노드가 가진 값보다 크거나..