[Class] Vertex , Edge template class Vertex{ public: int key; T value; Vertex(int _key, T _value) : key(_key), value(_value) {}; bool operator==(const int arg) const {return this -> key == arg;} bool operator!=(const int arg) const {return this -> key != arg;} void print() {cout
가중치를 가지는 무방향 그래프의 최소신장트리를 생성하는 코드이다. [Class] Vertex , Edge template class Vertex { public: T value; int key; Vertex(int _key, T _value) : key(_key), value(_value) {}; void print(){ std::cout arg; } bool operator key key == arg.key; } bool operator==(const int arg) const { return this -> key == arg; }..
[Class] Vertex 그래프의 표현 방식 중 하나인 인접리스트에 사용될 정점이다. template class Vertex { public: T data; int weight; Vertex *link; Vertex(T _data) : data(_data), link(NULL) {} Vertex() {Vertex(NULL);} const bool operator== (const T arg) { return this -> data == arg; } const bool operator!= (const T arg) { return this -> data != arg; } }; 인접리스트 특성 상 link 포인터를 추가하였다. [Class] Graph template class Graph { public: t..
[Class] Node run과 tree에 사용할 노드를 정의하였다. class Node { public: int key, runNum; Node(int _key, int _run) : key(_key), runNum(_run){}; Node(){ key = INT_MAX; }; bool operator key < arg.key; } }; runNum에는 노드 자신이 어느 run에 속해있는지를 저장한다. key를 최댓값으로 초기화시키는 이유는 run에 포인터가 아닌 객체를 저장할 것이므로 NULL를 대신하기 위함이다. [Class] LoserTree class LoserTree { public: const int RUNMAX = 100; Node **run, **tree; int *runTop, runC..
Class BinarySearchTree 이진탐색트리 Class이다. template class BinarySearchTree { public: class Node { ... }; Node *root; BinarySearchTree() : root(NULL) {} ... [Class] Node Inner Class 구조로 Tree의 원소인 노드를 표현하는 Node class를 표현하겠다. class Node { public: T data; int key; Node *left, *right, *parent; Node(T data, int key) { this -> data = data; this -> key = key; left = right = parent = NULL; } Node(){ Node(NUL..
#include class MaxHeap { public: class Node { public: int data; bool isNull; Node(int data) { this -> data = data; isNull = false; } Node(){ isNull = true; } }; Node *biTree; int top; MaxHeap(){ biTree = new Node[100](); top = 0; } void swap(Node &a, Node &b) { Node temp = a; a = b; b= temp; } void push(int data) { biTree[++top] = Node(data); for(int idx = top; idx != 1 && biTree[idx / 2].data <..
Comment