one Book a Day

  • 홈
  • 태그
  • 방명록
  • GitHub

Longest common ancester 1

[알고리즘] LCA(최소 공통 조상)과 sparse table

LCA(lowest common ancestor)최소 공통 조상 모든 노드에 대한 깊이(depth)를 계산합니다. LCA를 찾을 두 노드를 확인합니다. depth가 동일하도록 거슬러 올라갑니다. 이후 부모가 같아질때까지 반복적으로 두 노드의 depth를 낮춥니다. 모든 LCA(a,b)연산에 대해 2번의 과정을 반복합니다. 느린 탐색 import sys sys.setrecursion(int(1e5)) # 각 노드의 depth를 찾아 기록하기 위한 dfs def find_depth(cur_node, depth): check[cur_node] = True depth[cur_node] = depth for next_node in graph[x]: if not check[next_node]: parent[next..

practivceAlgorithm/자료구조&알고리즘 2021.08.09
1
더보기
프로필사진
  • 분류 전체보기 (720)
    • webDeveloper (11)
      • Browser (5)
      • Test (1)
    • frontend (50)
      • HTML (6)
      • CSS&Design (14)
      • JavaScript (16)
      • TypeScript (2)
      • React (8)
      • 상태관리 (2)
      • d3.js & three.js (1)
    • backend (21)
      • Node.js (0)
      • Django&Python (15)
      • Java (2)
      • Spring Boot (0)
      • DB (4)
    • practivceAlgorithm (570)
      • 자료구조&알고리즘 (29)
      • PYTHON 기능연습 (11)
      • 백준 (379)
      • swexpertacademy (84)
      • programmers (23)
      • codeforce (20)
      • LeetCode (0)
      • 다시 봐야할 문제들 (22)
    • Computer Science (37)
      • 소프트웨어 공학 (9)
      • 네트워크 (10)
      • 운영체제 (7)
      • 컴퓨터 구조 (4)
      • DB (2)
      • 모델링 & 아키텍쳐 & 패턴 (3)
      • IOT (2)
    • GitHub&Git (7)
    • 후기 (3)
    • IDE (1)
    • Memo (1)

Tag

비트마스킹, kakao 2019, 분할정복, 2018, BOJ, JS, http, 슬라이딩 윈도우, DP, Python, TRIE, 비트마스크, kakao 2018, 파이썬, React, JS 30, 다익스트라, dfs, 백준, codeforce 702,

최근글과 인기글

  • 최근글
  • 인기글

최근댓글

Archives

Calendar

«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

방문자수Total

  • Today :
  • Yesterday :

Copyright © Kakao Corp. All rights reserved.

티스토리툴바