Posts

Hashing Table

Image
Hashing Hashing is the process of converting any length into a fixed sized string of text using a mathematical function. So no matter how long the text is, it can be converted into an array of numbers and letters through an algorithm.  Understanding the concept of Hash Tables A hash table is a data structure that is used to store information, the information in hash table usually has 2 components which is key and value or some sort of record. A key could be something like name and value could be something like phone number. Basically we're mapping the key to the value here.  In this example, we're representing the hash in shapes. every time the same key is entered it will spit out the same index as for this example in the picture above. Hash Function There are some important methods to hash a string into a key ; Mid- Square Division Folding Digit Extraction Rotating Hash Mid-Square To understand more about mid-square technique we can se...

Linked List II

Image
Linked List Head : address of the head node gives us access of the complete list. Example of linked list implementation in C based on the picture above  struct node{ int data; struct node *next; }; node *A; A = NULL; //empty list node *temp = (node*)malloc(sizeof(node)); temp->data=2; temp->next=NULL; A=temp; node *temp1 = A; while(temp1->next!=NULL) { temp1=temp1->next; temp1->next=temp; } Circular Singly Linked List  Main difference in a single linked list is that it doesn't have of NULL values in the list. The last node will link to the head node so it's circular. Doubly Linked List Every node is a data structure that contains two links, 1 line contains reference to both previous and next data/node. In code it can be written like : struct t_node{ int value; struct node* next;  struct node* prev; }; typedef struct t_node tnode; Examples of inserting new node : tnode *head=0; tnode *tail=0; tnode *node=(tn...