SlideShare a Scribd company logo
1 of 38
Download to read offline
서울시립대 알고리즘 소모임
트리
여름방학 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
 
Generative Adversarial Nets
Generative Adversarial NetsGenerative Adversarial Nets
Generative Adversarial NetsJinho 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 numpyFaraz Ahmed
 
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 ProgrammersKimikazu Kato
 
Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Numpy tutorial(final) 20160303
Numpy tutorial(final) 20160303Namgee 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 JuliaJiahao Chen
 
Advanced data structure
Advanced data structureAdvanced data structure
Advanced data structureShakil 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 MayaviEnthought, Inc.
 
A2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_solA2 python basics_nptel_pds2_sol
A2 python basics_nptel_pds2_solMaynaShah1
 

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 StructuresIntro C# Book
 
Trees in data structure
Trees in data structureTrees in data structure
Trees in data structureAnusruti 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 traversalIntro C# Book
 
17 Trees and graphs
17 Trees and graphs17 Trees and graphs
17 Trees and graphsmaznabili
 
15-btrees.ppt
15-btrees.ppt15-btrees.ppt
15-btrees.pptplagcheck
 
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 Structuresijceronline
 
nptel 2nd presentation.pptx
nptel 2nd presentation.pptxnptel 2nd presentation.pptx
nptel 2nd presentation.pptxKeshavBandil2
 
(5) collections algorithms
(5) collections algorithms(5) collections algorithms
(5) collections algorithmsNico 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 complexityIntro C# Book
 
Asymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAsymptotic Notation and Data Structures
Asymptotic Notation and Data StructuresAmrinder 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 structureRai University
 
introduction to_trees
introduction to_treesintroduction to_trees
introduction to_treesDanish 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 structureRai 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 structureRai 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

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 

Recently uploaded (20)

Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 

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/