본문 바로가기

분류 전체보기

(644)
[OS/공룡책] Chapter 3. 프로세스 - 프로세스 간 통신 프로세스 간 통신 - 프로세스가 시스템에서 실행 중인 다른 프로세스들과 데이터를 공유하지 않는 프로세스는 독립적이다. 프로세스가 시스템에서 실행 중인 다른 프로세스들에 영향을 주거나 받는다면 이는 협력적인 프로세스들이다. - 협력적 프로세스들은 데이터를 교환할 수 있는, 즉 서로 데이터를 보내거나 받을 수 있는 프로세스 간 통신(interprocess communication, IPC) 기법이 필요하다. - 프로세스 간 통신에는 기본적으로 두 가지 모델이 있다. => 공유 메모리와 메시지 전달 - 공유 메모리 모델 : 공유 메모리 영역을 구축할 때만 시스템 콜이 필요하며, 공유 메모리 영역이 구축되면 모든 접근은 일반적인 메모리 접근으로 취급되어 커널의 도움이 필요 없다. 메시지 전달 모델보다 더 빠르다..
Do it! 알고리즘 코딩테스트 with JAVA - (15) 이진 탐색 이진 탐색 - 데이터가 정렬돼 있는 상태에서 원하는 값을 찾아내는 알고리즘 - 대상 데이터의 중앙값과 찾고자 하는 값을 비교해 데이터의 크기를 절반씩 줄이면서 대상을 찾는다. - 시간 복잡도는 O(logN)이다. - 정렬 데이터에서 원하는 데이터를 탐색할 때 사용하는 가장 일반적인 알고리즘이다. 핵심 이론 - 오름차순으로 정렬된 데이터에서 아래의 4가지 과정을 반복하며, 내림차순이라면 조건을 반대로 하여 과정을 반복한다. 현재 데이터셋의 중앙값을 선택한다. 중앙값 > 타깃 데이터일 때 중앙값 기준으로 왼쪽 데이터셋을 선택한다. 중앙값 < 타깃 데이터일 때 중앙값 기준으로 오른쪽 데이터셋을 선택한다. 과정 1~3을 반복하다가 중앙값 == 타깃 데이터일 때 탐색을 종료한다. 문제 풀이 https://yuri..
[백준/자바] 1300 - K번째 수 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int k = sc.nextInt(); long result = 0; long start = 1, end = k; while (start
[백준/자바] 2343 - 기타 레슨 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] arr = new int[N]; int start = 0; int end = 0; for (int i = 0; i < N; i++) { arr[i] = sc.nextInt(); if (start < arr[i]) start = arr[i]; end += arr[i]; } while (start middle) { count++; sum = 0; } sum += arr[i]; } if (sum != 0..
[백준/자바] 1316 - 그룹 단어 체커 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int result = 0; for (int i = 0; i < N; i++) { char[] arr = sc.next().toCharArray(); int[] index = new int[26]; for (int j = 0; j < 26; j++) { index[j] = -1; } boolean isGroupWord = true; for (int k = 0; k < arr.length; k++) { if (index[arr[k] - 97] != ..
[백준/자바] 10814 - 나이순 정렬 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine..
[리트코드/자바] 1920. Build Array from Permutation class Solution { public int[] buildArray(int[] nums) { int[] result = new int[nums.length]; for (int n : nums) { result[n] = nums[nums[n]]; } return result; } }
[리트코드/자바] 1929. Concatenation of Array class Solution { public int[] getConcatenation(int[] nums) { int[] result = new int[nums.length * 2]; System.arraycopy(nums, 0, result, 0, nums.length); System.arraycopy(nums, 0, result, nums.length, nums.length); return result; } } class Solution { public int[] getConcatenation(int[] nums) { int[] result = new int[nums.length * 2]; for (int i = 0; i < nums.length; i++) { result[i] = nums[i]; re..