637. Average of Levels in Binary Tree
·
Coding Test/LeetCode
난이도: 쉬움 (Easy)링크: LeetCode 637풀이 날짜: 2025/10/09(품) 1. 문제 이해 주어진 이진 트리에서 각 레벨(level)별 노드 값의 평균을 구해야 한다.즉, 루트부터 시작해 같은 깊이의 노드들을 모아 평균을 내고, 이를 배열로 반환한다.2. 접근 방식 및 자료 구조이 문제는 두 가지 방식으로 접근할 수 있는데, 나의 경우 깊이 우선 탐색 방식으로 풀었다. DFS 방식 (깊이 우선 탐색)각 노드를 방문하면서 depth를 추적한다.depth별로 값을 모으기 위해 result를 객체 형태로 관리한다.예: { 0: [3], 1: [9, 20], 2: [15, 7] }모든 노드를 탐색한 후, 각 배열의 평균을 계산한다.BFS 방식 (너비 우선 탐색)큐(queue)를 사용해 레벨 단위..
199. Binary Tree Right Side View
·
Coding Test/LeetCode
난이도: 중간 (Medium)링크: LeetCode 199풀이날짜: 2025/10/03(못품), 2025/10/09(품) 1. 문제 이해 주어진 이진 트리에서, 오른쪽 측면에서 보이는 노드들의 값을 반환해야 하는 문제로,각 레벨(level)마다 가장 오른쪽에 위치한 노드만 결과값으로 포함시켜야 한다.2. 접근 방식 및 자료 구조나는 DFS 방식으로 풀었으나, 문제 의도에는 BFS 방식이 더 적절해 보인다. 방법 1: DFS (오른쪽 우선 탐색) 깊이(Depth)를 추적하면서 오른쪽 자식부터 탐색한다.각 깊이에서 처음 방문한 노드가 그 레벨의 가장 오른쪽 노드가 된다.depth === result.length 조건을 통해 해당 깊이에서 아직 추가되지 않은 노드만 결과에 넣는다./** * Definition..
Linear and Nonlinear Data Structures(In progress)
·
Computer Science/Data Structure
Linear Data StructuresA linear data structure is a structure where elements are arranged in a sequential order.Examples: Linked List, Array, Vector, Stack, Queue.1) Linked ListA structure where nodes containing data are connected via pointers, maximizing space efficiency.Insertion/Deletion: O(1)Search/Access: O(n) OperationTime ComplexityNotesLookupO(n)Must traverse from headAssignO(n)Same reaso..
URI, URL and URN
·
Computer Science/Network
URI, URL and URNA Uniform Resource Identifier (URI)is a string of characters that uniquely identify a name or a resource on the internet.URIs have two specializations known as Uniform Resource Locator (URL), and Uniform Resource Name (URN).A URI identifies a resource by name, location, or both.A Uniform Resource Locator (URL)is a type of URI that specifies not only a resource, but **how to reach..
Structure of CPU scheduling algorithm and each algorithm
·
Computer Science/Operating System
CPU SchedulerThe CPU scheduler assigns CPU time to threads (units of work) from processes according to a scheduling algorithm.These algorithms aim to:Maximize CPU utilizationMaximize the amount of work done in a given timeMinimize the number of processes in the ready queueMinimize response time Non-Preemptive SchedulingIn non-preemptive scheduling, a process voluntarily releases the CPU;the OS d..
Shared resources, Critical sections, and Deadlock
·
Computer Science/Operating System
Shared ResourceA shared resource refers to resources or variables within a system that multiple processes or threads can access concurrently — such as monitors, printers, memory, files, or data.When two or more processes attempt to read or write to a shared resource simultaneously,this situation is called a race condition — where the timing or order of access affects the outcome.Critical Section..