기타 코드 낙서장/알고리즘 (2) 썸네일형 리스트형 탐색이진트리 구현 탐색이진트리를 구현 해 보았습니다 #include #include typedef struct Node{ int data; struct Node * L; struct Node * R; }Node; // 노드를 생성하는 함수 // 중복되는 값은 오른쪽으로 보낸다. Node * Node_add(Node * root, int data){ if(root==NULL){ root=(Node*)malloc(sizeof(Node)); root->data=data; root->L=NULL; root->R=NULL; } else if(root->data>data){ root->L=Node_add(root->L,data); } else{ root->R=Node_add(root->R,data); } return root; } .. 연결리스트 구현 #include #include #include typedef struct Node{ int data; struct Node * next; }Node; Node * head=NULL; Node * current=NULL; Node * before=NULL; //해당 데이터를 갖는 노드를 1개 생 성 void newNode(int data){ Node * nNode = (Node*)malloc(sizeof(Node)); nNode->data = data; nNode->next = NULL; if(head == NULL){ head=nNode; current=nNode; } else{ current->next = nNode; current = current->next; } } //해당 데이터를 갖는 노드 1.. 이전 1 다음