void test_seq(int n) { BiTree_s tree = { 0 }; Rec_s rec; unint i; if (FALSE) seed_random(); for (i = 0; i < n; i++) { rec.key = seq_lump(); rec.val = rnd_lump(); bi_insert(&tree, rec); } bi_print(&tree); }
void test_bi_find(int n) { BiTree_s tree = { 0 }; Rec_s rec; unint i; if (FALSE) seed_random(); for (i = 0; i < n; i++) { rec.key = fixed_lump(7); rec.val = rnd_lump(); r_add(rec); bi_insert(&tree, rec); } r_for_each(find_find, &tree); bi_audit(&tree); }
void test_rnd(int n) { BiTree_s tree = { 0 }; Rec_s rec; unint i; if (FALSE) seed_random(); for (i = 0; i < n; i++) { rec.key = fixed_lump(7); rec.val = rnd_lump(); bi_insert(&tree, rec); } // bi_print(&tree); // pr_all_records(&tree); // pr_tree(&tree); bi_audit(&tree); }
void interpret(int a[], int *np, int N) { char command[2]; char key[2]; int p; while (command[0] != 'q') { printf("\nInput command ->"); scanf("%1s", command); scanf("%1s", &key); switch (command[0]) { case 'i' : case 'I' : if (*np < N) { bi_insert(key[0], a, np); printf("\n Successful insert."); } else printf("\n Error : Table full."); break; case 'd' : case 'D' : if (bi_delete(key[0], a, np) < 0) printf("\n Error : Table Empty."); else printf("\n Successful delete."); break; case 's' : case 'S' : if ((p = bi_search(key[0], a, *np)) < 0) printf("\n Error : Can'f find that key"); else printf("\n Ok! find in %d th position", p); break; case 'f' : case 'F' : if ((p = bii_search(key[0], a, *np)) < 0) printf("\n Error : Can't find that key"); else printf("\n Ok ! find in %d th position & move front", p); break; case 'l' : case 'L' : bi_list(a, *np); break; } printf(" n = %d", *np); } }