int main(int argc, char **argv) { int i; struct Hashtable hash_table; //Allocate memory for a new hash table newHashTable(&hash_table, HASHTABLE_LENGTH); printf("New hash table containing no values\n"); //Print the hash table containing no values for(i=0;i<HASHTABLE_LENGTH;i++){ print_ll(&(hash_table.table[i])); } putchar('\n'); //Insert several values into the hash table insert(&hash_table, "Hello World"); insert(&hash_table, "Hello World"); insert(&hash_table, "Hel World"); insert(&hash_table, "GoodBye"); insert(&hash_table, "GoodBye"); insert(&hash_table, "wangbang"); insert(&hash_table, "Holachola"); insert(&hash_table, "antidis"); printf("Test values inserted printing full hash_table...\n"); //Print the list again for(i=0;i<HASHTABLE_LENGTH;i++){ print_ll(&(hash_table.table[i])); } //Deallocate memory freeHashTable(&hash_table); }
int main() { node_t *head = NULL; head = insert_node(head, 10); head = insert_node(head, 12); head = insert_node(head, 15); head = insert_node(head, 5); head = insert_node(head, 7); print_ll(head); head = reverse_ll(head); print_ll(head); return 0; }
void print_ll(struct node* head) { if (head) { printf("%d ", head->data); print_ll(head->next); } }
int main() { int i, j; insert_data(55); print_ll(); insert_data(22); print_ll(); insert_data(19); insert_data(5); insert_data(50); insert_data(87); insert_data(79); insert_data(33); insert_data(99); insert_data(29); insert_data(8); print_ll(); delete_data(79); delete_data(77); delete_data(55); print_ll(); i = 87; if ( (j=search_ll(i)) == -1) printf("\n%d is not present in the list\n", i); else printf("\n%d is present in the list at index: %d\n", i, j); i = 2; if ( (j=search_ll(i)) == -1) printf("%d is not present in the list\n", i); else printf("%d is present in the list at index: %d\n", i, j); return 0; }
void main() { ll_ptr nd = NULL; int i=0; int inv_ct =0; //for(i=0;i<5;i++) push_ele_hd(&nd,15); push_ele_hd(&nd,3); push_ele_hd(&nd,2); push_ele_hd(&nd,10); push_ele_hd(&nd,1); push_ele_hd(&nd,-1); push_ele_hd(&nd,100); print_ll(nd); printf("Count is %d \n:",simple_inv_count_re(nd,nd)); nd = msort(nd,&inv_ct); print_ll(nd); printf("Recur Count is %d \n:",inv_ct);
int main() { int ch; struct node* head; struct node* addresses[100]; scanf("%d", &ch); do { head = insert_end(head, ch); scanf("%d", &ch); } while (ch != -1); printf("\n"); print_ll(head); int cnt = hash_table_approach(head, addresses); printf("\nCount of nodes is : %d \n", cnt); struct node* mid_ptr = addresses[cnt/2]; printf("\nThe middle node is %d\n", mid_ptr->data); return 0; }
int main() { struct node* head; int ch; printf("\nEnter more than 5 nodes for proper execution of program\n"); scanf("%d", &ch); do { head = insert_at_end(head, ch); scanf("%d", &ch); }while (ch != -1); printf("\n"); print_ll(head); printf("\n"); make_linkage(head); struct node* ret_val = has_loops(head); if (ret_val) printf("\nLL has loop at %d \n", ret_val->data); else printf("\nLL has no loops\n"); return 0; }
//Merge sort algo ll_ptr msort(ll_ptr nd,int *inv_ctr) { if(nd == NULL || nd->next ==NULL) { print_ll(nd); return nd; } ll_ptr ft = NULL; ll_ptr bk = NULL; split_list(nd,&ft,&bk); ll_ptr nd1 = msort(ft,inv_ctr); ll_ptr nd2 = msort(bk,inv_ctr); return smerge(nd1,nd2,inv_ctr); //ll_ptr nd_ret = NULL; //nd_ret = smerge_recur(&nd_ret,nd1,nd2); //return nd_ret; }
int main() { print_ll(); insert_data(10); print_ll(); insert_data(20); insert_data(30); insert_data(15); insert_data(40); insert_data(50); insert_data(25); insert_data(60); print_ll(); delete_data(100); print_ll(); delete_data(15); print_ll(); delete_data(25); print_ll(); delete_data(10); print_ll(); delete_data(20); print_ll(); delete_data(60); print_ll(); delete_data(50); print_ll(); delete_data(30); print_ll(); delete_data(40); print_ll(); delete_data(40); print_ll(); return 0; }