Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
Tags
- bit manipulation
- 파이썬
- java
- Binary Search
- Data Structure
- Math
- Tree
- Binary Tree
- database
- 자바
- SQL
- 구현
- dynamic programming
- hash table
- Number Theory
- Method
- simulation
- 코테
- Counting
- geometry
- sorting
- 코딩테스트
- Class
- Matrix
- implement
- array
- Stack
- string
- two pointers
- greedy
Archives
- Today
- Total
코린이의 소소한 공부노트
Search Binary Tree (no example) 본문
1. Problem
- 이진 트리에서 원하는 값을 찾아보자.
// 이진 트리란?
1) 값(key)을 가진 노드들의 모임
2) 노드는 자식 노드를 왼쪽 하나(left subtree), 오른쪽 하나(right subtree)를 가질 수 있다.
3) 왼쪽 자식의 노드 값은 부모 노드(root)보다 작거나 같고, 오른쪽 자식의 노드 값은 크거나 같다.
2. Input
1) 이진 트리를 가리키는 포인터 tree
2) 찾아야 할 값 keyin
3. Output
1) 찾아야 할 값이 있는 노드를 가리키는 포인터 p
4. PseudoCode
void search(node_pointer tree, keytype keyin, node_pointer p){
boolean found;
p = tree;
found = false;
while(!found){
if(p->key == keyin)
found = true;
else if(keyin < p->key)
p = p->left;
else
p = p->right;
}
}
'Back-End > Algorithm' 카테고리의 다른 글
Selection sort (0) | 2023.05.19 |
---|---|
Chained matrix multiplication (0) | 2023.05.11 |
Floyd's Algorithm for shortest paths (0) | 2023.03.07 |
Binomial Coefficient (iterative) (0) | 2023.03.07 |
Binomial Coefficient (recursive) (0) | 2023.03.07 |