2014년 4월 25일 금요일

queue

#include<iostream>
using namespace std;
typedef struct node* itemType;
struct node{
char info;
struct node *l, *r;
};

struct node *x, *z;

class Queue{
private:
t = itemType *queue;

public:
void put(itemType){
queue[tail++] = v;
if(tail > size)
tail = 0;
}
itemType get(){
itemType t = queue[head++];
if(head>size)
head = 0;
return t;
}
int empty(){
return head == tail;
}
};


void visit(struct node *t){
cout << t->info <<" ";
}

void levelOrderTraverse(strcut node *t){
queue.put(t);
while(!queue.empty()){
t = queue.get();
visit(t);
if(t)
}
}

댓글 없음:

댓글 쓰기