Postingan

Menampilkan postingan dari Maret, 2020

Hash and Trees

Gambar
This GSLC Session, My lecturer asking us to make a blog about Hashing and Trees. So here it is, my take on Hashing and Trees Data structure. What is Hashing? Hashing is a technique used for temporary storing and retrieving keys in a rapid and fast manner. Hashing is used as a data structure because for example, if you want to find if there is a certain string that exists in an array, we could make a key to connect it with so it's easier and more efficient to do search function for it.  Hashing is used to index and retrieve items in a database because it is faster to find the item using shorter hashed keys than to find it using the original value. The example of hashing in real-life implementation is cryptocurrency. Hash Table A hash table is a data structure that consists of a table and a function to map unique key values for each row and become the number of record locations in a table. The advantage of hash tables is that the time to access is faster because the recor...

Pertemuan ke III : Data Structure Linked List | C Programming Languange

Dari blog saya yang sebelumnya, kita lebih mengenal tentang Linked List, Perbedaan Linked List dengan Array, dan Jenis-Jenis Linked List yang ada. Nah, Sekarang ayo kita mencoba mempraktekkan membuat sebuah singly linked list di salah satu programming languange yang populer, C Programming Languange. #include <stdio.h> #include <stdlib.h> struct Node{ int val; struct Node* next; }*head,*tail,*curr, *temp; void pushmiddle(int val,int a){ curr = (struct Node*)malloc(sizeof(struct Node)); curr->val = val; curr->next = NULL; temp = head; for(int i = 1; i < a; i++){ temp = temp->next; } if(temp->next==NULL) { printf("ERROR"); } curr->next=temp->next; temp->next=curr; } void pushhead(int val){ curr = (struct Node*)malloc(sizeof(struct Node)); curr->val = val; curr->next = NULL; if(head == NULL) { head = tail = curr; } else { curr->next=head; head = curr; } } void pus...