CS 60

Chapter 8: Tree

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Treedata 간에 hierarchy가 존재할 때 data를 표현하는 방식을 tree라고 한다. Nodes▶ Parents and Children Nodes▶ Root Node▶ Leaf Nodes Level▶ Level 0▶ Level 1▶ Level 2 Subtree▶ Left subtree▶ Right subtree Type Data▶ Char Type Data▶ Int Type Data Unique Path▶ A unique path exists from the root node to every other node.The path from E to Z: E -> C -> Z (acyclic structure)Binary Tree..

CS/자료구조 06:35:04

Socket Programming in C: Client-server example

Client-server example using TCPserver#include #include #include #include #include #include #include #include ▶ 헤더파일 포함int main(void)▶ main 함수 시작struct sockaddr_in sa;int SocketFD = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);▶ 소켓 주소 구조체 생성 + 소켓 생성socket(): 소켓 생성PF_INET: IPv4 프로토콜 사용SCOK_STREAM: TCP 사용IPPROTP_TCP: TCP 프로토콜socket()이 실패하면 -1 반환if (SocketFD == -1) { perror("cannot create socket"); e..

Socket Programming in C: Socket API functions

SocketSocket Address = TCP or UDP의 Port number + IP의 AddressSocket은 Transport Layer(4)와 Network Layer(3) 간 정보를 주고받기 위한 구멍이다. Header filesFileDescriptionsys/socket.h소켓 생성, 바인딩, 수신, 전송 등 소켓 함수들의 기본 정의 포함 (e.g., socket, bind, listen, accept)netinet/in.hAF_INET, AF_INET6, PF_INET, PF_INET6 등 표준 IP 주소와 TCP/UDP 포트 번호 정의sys/un.h동일 컴퓨터에서 실행되는 프로그램 간의 로컬 통신(UNIX 도메인 소켓 통신)을 위한 기능 제공arpa/inet.hIP 주소 변환 함수..

Programming Exercise: Lab #6

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement the SORTED LIST using doubly linked structure.1) insertItem(item): Insert the item to the proper position in the list.2) removeItem(item): Delete "item" in the listDeallocate (delete) the deleted item.template void DoubleSortedType::insertItem(ItemType item){ NodeType* newNode = new NodeType; NodeType* tempPtr = listData;..

CS/자료구조 2025.06.02

Chapter 7: Recursion

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.RecursionDefinitionsRecursive call: 재귀, 자기 자신을 호출하는 것Direct recursion: 직접적으로 자기 자신을 호출, e.g., a 함수가 a 함수 호출Indirect recursion: 다른 함수를 우회해 자기 자신을 호출, e.g., a 함수가 b 함수 호출 -> b가 a 함수 호출 Recursion의 필요성recursive한 프로그래밍은 모두 nonrecursive한 방법으로도 가능하다.즉, 반드시 필요한 것은 아니기에 recursion을 사용하지 않아도 모든 알고리즘 구현 가능하다. Recursive solutions can be less efficient than iterative solu..

CS/자료구조 2025.06.02

해킹 문제 풀이 실습 (웹 해킹) - 1

경희대학교 장대희 교수님의 정보보호 수업을 기반으로 정리한 글입니다.SQL Injection 소개SQL Injection악의적인 사용자가 보안상의 취약점을 이용하여, 임의의 SQL문을 주입하고 실행되게 하여데이터베이스가 비정상적인 동작을 하도록 조작하는 행위이다.▶ 예시Attacker는 OR 문과 "--" 주석을 활용하여 비밀번호 인증을 우회하여 데이터베이스에 접근OWASP Top 10▶ OWASP는 웹 애플리케이션 보안 개선을 위한 글로벌 비영리 조직 OWASP(오왑스)는 주로 웹에 관한 정보 노출, 악성 파일 및 스크립트, 보안 취약점 등을 연구하며, 10대 웹 애플리케이션의 취약점(OWASP Top 10)을 3-4년 주기로 발표한다. 이때 SQL Injection은 OWASP Top 10에 자주 들..

CS/정보보호 2025.05.21

Programming Exercise: Lab #5

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Exercise #1ProblemsImplement the UNSORTED LIST using linked structure and ANSWER the time complexity questions in the code.Destructor(): Deallocate (delete) all nodes in the list.appendItem(item): Append the item to the list (with the best time complexity)removeItem(item): Delete "item" in the list and Deallocate (delete) the deleted item.getItem(pos): Retur..

CS/자료구조 2025.05.20

Chapter 6: Linked Structures (2)

경희대학교 박제만 교수님의 자료구조 수업을 기반으로 정리한 글입니다.Linked StructuresReview▶ Big-O Comparison of Stack Operations▶ Big-O Comparison of Queue OperationsArray vs. Linked StructurePerformanceGenerally, array-based structures are faster than linked structures.Most operations are equally fast for both array and linked structures (O(1)).For size(), clear(), and destructor, the array is faster (O(1) vs. O(n)).But, a..

CS/자료구조 2025.05.20

Chapter 5: CPU Scheduling

경희대학교 허선영 교수님의 운영체제 수업을 기반으로 정리한 글입니다.Preemptive & Nonpreemptive Scheduling1. Nonpreemptive: 기존 프로세스 내쫓지 않고, 종료 or 대기까지 기다림 2. Preemptive: 기존 프로세스 내쫓음-> race conditionScheduling Criteria+ CPU Utilization: CPU가 busy 유지하도록 100% 이용+ Throughput: 단위시간 동안 완료한 프로세스 개수-> 클수록 좋음 - Turnaround Time: process 생성부터 종료까지의 시간- Waiting Time: ready queuescheduling affects only- Response Time: CPU에 처음 할당되기까지의 시간 (..

CS/운영체제 2025.05.07

Chapter 4: Thread & Concurrency

경희대학교 허선영 교수님의 운영체제 수업을 기반으로 정리한 글입니다.Thread: 독자적인 실행 흐름-> 서로 다른 코드 동시 실행 가능하나, 코어당 하나의 thread가 돌아감 multithreaded processs의 경우, 너무 많은 함수 호출 시 overflow 가능성 더 높다. ※ heap: 프로그램이 전체적으로 관리 및 스레드 간 데이터 공유에도 필요, e.g., 한 스레드가 메모리 할당, 다른 스레드가 사용 Benefits1. Responsiveness (반응성)2. Resource Sharing3. Economy: thread switching lower overhead than context switching4. Scalability (확장성): multicore일 때 이점Thread -..

CS/운영체제 2025.05.06