Programming/DS SorceCode 썸네일형 리스트형 스레드 이진트리(Thread Binary Tree)를 위한 노드 클래스 #pragma once#ifndef ___ThreadBinNode#define ___ThreadBinNode//스레드 이진트리(Thread Binary Tree)를 위한 노드 클래스class ThreadBinNode{int data;ThreadBinNode* left;ThreadBinNode* right;public: bool bThread;ThreadBinNode(int val,ThreadBinNode* l, ThreadBinNode* r,bool bTh) : data(val), left(l), right(r), bThread(bTh) {}int getData() { return data; }void setRight(ThreadBinNode *r) { right = r; }ThreadBinNode* g.. 더보기 BinaryNode.h : 이진 트리를 위한 노드 클래스 #pragma once#ifndef ___BinaryNode#define ___BinaryNode//BinaryNode.h : 이진 트리를 위한 노드 클래스#include class BinaryNode{protected:int data;//트리에 저장할 데이터BinaryNode* left;//왼쪽 자식 노드의 포인터BinaryNode* right;//오른쪽 자식 노드의 포인터public:BinaryNode(int val = 0, BinaryNode* l = NULL, BinaryNode* r = NULL): data(val), left(l), right(r) {}void setData(int val) { data = val; }void setLeft(BinaryNode* l) { left = l; }vo.. 더보기 LinkedDeque.h : 연결된 덱 클래스 #pragma once#ifndef ___DbLinkedDeque#define ___DbLinkedDeque#include "DblinkedList.h"//Node 클래스 포함//LinkedDeque.h : 연결된 덱 클래스 class LinkedDeque : public DbLinkedList {public:void addFront(Node2 *n) { insert(0, n); }Node2* deleteFront() { return remove(0); }Node2* getFront() { return getEntry(0); }void addRear(Node2* n) { insert(size(), n); }Node2* deleteRear() { return remove(size() - 1); }Node2.. 더보기 DblinkedList.h : 이중 연결 리스트 클래스 #pragma once#ifndef ___DblinkedList#define ___DblinkedList#include "Node2.h"//DblinkedList.h : 이중 연결 리스트 클래스class DbLinkedList {Node2org;//헤드노드public:DbLinkedList() : org(0) {}//생성자~DbLinkedList() { while (!isEmpty()) delete remove(0); }//소멸자void clear() { while (!isEmpty()) delete remove(0); }Node2* getHead() { return org.getNext(); }bool isEmpty() { return getHead() == NULL; } Node2* getEntry(.. 더보기 Node2.h : 이중연결리스트 노드를 나타내기 위한 클래스 #pragma once#ifndef ___Node2#define ___Node2//Node2.h : 이중연결리스트 노드를 나타내기 위한 클래스#include class Node2 {Node2*prev;//선행 노드를 가리키는 포인터 변수Node2*next;//후속 노드를 가리키는 포인터 변수intdata;//데이터 필드public:Node2(int val = 0) : data(val), prev(NULL), next(NULL) {}Node2* getPrev() { return prev; }Node2* getNext() { return next; }void setPrev(Node2* p) { prev = p; }void setNext(Node2* n) { next = n; }void display() { .. 더보기 LinkedList.h : 단순 연결 리스트 클래스 #pragma once#ifndef ___LinkedList#define ___LinkedList//LinkedList.h : 단순 연결 리스트 클래스 #include "Node_Int.h"class LinkedList {Node org;//헤드 노드(헤드 포인터가 아님)public:LinkedList(): org(0) {}//생성자~LinkedList() { clear(); }//소멸자void clear(){ while (!isEmpty()) delete remove(0); }Node* getHead() { return org.getLink(); }bool isEmpty() { return getHead() == NULL; } //pos번째 항목을 반환함Node* getEntry(int pos) {No.. 더보기 Node_Int : 연결된 큐를 위한 int형 클래스 + 연결 리스트로 구현된 리스트를 위한 노드 클래스 #pragma once#ifndef ___Node_Int#define ___Node_Int//Node_Int : 연결된 큐를 위한 int형 클래스 + 연결 리스트로 구현된 리스트를 위한 노드 클래스 #include class Node {Node*link;//다음 노드를 가리키는 포인터 변수int data;//노드의 데이터 필드public:Node(int val = 0) :data(val), link(NULL) {}Node* getLink() { return link; }void setLink(Node* next) { link = next; }void display() { printf(" ", data); }bool hasData(int val) { return data == val; } //자신의 다음에.. 더보기 ArrayList.h : 배열을 이용한 리스트 클래스 구현 #pragma once#ifndef ___ArrayList#define ___ArrayList//ArrayList.h : 배열을 이용한 리스트 클래스 구현 #include #include #define MAX_LIST_SIZE 100//오류 처리 함수inline void error(const char *message) {printf("%s\n", message);exit(1);} class ArrayList {int data[MAX_LIST_SIZE];//실제로 항목 값들이 들어감int length;//현재 리스트 내의 항목들의 개수public:ArrayList(void) { length = 0; }//생성자 ==> length을 초기화 //삽입 연산 : 리스트의 pos번째에 항목 e추가void inse.. 더보기 이전 1 ··· 3 4 5 6 7 8 다음