obcon-scada / app /include /Tree.js
chanmin0723's picture
Initial obcon SCADA deploy
e4bf523
Raw
History Blame Contribute Delete
2.11 kB
'use strict'
/**
* Copyright (c) 2017~2019, OBCon Inc.
* All rights reserved.
*/
/**
* @file
* @copyright 2017~2019, OBCon Inc.
* @author gye hyun james kim [pnuskgh@gmail.com]
*/
class Node {
constructor(data) {
this.data = data;
this.left = null;
this.right = null;
this.children = [];
}
}
//--- 트리 순회
//--- pre-order (선순회), post-order (후순회), in-order (중순회), level-order (단계순회)
//--- AVL Tree : 트리의 높이를 최소화
class Tree { //--- FIFO (First In First Out)
constructor(isBinaryTree=true, isAVLTree=false) {
this._root = null;
this.isBinaryTree = isBinaryTree;
this.isAVLTree = isAVLTree;
}
insert(data) {
if (this._root == null) {
this._root = new Node(data);
} else {
let cur = this._root;
//--- Reserved
}
}
remove(data) {
}
findNode(data) {
}
traversePreOrder(node) {
if (!node) {
return;
}
console.log(node.data);
for (let idx = 0; idx < node.children; idx++) {
this.traversePreOrder(node.children[idx]);
}
}
traverseInOrder(node) {
}
traversePostOrder(node) {
}
traverseLevelOrder(node) {
}
setDepthBasedOnChildren() { //--- 자식의 높이 계산
if (this.isAVLTree == false) {
return;
}
}
rotateLL() { //--- 왼쪽으로 회전
if (this.isAVLTree == false) {
return;
}
}
rotateRR() { //--- 오른쪽으로 회전
if (this.isAVLTree == false) {
return;
}
}
balance() { //--- 왼쪽/오른쪽 회전을 통해서 균형 잡기
}
}
module.exports = Tree;