-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBOJ1991.java
More file actions
107 lines (107 loc) · 3.01 KB
/
BOJ1991.java
File metadata and controls
107 lines (107 loc) · 3.01 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//import java.io.BufferedReader;
//import java.io.IOException;
//import java.io.InputStreamReader;
//import java.util.ArrayList;
//import java.util.StringTokenizer;
//class Node {
// char data;
// Node leftChild;
// Node rightChild;
//
// public Node(char data) {
// this.data = data;
// }
//}
//class Tree {
// /*
// Node class 구현
// */
//
//
// /*
// Tree 구현
// */
// Node root;
//
// public void createNode(char data, char leftData, char rightData) {
// if (root == null) {
// this.root = new Node(data);
// root.leftChild = (leftData != '.') ? new Node(leftData) : null;
// root.rightChild = (rightData != '.') ? new Node(rightData) : null;
// } else {
// findNodeAndCreate(this.root, data, leftData, rightData);
// }
// }
//
// public void findNodeAndCreate(Node node, char targetData, char leftData, char rightData) {
// if (node == null) {
// return;
// } else if (node.data == targetData) {
// node.leftChild = (leftData != '.') ? new Node(leftData) : null;
// node.rightChild = (rightData != '.') ? new Node(rightData) : null;
// } else {
// findNodeAndCreate(node.leftChild, targetData, leftData, rightData);
// findNodeAndCreate(node.rightChild, targetData, leftData, rightData);
// }
// }
//
// public void preOrder(Node node) {
// if(node != null) {
// System.out.print(node.data);
// if(node.leftChild != null) {preOrder(node.leftChild);}
// if(node.rightChild != null) {preOrder(node.rightChild);}
// }
// }
//
// public void inOrder(Node node) {
// if(node != null) {
// if(node.leftChild != null) {inOrder(node.leftChild);}
// System.out.print(node.data);
// if(node.rightChild != null) {inOrder(node.rightChild);}
// }
// }
//
// public void postOrder(Node node) {
// if(node != null) {
// if(node.leftChild != null) {postOrder(node.leftChild);}
// if(node.rightChild != null) {postOrder(node.rightChild);}
// System.out.print(node.data);
// }
// }
//
//}
//
//public class BOJ1991 {
// public static void main(String[] args) throws IOException {
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// int n = Integer.parseInt(br.readLine());
//
// Tree t = new Tree();
// for(int i = 0 ; i < n; i++){
// StringTokenizer st = new StringTokenizer(br.readLine());
// char root = st.nextToken().charAt(0);
// char left = st.nextToken().charAt(0);
// char right = st.nextToken().charAt(0);
//
// t.createNode(root, left, right);
// }
//
// t.preOrder(t.root);
// System.out.println();
// t.inOrder(t.root);
// System.out.println();
// t.postOrder(t.root);
// }
//}
//
//
///*
//7
//A B C
//B D .
//C E F
//E . .
//F . G
//D . .
//G . .
// */