각 정렬의 특징 및 차이점 하단의 사이트에 정리가 잘 되어있다. https://yabmoons.tistory.com/250 [얍문's Coding World..] [ 정렬 ] 정렬별 장단점 및 시간복잡도 이번 글에서는 정렬별 장단점 및 시간복잡도를 비교함으로써 어떤 정렬이 제일 좋고 나쁜지를 알아보자 ! 사실 이 정렬법이 무조건 제일 좋아요 ! 라고 말할 수 있는 정렬법은 없다. 왜냐하면 각 정렬법들이 좋을.. yabmoons.tistory.com 🖥️ CS/Data Structure & Algorithm 2020.03.12
#1181번 단어정렬 (c++) #include #include #include using namespace std; bool check(string a, string b){ if(a.length()==b.length()) return a> T; for(int i=0; i> s; v.push_back(s); } sort(v.begin(),v.end(),check); cout 🖥️ CS/Baekjoon Algorithms 2020.03.12
#11651번 좌표정렬하기2 (c++) #include #include #include using namespace std; bool compare(paira,pairb){ if(a.second==b.second){ return a.first T; for(int i=0; i> a >> b; v.push_back(pair(a,b));} sort(v.begin(),v.end(),compare); for(int i=0; i 🖥️ CS/Baekjoon Algorithms 2020.03.11
Episode 972 of Planet Money : The CryptoQueen (2) BARTLETT: Fans of hers would just write poetry, write music about her. They'd almost - they'd really sort of worship the woman. We heard a lot of songs that had been dedicated to Ruja. That was one of many. (SOUNDBITE OF SONG, "ONE FOR ALL") O'NEILL: (Singing) ...People all around carrying financial solution. ARONCZYK: There are all these fans and this whole community online. And Jamie's trying .. 🔑 English/NPR 2020.03.09
#11650번 좌표 정렬하기 (c++) #include #include #include using namespace std; int main(void){ ios_base::sync_with_stdio(false); cin.tie(NULL); int T; cin >> T; vector v; for(int i=0; i> a >> b; v.push_back(pair(a,b));} sort(v.begin(),v.end()); for(int i=0; i 카테고리 없음 2020.03.08
#1427번 소트인사이드 (c++) #include using namespace std; int main(void){ ios_base::sync_with_stdio(false); cin.tie(NULL); int num = 0; string s= ""; cin >> num; s=to_string(num); for(int i=0; i 🖥️ CS/Baekjoon Algorithms 2020.03.08
#2108번 통계학 (c++) #include #include using namespace std; void Questions(int T){ int arr[8001] = {0,}; //-4000과 4000도 포함 double sum = 0; // 전체 합 int middle = 0, mid_ans = (T/2)+(T%2); // 중앙값 1,2 int mid_ans_check = false; int often_used = 0, often_used_ans = 0; // 최빈값 1,2 bool often_used_check = false; // 최빈값이 여러개일 경우를 대비한 조건 int max = 0, min = 8000; // 최대값, 최소값 for(int i=0; i> a; arr[4000+a]++; sum += a; } for(in.. 🖥️ CS/Baekjoon Algorithms 2020.03.08
정렬(2) - 카운팅 정렬 / 퀵 정렬 / 병합 정렬 1. 계수 정렬 (Counting Sort) ※ 조건 : 입력값의 범위가 정해진 경우, 동시에 입력값의 최대값이 범위를 넘지 않는 경우에 사용 가능 'counting'이라는 단어를 해석하면 말 그대로 '수를 세는'이라는 뜻이 나온다. 예시를 보면 쉽게 풀리는 문제이다. 하단의 표를 참고해보자. 문제 : 5이하의 숫자까지 입력이 가능하며, 입력된 숫자들을 오름차 순으로 정렬하라. 입력값 3 3 3 2 1 2 4 5 5 해당 입력값을 1~5까지, 입력 된 숫자 크기로 정리를 해보면 하단과 같다. 배열 1 2 3 4 5 갯수 1 2 3 1 2 이제 어떻게 하면 될까? 답은 간단하다. for문으로 배열의 값만큼 해당 수를 출력해주면 된다. 관련 문제를 보고, 그에 대한 해답을 보면 군더더기 없이 정리가 된다. .. 🖥️ CS/Data Structure & Algorithm 2020.03.07
#include<algorithm> 그리고 sort() - (2) 링크 : https://www.youtube.com/watch?v=ZG68SXDtODM 공부 출처 링크 : 동빈나 유튜버 #inlcude - sort()와 연계했을때 알아두면 좋을 지식이 한 가지 더 있다. 바로 'pair'라는 기능이다. utility 헤더 파일에 포함된 기능인데, utility 외에도 algorithm이나 vector에도 포함되어있다. 보통 정렬해야하는 값이 2개 이상일때 많이 사용된다. 기본적인 pair의 사용법은 아래와 같다. #include #include #include using namespace std; int main(void) { ios_base::sync_with_stdio(false); cin.tie(NULL); pair p; p = make_pair(10, 'T').. 🖥️ CS/Data Structure & Algorithm 2020.03.05
#include<algorithm> 그리고 sort() - (1) https://www.youtube.com/watch?v=YJ-OUnZu7nQ 공부 출처 링크 : 동빈나 유튜버 정렬을 할 때 사용될 수 있는 기법은 다양하다. 선태정렬, 삽입정렬, 버블정렬, 병합정렬, 힙정렬. 당장 떠올릴 수 있는 기법만 해도 5가지이다. 하지만 매번 정렬을 정의해주는 것은 번거로울뿐더러, 구현 과정에서 실수의 여지도 있다. C++에서는 STL를 통해 오름차순 or 내림차순을 정렬할 수 있는 함수가 이미 구현되어있으므로, 해당 함수를 사용하면 굉장히 편리하다. #include 과 sort(정렬의 시작, 정렬의 끝)만 추가하면 기본적인 정렬이 완성된다. 기억해야할 점은 두 가지이다. sort(arr, arr+T)에서 T의 의미는 배열의 주소라기 보다는 배열이 가진 원소의 갯수라고 해석하.. 🖥️ CS/Data Structure & Algorithm 2020.03.05