Bài tập cấu trúc dữ liệu
Trang 1/* Bai toan tam hoang hau */
Trang 4int isempty(int _stack)
Trang 5} while (k != -1 && !is_full());
printf("\n\nLay cac phan tu tu queue ra : ");
while (!is_empty())
{
pop(&k);
printf("%d ", k);
Trang 6} while (k != -1 && !is_full());
printf("\n\nLay cac phan tu tu stack ra : ");
Trang 7while (!is_empty()) {
Trang 8typedef int element_type;
typedef struct node {
element_type element;
struct node *left, *right;
} NODE;
NODE *root;
#define max(a,b) ((a) > (b)? (a) : (b))
void khoi_tao_cay(NODE ** root)
Trang 11printf("\nTim thay tai vi tri : %d", k);
printf("\nChuoi tim thay : %s", found);
Trang 12for (i=1; i< MAX; i++)
for (j=MAX-1; j>=i; j )
{
Trang 13typedef int element_type;
typedef struct node {
Trang 14void insert_node(element_type e, NODE **root)
if (root->left != NULL || root->right != NULL)
return dem_nut_la(root->left) + dem_nut_la(root->right);
if (root->left != NULL && root->right != NULL)
return dem_nut_day_du(root->left) + dem_nut_day_du(root->right) + 1; else
return dem_nut_day_du(root->left) + dem_nut_day_du(root->right); }
Trang 15typedef int element_type;
typedef struct node {
Trang 16printf("\nTong so nut cua cay = %d", tong_nut);
printf("\nTong so nut rong = %d", tong_nut_rong);
struct node *next;
} *first = NULL, *last = NULL;
Trang 22struct node *next;
} *first = NULL, *last = NULL;