본문 바로가기

cs50

[CS50] Week3: Algorithms (1) Linear Search -순서대로 선형 검색 -7개의 락커에서 50이 들어있는 락커를 처음부터 순서대로 열어가면서 찾기 (2) Binary Search -미리 정렬이 되어있을 때 사용 가능 -중간 락커를 열어서 확인해보고 찾으려는 숫자가 확인한 숫자보다 작으면 왼쪽에서 search, 크면 오른 쪽에서 search (3) Big O, Big Omega, Big Theta Notation -알고리즘의 효율성은 대개 실행 시간의 차수로 표현되며, 그래프의 모양이 중요 -O는 최악의 경우, Ω(omega)는 최적의 경우, Θ(theta)는 상한과 하한이 동일한 경우 Linear Search: O(n), Ω(1) Binary Search: O(log n), Ω(1) (4) Data Structure -s.. 더보기
[CS50] Week2: 컴파일링, 디버깅, 배열, 문자열, Command-Line Arguments, Exit Status, Cryptography, 2주차 과제 (1) Scrabble In the game of Scrabble, players create words to score points, and the number of points is the sum of the point values of each letter in the word. For example, if we wanted to score the word “CODE”, we would note that the ‘C’ is worth 3 points, the ‘O’ is worth 1 point, the ‘D’ is worth 2 points, and the ‘E’ is worth 1 point. Summing these, we get that “CODE” is worth 7 points. In a.. 더보기
[CS50] Week2: 컴파일링, Array, String 소스코드 -> 컴파일러 -> 머신코드 code hello.c // 소스코드 파일 생성 make hello // 컴파일 ./hello // 코드 실행 실제 컴파일링 과정 (1) Preprocessing (전처리 단계): 소스 코드에서 주석 제거, 매크로 확장 등의 작업을 수행. 전처리기는 #로 시작하는 지시문을 처리하여 소스 코드 수정. (2) Compiling (컴파일링): .c 파일을 컴파일러를 사용하여 목적 코드인 어셈블리 코드로 변환. (3) Assembling (어셈블링): 어셈블러를 사용하여 목적 코드를 기계어 코드로 변환. (4) Linking (링킹): 여러 목적 코드 파일과 라이브러리를 결합하여 실행 파일 생성. 링커가 최종적으로 실행 가능한 프로그램을 만듦. 배열, 문자열 -문자열은 실제.. 더보기
[CS50] Week 1: 데이터 타입, 연산자, 조건문, 반복문, 커맨드라인(CLI), 1주차 과제 Problem set 1 (1) Hello, world In a file called hello.c, in a folder called world, implement a program in C that prints hello, world\n, and that’s it! (2) Hello, it's me In a file called hello.c, in a folder called me, implement a program in C that prompts the user for their name and then says hello to that user. For instance, if the user’s name is Adele, your program should print hello, Adele\n.. 더보기