-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtraversal_strategy.cpp
More file actions
46 lines (33 loc) · 1.34 KB
/
traversal_strategy.cpp
File metadata and controls
46 lines (33 loc) · 1.34 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include "classwork/traversal_strategy.hpp"
// очередь и стек из стандартной библиотеки
#include <queue>
#include <stack>
namespace classwork {
// инфиксный обход - L(left) N(node) R(right)
void InOrderTraversalStrategy::Print(Node* node, std::ostream& os) const {
// Write your code here ...
}
// префиксный обход - N(node) L(left) R(right)
void PreOrderTraversalStrategy::Print(Node* node, std::ostream& os) const {
// Write your code here ...
}
// постфиксный обход - L(left) R(right) N(node)
void PostOrderTraversalStrategy::Print(Node* node, std::ostream& os) const {
// Write your code here ...
}
// обход в ширину - слева направо, сверху вниз
void BreadthFirstTraversalStrategy::Print(Node* node, std::ostream& os) const {
// Задание: внести изменения в код, чтобы обход был справа налево / сверху вниз.
if (node == nullptr) {
return;
}
// Write your code here ...
}
// префиксный обход (NLR) на базе стека
void DepthFirstTraversalStrategy::Print(Node* node, std::ostream& os) const {
if (node == nullptr) {
return;
}
// Write your code here ...
}
} // namespace classwork