C++로 DFS-BFS 알고리즘 비교하기 (헤더, cpp클래스파일 포함)
- 최초 등록일
- 2021.04.05
- 최종 저작일
- 2009.09
- 9페이지/ 압축파일
- 가격 3,000원
목차
1. DFS_BFS 소스 코드(헤더,CPP파일).hwp
2. DFS_BFS 트리 및 실행 결과.hwp
본문내용
cpp 파일 - DFSandBFS.cpp
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include "DFSandBFS.h"
using namespace std;
void main()
{
BSTree bst;
bst.Get();
bst.DFS();
cout<<endl;
cout<<"**************************************"<<endl;
cout<<endl;
bst.BFS();
cout<<endl;
}
header 파일 - DFSandBFS.h
#include<cstdlib>
#include<iostream>
#include<iomanip>
using namespace std;
/*****************class TreeNode*****************/
class TreeNode{
friend class BSTree;
private:
TreeNode *sibling;
TreeNode *parent;
char data;
bool check;
public:
TreeNode();
TreeNode(char a);
};
BSTree::BSTree()
{
root = NULL;
};
void BSTree::Get()
{
num = 12;
arrTree[0] = new TreeNode('A');
TreeNode *insert = new TreeNode('B');
arrTree[0] -> sibling = insert;
insert = new TreeNode('C');
참고 자료
없음
압축파일 내 파일목록
DFS_BFS 소스 코드(헤더,CPP파일).hwp
DFS_BFS 트리 및 실행 결과.hwp