SlideShare a Scribd company logo
서울시립대 알고리즘 소모임
트리
여름방학 1주차
강의자 소개
2021 AL林 정기 세미나 2
이름 최문기
소속 서울시립대 컴퓨터과학부(16학번)
핸들 iknoom1107(BOJ) IKnoom(Codeforces) IKnoom(AtCoder)
ICPC 팀 (팀명 미정)
- 김정현, 오규민, 최문기
2021 AL林 정기 세미나 3
복습
자료구조(data structure)
2021 AL林 정기 세미나 4
효율적인 접근 및 수정을 가능하게 하는 자료의 집합
(In computer science, a data structure is a data organization,
management, and storage format that enables efficient access
and modification.)
효율적인 알고리즘을 설계하는데에 필요하다.
자료구조(data structure)
2021 AL林 정기 세미나 5
선형 구조
- 배열
- 연결 리스트
- 스택, 큐, 덱
비선형 구조
- 그래프
- 트리
컴퓨터과학에서의 그래프
2021 AL林 정기 세미나 6
그래프를 표현하는 방법
2021 AL林 정기 세미나 7
트리??
2021 AL林 정기 세미나 8
🌳
2021 AL林 정기 세미나 9
트리
트리(tree)
2021 AL林 정기 세미나 10
[그래프 이론]
- 회로가 없는 연결 무향 그래프
[자료 구조]
- 노드 사이의 계층 관계를 표현하는 자료구조
- 부모(상위 노드) – 자식(하위 노드) 관계를 가진다.
- 자식노드는 하나의 부모노드를 가진다.
트리: 예
2021 AL林 정기 세미나 11
트리: 트리가 아닌 예
2021 AL林 정기 세미나 12
트리: 예
2021 AL林 정기 세미나 13
https://thebook.io/007021/ch01/02/01-02/
https://nomis.tistory.com/121
트리: 용어
2021 AL林 정기 세미나 14
트리: 성질
2021 AL林 정기 세미나 15
1. 노드가 n개일 때 간선이 n-1개이다.
2. 서로 다른 임의의 두 노드에 대한 경로는 유일하다.
이진 트리(binary tree)
2020 AL林 정기 스터디 16
임의의 노드의 자식 노드 수가 2 이하인 트리
이진 트리: 예
2020 AL林 정기 스터디 17
full binary tree complete binary tree
= heap structure
perfect binary tree
이진 트리: 성질
2021 AL林 정기 세미나 18
1. 깊이가 𝑑인 노드는 최대 2𝑑
개이다.
2. 높이가 ℎ이면 최대 2h+1 − 1개의 노드를 가진다.
3. 노드의 개수가 𝑛이면 높이는 적어도 log2(𝑛 + 1) 이다.
2021 AL林 정기 세미나 19
트리의 구현
트리의 구현
2021 AL林 정기 세미나 20
트리는 그래프이므로 그래프와 동일하게 구현하면 됩니다.
그래프를 구현하는 방법
1. 인접 행렬
2. 인접 리스트
트리의 구현
2021 AL林 정기 세미나 21
하지만 인접 행렬로 구현하게 된다면 희소 행렬이 되므로 비효율적이고
일반적으로 인접 리스트로 저장합니다.
트리의 구현
2021 AL林 정기 세미나 22
이렇게 객체를 만들어서 자식 노드의 주소를 저장할 수도 있습니다.
class Node:
def __init__(self, element):
self.element = element
self.left_child = None
self.right_child = None
class Node:
def __init__(self, element):
self.element = element
self.children = []
트리의 구현: 그 외..
2021 AL林 정기 세미나 23
완전 이진트리는 배열로 구현하는 것이 효율적입니다.
이는 [여름방학 3주차 우선순위 큐]에서 알아보겠습니다.
트리의 순회
2021 AL林 정기 세미나 24
트리는 그래프이므로
동일하게 bfs, dfs를 하여 트리를 순회(탐색)할 수 있습니다.
이 때 이진 트리를 dfs로 순회할 때
순서에 따라 다음 세가지 방법이 있습니다.
• 전위 순회
• 중위 순회
• 후위 순회
트리의 순회
2021 AL林 정기 세미나 25
• 전위 순회: (루트) (왼쪽 자식) (오른쪽 자식)
• 중위 순회: (왼쪽 자식) (루트) (오른쪽 자식)
• 후위 순회: (왼쪽 자식) (오른쪽 자식) (루트)
트리의 순회
2021 AL林 정기 세미나 26
레벨 순서(level-order) 순회라는 걸 들어보신 분도 있을 겁니다.
이건 bfs를 구현하면 됩니다.
트리의 순회
2021 AL林 정기 세미나 27
[BOJ 1991] 트리 순회
2021 AL林 정기 세미나 28
정답 소스코드1(python): http://boj.kr/09314e6711e94d05a5a297020c44d6b0
정답 소스코드2 (python): http://boj.kr/f0c7e12c414f411b86d567abaf5b2871
2021 AL林 정기 세미나 29
트리의 활용
이진 검색 트리(BST, Binary Search Tree)
2021 AL林 정기 세미나 30
효율적으로 자료를 검색하기 위한 자료구조
원소 검색, 삽입, 삭제가 𝜃(log 𝑛 ) (평균적으로 log(n))
레코드(Recode): 개체에 대한 모든 정보
검색키(Search key): 레코드를 대표할 수 있는 필드
이진 검색 트리(BST, Binary Search Tree)
2021 AL林 정기 세미나 31
특징
• 이진 트리다.
• 각 노드는 키 값을 하나씩 갖는다.
각 노드의 키 값은 모두 다르다.
• 임의의 노드의 키 값은
자신의 왼쪽에 있는 모든 노드의 키 값보다 크고,
오른쪽에 있는 모든 노드의 키 값보다 작다.
이진 검색 트리(BST, Binary Search Tree)
2021 AL林 정기 세미나 32
- 원소 검색
- 원소 삽입
- 원소 삭제
위 연산이 𝑂(ℎ)에 수행
(트리의 높이에 비례)
따라서 최악의 경우 𝑂(𝑛)
이진 검색 트리(BST, Binary Search Tree)
2021 AL林 정기 세미나 33
높이를 log(𝑛)으로 유지하는 이진 검색 트리
- AVL 트리
- 레드 블랙 트리(C++에서 std::set, std::map)
효율적으로 자료를 검색하기 위한 또 다른 자료구조
- 해시 테이블(C++에서 std::unordered_set, std::unordered_map)
우선순위 큐
2021 AL林 정기 세미나 34
원소를 추가 : O(logN)
최댓값을 확인 : O(1)
최댓값을 삭제 : O(logN)
이는 [여름방학 3주차 우선순위 큐]에서 알아보겠습니다.
트리의 활용: 그 외..
2021 AL林 정기 세미나 35
• 유니온 파인드: 집합을 관리하는 자료구조
• 최소 스패닝 트리: 그래프의 모든 정점을 연결하는 트리. 그 중 가중치의 합이 최소
• 트라이: 문자열 집합을 관리하는 자료구조
• 세그먼트 트리: 구간합을 관리하는 자료구조
연습문제
2021 AL林 정기 세미나 36
트리
연습 문제
1991 트리 순회
9934 완전 이진 트리
5639 이진 검색 트리
4803 트리
1068 트리
도전 문제
14725 개미굴
1967 트리의 지름
2263 트리의 순회
그 외 참고할만한 자료
2021 AL林 정기 세미나 37
kks님 블로그
• https://m.blog.naver.com/kks227/220788265724
바킹독님 블로그
• https://blog.encrypted.gg/909?category=773649
출처
2021 AL林 정기 세미나 38
https://en.wikipedia.org/

More Related Content

What's hot

งานย่อยที่ 6
งานย่อยที่ 6งานย่อยที่ 6
งานย่อยที่ 6Little Thuntun
 
Chapter 9 ds
Chapter 9 dsChapter 9 ds
Chapter 9 ds
Hanif Durad
 
C++ ammar .s.q
C++  ammar .s.qC++  ammar .s.q
C++ ammar .s.q
ammarsalem5
 
Generative Adversarial Nets
Generative Adversarial NetsGenerative Adversarial Nets
Generative Adversarial Nets
Jinho Lee
 
Viva questions ds th c++
Viva questions ds th c++Viva questions ds th c++
Viva questions ds th c++mrecedu
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
Faraz Ahmed
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
Enthought, Inc.
 
January 7, 2014 function notation
January 7, 2014  function notationJanuary 7, 2014  function notation
January 7, 2014 function notationkhyps13
 
Introduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersIntroduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning Programmers
Kimikazu Kato
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303
Namgee Lee
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.
Piotr Milanowski
 
Designing linear algebra into Julia
Designing linear algebra into JuliaDesigning linear algebra into Julia
Designing linear algebra into Julia
Jiahao Chen
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
Shakil Ahmed
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Enthought, Inc.
 
A2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_solA2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_sol
MaynaShah1
 

What's hot (20)

Arrays
ArraysArrays
Arrays
 
Exercise #11 notes
Exercise #11 notesExercise #11 notes
Exercise #11 notes
 
งานย่อยที่ 6
งานย่อยที่ 6งานย่อยที่ 6
งานย่อยที่ 6
 
Chapter 9 ds
Chapter 9 dsChapter 9 ds
Chapter 9 ds
 
C++ ammar .s.q
C++  ammar .s.qC++  ammar .s.q
C++ ammar .s.q
 
Generative Adversarial Nets
Generative Adversarial NetsGenerative Adversarial Nets
Generative Adversarial Nets
 
Domain Transformations
Domain TransformationsDomain Transformations
Domain Transformations
 
Viva questions ds th c++
Viva questions ds th c++Viva questions ds th c++
Viva questions ds th c++
 
parent functons
parent functonsparent functons
parent functons
 
Matlab graphics
Matlab graphicsMatlab graphics
Matlab graphics
 
Intoduction to numpy
Intoduction to numpyIntoduction to numpy
Intoduction to numpy
 
Numpy Talk at SIAM
Numpy Talk at SIAMNumpy Talk at SIAM
Numpy Talk at SIAM
 
January 7, 2014 function notation
January 7, 2014  function notationJanuary 7, 2014  function notation
January 7, 2014 function notation
 
Introduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning ProgrammersIntroduction to NumPy for Machine Learning Programmers
Introduction to NumPy for Machine Learning Programmers
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303
 
Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.Statistical inference for (Python) Data Analysis. An introduction.
Statistical inference for (Python) Data Analysis. An introduction.
 
Designing linear algebra into Julia
Designing linear algebra into JuliaDesigning linear algebra into Julia
Designing linear algebra into Julia
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structure
 
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with MayaviScientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
Scientific Computing with Python Webinar March 19: 3D Visualization with Mayavi
 
A2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_solA2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_sol
 

Similar to 2021 여름방학 정기 세미나 1주차

17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
Intro C# Book
 
L 19 ct1120
L 19 ct1120L 19 ct1120
L 19 ct1120
Zia Ush Shamszaman
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
Anusruti Mitra
 
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
Intro C# Book
 
17 Trees and graphs
17 Trees and graphs17 Trees and graphs
17 Trees and graphs
maznabili
 
15-btrees.ppt
15-btrees.ppt15-btrees.ppt
15-btrees.ppt
plagcheck
 
Furnish an Index Using the Works of Tree Structures
Furnish an Index Using the Works of Tree StructuresFurnish an Index Using the Works of Tree Structures
Furnish an Index Using the Works of Tree Structures
ijceronline
 
unit06-3-Trees.pdf
unit06-3-Trees.pdfunit06-3-Trees.pdf
unit06-3-Trees.pdf
AnmolYadav509681
 
nptel 2nd presentation.pptx
nptel 2nd presentation.pptxnptel 2nd presentation.pptx
nptel 2nd presentation.pptx
KeshavBandil2
 
(5) collections algorithms
(5) collections algorithms(5) collections algorithms
(5) collections algorithms
Nico Ludwig
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structuresNiraj Agarwal
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
Intro C# Book
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
Amrinder Arora
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Rai University
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_trees
Danish Aakash
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Rai University
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
Rai University
 

Similar to 2021 여름방학 정기 세미나 1주차 (20)

17. Trees and Tree Like Structures
17. Trees and Tree Like Structures17. Trees and Tree Like Structures
17. Trees and Tree Like Structures
 
A41001011
A41001011A41001011
A41001011
 
L 19 ct1120
L 19 ct1120L 19 ct1120
L 19 ct1120
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structure
 
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
17 Trees and graphs
17 Trees and graphs17 Trees and graphs
17 Trees and graphs
 
15-btrees.ppt
15-btrees.ppt15-btrees.ppt
15-btrees.ppt
 
Furnish an Index Using the Works of Tree Structures
Furnish an Index Using the Works of Tree StructuresFurnish an Index Using the Works of Tree Structures
Furnish an Index Using the Works of Tree Structures
 
unit06-3-Trees.pdf
unit06-3-Trees.pdfunit06-3-Trees.pdf
unit06-3-Trees.pdf
 
nptel 2nd presentation.pptx
nptel 2nd presentation.pptxnptel 2nd presentation.pptx
nptel 2nd presentation.pptx
 
(5) collections algorithms
(5) collections algorithms(5) collections algorithms
(5) collections algorithms
 
Binary trees
Binary treesBinary trees
Binary trees
 
Fundamentals of data structures
Fundamentals of data structuresFundamentals of data structures
Fundamentals of data structures
 
19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity19. Java data structures algorithms and complexity
19. Java data structures algorithms and complexity
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data Structures
 
Mca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structureMca ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_trees
 
Binary Trees
Binary TreesBinary Trees
Binary Trees
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 
Bsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structureBsc cs ii dfs u-1 introduction to data structure
Bsc cs ii dfs u-1 introduction to data structure
 

More from Moonki Choi

2021 2학기 정기 세미나 5주차
2021 2학기 정기 세미나 5주차2021 2학기 정기 세미나 5주차
2021 2학기 정기 세미나 5주차
Moonki Choi
 
2021 2학기 정기 세미나 4주차
2021 2학기 정기 세미나 4주차2021 2학기 정기 세미나 4주차
2021 2학기 정기 세미나 4주차
Moonki Choi
 
2021 여름방학 정기 세미나 3주차
2021 여름방학 정기 세미나 3주차2021 여름방학 정기 세미나 3주차
2021 여름방학 정기 세미나 3주차
Moonki Choi
 
2021 알림 오세요
2021 알림 오세요2021 알림 오세요
2021 알림 오세요
Moonki Choi
 
2021 1학기 정기 세미나 6주차
2021 1학기 정기 세미나 6주차2021 1학기 정기 세미나 6주차
2021 1학기 정기 세미나 6주차
Moonki Choi
 
2021 1학기 정기 세미나 3주차
2021 1학기 정기 세미나 3주차2021 1학기 정기 세미나 3주차
2021 1학기 정기 세미나 3주차
Moonki Choi
 
2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차
Moonki Choi
 
2020 여름방학 정기스터디 6주차
2020 여름방학 정기스터디 6주차2020 여름방학 정기스터디 6주차
2020 여름방학 정기스터디 6주차
Moonki Choi
 
2020 여름방학 정기스터디 5주차
2020 여름방학 정기스터디 5주차2020 여름방학 정기스터디 5주차
2020 여름방학 정기스터디 5주차
Moonki Choi
 
2020 겨울방학 정기스터디 3주차
2020 겨울방학 정기스터디 3주차2020 겨울방학 정기스터디 3주차
2020 겨울방학 정기스터디 3주차
Moonki Choi
 
2020 겨울방학 정기스터디 2주차
2020 겨울방학 정기스터디 2주차2020 겨울방학 정기스터디 2주차
2020 겨울방학 정기스터디 2주차
Moonki Choi
 
2020 2학기 정기스터디 8주차
2020 2학기 정기스터디 8주차2020 2학기 정기스터디 8주차
2020 2학기 정기스터디 8주차
Moonki Choi
 
2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차
Moonki Choi
 
2020 2학기 정기스터디 1주차
2020 2학기 정기스터디 1주차2020 2학기 정기스터디 1주차
2020 2학기 정기스터디 1주차
Moonki Choi
 
2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차
Moonki Choi
 

More from Moonki Choi (15)

2021 2학기 정기 세미나 5주차
2021 2학기 정기 세미나 5주차2021 2학기 정기 세미나 5주차
2021 2학기 정기 세미나 5주차
 
2021 2학기 정기 세미나 4주차
2021 2학기 정기 세미나 4주차2021 2학기 정기 세미나 4주차
2021 2학기 정기 세미나 4주차
 
2021 여름방학 정기 세미나 3주차
2021 여름방학 정기 세미나 3주차2021 여름방학 정기 세미나 3주차
2021 여름방학 정기 세미나 3주차
 
2021 알림 오세요
2021 알림 오세요2021 알림 오세요
2021 알림 오세요
 
2021 1학기 정기 세미나 6주차
2021 1학기 정기 세미나 6주차2021 1학기 정기 세미나 6주차
2021 1학기 정기 세미나 6주차
 
2021 1학기 정기 세미나 3주차
2021 1학기 정기 세미나 3주차2021 1학기 정기 세미나 3주차
2021 1학기 정기 세미나 3주차
 
2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차2021 1학기 정기 세미나 2주차
2021 1학기 정기 세미나 2주차
 
2020 여름방학 정기스터디 6주차
2020 여름방학 정기스터디 6주차2020 여름방학 정기스터디 6주차
2020 여름방학 정기스터디 6주차
 
2020 여름방학 정기스터디 5주차
2020 여름방학 정기스터디 5주차2020 여름방학 정기스터디 5주차
2020 여름방학 정기스터디 5주차
 
2020 겨울방학 정기스터디 3주차
2020 겨울방학 정기스터디 3주차2020 겨울방학 정기스터디 3주차
2020 겨울방학 정기스터디 3주차
 
2020 겨울방학 정기스터디 2주차
2020 겨울방학 정기스터디 2주차2020 겨울방학 정기스터디 2주차
2020 겨울방학 정기스터디 2주차
 
2020 2학기 정기스터디 8주차
2020 2학기 정기스터디 8주차2020 2학기 정기스터디 8주차
2020 2학기 정기스터디 8주차
 
2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차2020 2학기 정기스터디 2주차
2020 2학기 정기스터디 2주차
 
2020 2학기 정기스터디 1주차
2020 2학기 정기스터디 1주차2020 2학기 정기스터디 1주차
2020 2학기 정기스터디 1주차
 
2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차2020 1학기 정기스터디 2주차
2020 1학기 정기스터디 2주차
 

Recently uploaded

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
MuhammadTufail242431
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 

Recently uploaded (20)

Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 

2021 여름방학 정기 세미나 1주차

  • 2. 강의자 소개 2021 AL林 정기 세미나 2 이름 최문기 소속 서울시립대 컴퓨터과학부(16학번) 핸들 iknoom1107(BOJ) IKnoom(Codeforces) IKnoom(AtCoder) ICPC 팀 (팀명 미정) - 김정현, 오규민, 최문기
  • 3. 2021 AL林 정기 세미나 3 복습
  • 4. 자료구조(data structure) 2021 AL林 정기 세미나 4 효율적인 접근 및 수정을 가능하게 하는 자료의 집합 (In computer science, a data structure is a data organization, management, and storage format that enables efficient access and modification.) 효율적인 알고리즘을 설계하는데에 필요하다.
  • 5. 자료구조(data structure) 2021 AL林 정기 세미나 5 선형 구조 - 배열 - 연결 리스트 - 스택, 큐, 덱 비선형 구조 - 그래프 - 트리
  • 7. 그래프를 표현하는 방법 2021 AL林 정기 세미나 7
  • 8. 트리?? 2021 AL林 정기 세미나 8 🌳
  • 9. 2021 AL林 정기 세미나 9 트리
  • 10. 트리(tree) 2021 AL林 정기 세미나 10 [그래프 이론] - 회로가 없는 연결 무향 그래프 [자료 구조] - 노드 사이의 계층 관계를 표현하는 자료구조 - 부모(상위 노드) – 자식(하위 노드) 관계를 가진다. - 자식노드는 하나의 부모노드를 가진다.
  • 11. 트리: 예 2021 AL林 정기 세미나 11
  • 12. 트리: 트리가 아닌 예 2021 AL林 정기 세미나 12
  • 13. 트리: 예 2021 AL林 정기 세미나 13 https://thebook.io/007021/ch01/02/01-02/ https://nomis.tistory.com/121
  • 14. 트리: 용어 2021 AL林 정기 세미나 14
  • 15. 트리: 성질 2021 AL林 정기 세미나 15 1. 노드가 n개일 때 간선이 n-1개이다. 2. 서로 다른 임의의 두 노드에 대한 경로는 유일하다.
  • 16. 이진 트리(binary tree) 2020 AL林 정기 스터디 16 임의의 노드의 자식 노드 수가 2 이하인 트리
  • 17. 이진 트리: 예 2020 AL林 정기 스터디 17 full binary tree complete binary tree = heap structure perfect binary tree
  • 18. 이진 트리: 성질 2021 AL林 정기 세미나 18 1. 깊이가 𝑑인 노드는 최대 2𝑑 개이다. 2. 높이가 ℎ이면 최대 2h+1 − 1개의 노드를 가진다. 3. 노드의 개수가 𝑛이면 높이는 적어도 log2(𝑛 + 1) 이다.
  • 19. 2021 AL林 정기 세미나 19 트리의 구현
  • 20. 트리의 구현 2021 AL林 정기 세미나 20 트리는 그래프이므로 그래프와 동일하게 구현하면 됩니다. 그래프를 구현하는 방법 1. 인접 행렬 2. 인접 리스트
  • 21. 트리의 구현 2021 AL林 정기 세미나 21 하지만 인접 행렬로 구현하게 된다면 희소 행렬이 되므로 비효율적이고 일반적으로 인접 리스트로 저장합니다.
  • 22. 트리의 구현 2021 AL林 정기 세미나 22 이렇게 객체를 만들어서 자식 노드의 주소를 저장할 수도 있습니다. class Node: def __init__(self, element): self.element = element self.left_child = None self.right_child = None class Node: def __init__(self, element): self.element = element self.children = []
  • 23. 트리의 구현: 그 외.. 2021 AL林 정기 세미나 23 완전 이진트리는 배열로 구현하는 것이 효율적입니다. 이는 [여름방학 3주차 우선순위 큐]에서 알아보겠습니다.
  • 24. 트리의 순회 2021 AL林 정기 세미나 24 트리는 그래프이므로 동일하게 bfs, dfs를 하여 트리를 순회(탐색)할 수 있습니다. 이 때 이진 트리를 dfs로 순회할 때 순서에 따라 다음 세가지 방법이 있습니다. • 전위 순회 • 중위 순회 • 후위 순회
  • 25. 트리의 순회 2021 AL林 정기 세미나 25 • 전위 순회: (루트) (왼쪽 자식) (오른쪽 자식) • 중위 순회: (왼쪽 자식) (루트) (오른쪽 자식) • 후위 순회: (왼쪽 자식) (오른쪽 자식) (루트)
  • 26. 트리의 순회 2021 AL林 정기 세미나 26 레벨 순서(level-order) 순회라는 걸 들어보신 분도 있을 겁니다. 이건 bfs를 구현하면 됩니다.
  • 27. 트리의 순회 2021 AL林 정기 세미나 27
  • 28. [BOJ 1991] 트리 순회 2021 AL林 정기 세미나 28 정답 소스코드1(python): http://boj.kr/09314e6711e94d05a5a297020c44d6b0 정답 소스코드2 (python): http://boj.kr/f0c7e12c414f411b86d567abaf5b2871
  • 29. 2021 AL林 정기 세미나 29 트리의 활용
  • 30. 이진 검색 트리(BST, Binary Search Tree) 2021 AL林 정기 세미나 30 효율적으로 자료를 검색하기 위한 자료구조 원소 검색, 삽입, 삭제가 𝜃(log 𝑛 ) (평균적으로 log(n)) 레코드(Recode): 개체에 대한 모든 정보 검색키(Search key): 레코드를 대표할 수 있는 필드
  • 31. 이진 검색 트리(BST, Binary Search Tree) 2021 AL林 정기 세미나 31 특징 • 이진 트리다. • 각 노드는 키 값을 하나씩 갖는다. 각 노드의 키 값은 모두 다르다. • 임의의 노드의 키 값은 자신의 왼쪽에 있는 모든 노드의 키 값보다 크고, 오른쪽에 있는 모든 노드의 키 값보다 작다.
  • 32. 이진 검색 트리(BST, Binary Search Tree) 2021 AL林 정기 세미나 32 - 원소 검색 - 원소 삽입 - 원소 삭제 위 연산이 𝑂(ℎ)에 수행 (트리의 높이에 비례) 따라서 최악의 경우 𝑂(𝑛)
  • 33. 이진 검색 트리(BST, Binary Search Tree) 2021 AL林 정기 세미나 33 높이를 log(𝑛)으로 유지하는 이진 검색 트리 - AVL 트리 - 레드 블랙 트리(C++에서 std::set, std::map) 효율적으로 자료를 검색하기 위한 또 다른 자료구조 - 해시 테이블(C++에서 std::unordered_set, std::unordered_map)
  • 34. 우선순위 큐 2021 AL林 정기 세미나 34 원소를 추가 : O(logN) 최댓값을 확인 : O(1) 최댓값을 삭제 : O(logN) 이는 [여름방학 3주차 우선순위 큐]에서 알아보겠습니다.
  • 35. 트리의 활용: 그 외.. 2021 AL林 정기 세미나 35 • 유니온 파인드: 집합을 관리하는 자료구조 • 최소 스패닝 트리: 그래프의 모든 정점을 연결하는 트리. 그 중 가중치의 합이 최소 • 트라이: 문자열 집합을 관리하는 자료구조 • 세그먼트 트리: 구간합을 관리하는 자료구조
  • 36. 연습문제 2021 AL林 정기 세미나 36 트리 연습 문제 1991 트리 순회 9934 완전 이진 트리 5639 이진 검색 트리 4803 트리 1068 트리 도전 문제 14725 개미굴 1967 트리의 지름 2263 트리의 순회
  • 37. 그 외 참고할만한 자료 2021 AL林 정기 세미나 37 kks님 블로그 • https://m.blog.naver.com/kks227/220788265724 바킹독님 블로그 • https://blog.encrypted.gg/909?category=773649
  • 38. 출처 2021 AL林 정기 세미나 38 https://en.wikipedia.org/