컴퓨터/자료구조_알고리즘
-
백준 입출력 받기컴퓨터/자료구조_알고리즘 2021. 1. 16. 17:16
* node var fs = require('fs'); var input = fs.readFileSync("/dev/stdin").toString().split(/\r?\n/); // 출력은 process.stdout.write("hello "); // 줄바꿈없이 가능 * c++ 1) scanf 이용 #include using namespace std; // 문자열 받을 때 char a[600000]; scanf("%s",a); // 정수 받을 때 int m; scanf("%d", &m); // input이 띄어쓰기+target 문자인 경우 // scanf로 받은 이후 줄바꿈된 문자를 받을 때도 띄어쓰기 필요 char target; scanf(" %c", &target); // 여러 개 받을 때 int ..
-
Big-O컴퓨터/자료구조_알고리즘 2020. 1. 16. 08:41
* What is Big-O? Mathematical notation that describes algorithm efficiency 시간과 공간 복잡도를 표현할 수 있다. Describes the growth rate of algorithms 상수는 버린다(데이터가 증가함에 따른 증가율을 보기 위해 계산하기 때문) * O(1) : constant time data의 크기가 커져도 성능에 변화가 없다. * O(n) : for문 같은 경우 data의 크기가 커지면서 시간도 비례적으로 증가한다. *O(n^2) * O(n*m) : quadratic time * O(n^3) : polynomial / cubic time ex. 삼중 for문 * O(2^n) : exponential time ex) 피보나치 나선..