💻 computer science
-
📒 위상정렬💻 computer science/🤔 알고리즘 2024. 6. 17. 15:46
💡 위상 정렬(Topological Sort)이란?유향 그래프의 꼭짓점들(vertex)을 변의 방향을 거스르지 않도록 나열하는 것 그래프와 관련된 알고리즘 중 하나방향 그래프에서 간선으로 주어진 정점 간 선후 관계를 위배하지 않도록 나열하는 정렬 ❗선후 관계가 정의된 그래프 구조에서 정렬을 하는데 사용할 수 있다. ⚠️ 그래프내에 사이클이 존재하는 경우에는 올바른 위상 정렬이 존재할 수 없다.선후 관계에 모순이 생기기 때문 따라서, 위상 정렬은 사이클이 존재하지 않는 방향 그래프에서만 잘 정의가 된다. 사이클이 존재하지 않는 방향 그래프 = DAG(Directed Acyclic Graph) 🧑🏻💻 구현 🏃 구현 순서 1️⃣ 먼저, 위상 정렬상에서 제일 앞에 오는 정점(A, C, G)로 가능..
-
MySQL - 트랜잭션 격리 수준 실습💻 computer science/📦 database 2024. 5. 11. 21:24
⚙️ 실습 세팅트랜잭션 격리 수준을 실습해보기 위해서 테이블을 만들고 데이터를 넣어두었다. 👤 Member TableCREATE TABLE MEMBER ( id bigint auto_increment primary key, name varchar(255) not null, constraint UK_name unique (name)); ➕ 데이터 추가INSERT INTO MEMBER (id, name) VALUES(1, 'Beomsic');INSERT INTO MEMBER (id, name) VALUES(2, 'Beomseok');INSERT INTO MEMBER (id, name) VALUES(3, 'KO'); 💻 2개의 데이터베이스 세션 설정set autocommit = FALSE; // 현..
-
MySQL - 스토리지 엔진 수준의 락💻 computer science/📦 database 2024. 5. 11. 14:25
🔒 MySQL 의 락MySQL에서 사용되는 락은 크게 스토리지 엔진 레벨과 MySQL 엔진 레벨로 나눌 수 있다. 🧩 스토리지 엔진 레벨의 락테이블의 데이터를 다루기 위한 락 🧩 MySQL 엔진 레벨의 락테이블이나 데이터베이스 등과 같은 부분을 위한 락 🆎 스토리지 엔진 레벨의 락의 종류레코드 락 (Record Lock)갭 락 (Gap Lock)넥스트 키 락 (Next Key Lock)자동 증가 락 (Auto Increment Lock) 1️⃣ 레코드 락🎯 레코드 락은 테이블 레코드 자체를 잠그는 락을 의미한다. ❗MySQL에서 레코드 락은 테이블의 레코드가 아닌 인덱스의 레코드를 잠근다는 점이 다른 DBMS와의 차이점이다.MySQL에서는 레코드 자체를 잠그는 것이 아닌 인덱스를 잠그기 때문에..
-
📂 MySQL - 트랜잭션 격리 수준💻 computer science/📦 database 2024. 5. 11. 14:14
🔝 트랜잭션 격리 수준 🌟모든 DB 트랜잭션은 격리수준을 갖고 있어야 한다.서버 환경에서는 여러 개의 트랜잭션이 동시에 진행될 수 있다.적절하게 격리수준을 조정해 가능한 한 많은 트랜잭션을 동시에 진행시키면서도 문제가 발생하지 않게 해야 한다. 🌠 트랜잭션 격리 수준 격리 수준설명 발생하는 이상 현상SERALIZABLE트랜잭션을 순차적으로 진행- 여러 트랜잭션이 동시에 같은 행에 접근할 수 없다.- deadlock이 일어날 확률도 높고 성능이 가장 떨어짐 ❌REPEATABLE_READ특정 행을 조회시 항상 같은 데이터를 응답하는 것을 보장하는 격리 수준 하나의 트랜잭션이 수정한 행을 다른 트랜잭션이 수정할 수 없다- 새로운 행을 추가하는 것은 막지 않는다. phantom read READ_COMMI..
-
🎒 Knapsack 알고리즘 (배낭 알고리즘)💻 computer science/🤔 알고리즘 2024. 5. 9. 15:21
🎒 배낭 알고리즘DP 알고리즘 중 하나주어진 공간(배낭)에 최대 가치를 가지는 물건들을 넣도록 물건들을 선택하는 것이다. 배낭 알고리즘에는 2가지 유형이 존재한다. 1️⃣ Fraction Knapsack물건을 쪼갤 수 있는 경우이 경우는 그리디 알고리즘이 사용될 수 있다.단위 무게당 가치가 높은 물건을 차례대로 배낭에 넣는 방식 2️⃣ 0-1 Knapsack물건을 배낭에 넣을지 (1) 또는 넣지 않을지(0)을 결정하는 경우 🤔 왜 배낭 알고리즘이 Dynamic Programming 일까? 결국 최대 이익을 구하기 위해서는 물건을 배낭에 넣어야 한다.이때, 배낭에 물건을 넣는냐 마느냐 가 중요한 선택이다.2가지 선택지가 존재 만약, 배낭에 넣을 수 있는 양이 N 이고, 넣고자 하는 물건의 무게가 M 이..
-
💡 템플릿 콜백 패턴💻 computer science/🌠 디자인패턴 2024. 5. 7. 16:20
🧩 Template Callback 패턴스프링 프레임워크에서 DI(의존성 주입)에서 사용하는 특별한 전략패턴ex) Jdbc Template, Rest Template, Transaction Template, Redis Template public class TransactionTemplate extends DefaultTransactionDefinition implements TransactionOperations, InitializingBean { ... @Override @Nullable public T execute(TransactionCallback action) throws TransactionException { ... }} 🆚 기존의 전략패턴 기존의 전략패턴은 전략 알고리즘 부분을..
-
Hash Table 과 Hash Map💻 computer science/🧐 data structure 2022. 12. 4. 14:57
📍 Hash, Hash Function 해시(Hash) 데이터를 다루는 기법 중 하나 해시 함수 데이터를 효율적으로 관리하기 위해 임의의 길이의 데이터를 고정된 길이의 데이터로 매핑하는 함수 해시 함수 특징 같은 입력값에 대해서 같은 출력값이 보장된다. 서로 다른 입력값으로부터 동일한 출력값이 나올 가능성이 희박하므로 입력값에 대한 무결성이 보장된다. 일방향성을 갖는다. 📌 해시 테이블 (Hash Table) 키(key)와 값(value)이 하나의 쌍을 이루는 데이터 구조 즉, 키와 배열의 인덱스(index)를 이용하여 키를 저장하는 자료구조 해시 테이블은 해시 함수(hash function)으로 계산하여 그 값을 배열의 인덱스로 사용한다. 해시 함수로 의해 반환된 데이터의 고유 숫자 값을 해시 값 또는..
-
HTTPS💻 computer science/🌐 network 2022. 10. 9. 19:34
HTTP HTTP (Hyper Text Transfer Protocol) 서버 / 클라이언트 모델을 따라 데이터를 주고 받기 위한 프로토콜 80번 포트 사용 HTTP 특징 애플리케이션 레벨의 프로토콜 TCP/IP 위에서 작동 Stateless 프로토콜 암호화가 되지 않은 평문 데이터를 전송하는 프로토콜 중요 내용을 주고 받으면 제 3자가 정보를 조회할 수 있다 HTTPS HTTPS (Hyper Text Transfer Protocol Secure) HTTP에 데이터 암호화가 추가된 프로토콜 443번 포트 사용 네트워크 상에서 중간에 제 3자가 정보를 볼 수 없도록 암호화를 지원 SSL / TLS SSL (Secure Socket Layer) 암호화 기반 인터넷 보안 프로토콜 전달되는 모든 데이터를 암호화..