Posts

Image
Final Summary by : Philips Linked List Hello, fellow programmers! I'm sure most of you must've heard about  Array  before, don't you? Well today we'll be talking about something similar but slightly different, it's called  Linked List . What is Linked List ? If I were to associate it with things, I'll say linked list is sort of like a ton of numbered & locked box, where each box contains an item and a key to the next box. Formally speaking, Linked list is basically a collection, or a structure containing records of data, where each record contain the address or reference to the record next to it (sequencially). There are two kinds of Linked List, they are called Single Linked List and Double Linked List. As the name suggests, Single Linked List is linked list that contains only the 'address/key' of the box after it, while Double Linked List contains both before and after. Meaning, if you accidentally missed t...

AVL

Image
Introduction Hello there, in the previous post I've talked about Binary Search Tree before. Some of you might've encountered a situation where when you input the first data with extreme value (too big or too small), the following leaves/nodes just get overweight at one side, probably looking like this. 100 /  50    /  \    45  60      /              30                 Actually, there's nothing wrong with it. But since one invented an innovation towards this, here we are, a self-balancing binary tree : AVL tree. Technically speaking, AVL tree is an self-balancing binary tree in which the difference of depth between left and right subtree cannot be more than one. How does it work So basically, everytime when we input a data, we check on the balance between the right and left sub trees, and perform rotation accordingly to realign [reba...

Summary

Image
Hello guys, so today we'll be doing a quick summary of Linked List, Hashing, and Binary Tree :D Linked List If I were to associate it with things, I'll say linked list is sort of like a ton of numbered & locked box, where each box contains an item and a key to the next box. Formally speaking, Linked list is basically a collection, or a structure containing records of data, where each record contain the address or reference to the record next to it (sequencially). As I suggested before, there's Single Linked List and Double Linked List, right? In following I'll include some basic function from the infamous Double Linked List. #include<stdlib.h> -> Jangan lupa struct data{ int value; struct data *prev, *next; }*head, *tail, *curr; void boom(){ head->prev=tail; tail->next=head; } void pushHead(int a){ curr=(struct data*)malloc(sizeof(struct data)); curr->value=a; if (head==NULL){ head=tail=curr; } else{ curr-...

Binary Search Tree

Halo semuanya, pada postingan sebelumnya saya suda menjelaskan sekilas mengenai konsep Binary Tree. Pada postingan kali ini saya ingin menjelaskan soal searching pada Binary Tree. Searching disini menggunakan teknik rekursif ya man teman. Algoritmanya cukup sederhana, jadi apabila root (ibaratnya current) ketemu sama key (kata kunci) yang ingin kita cari, maka return root, or else geser. Itu saja sih man teman, makasi yaa. struct node* search( struct node* root, int key) {      // Base Cases: if the root is null or key is present at root      if (root == NULL || root->key == key)         return root;             // If key is greater than root's key      if (root->key < key)         return search(root->right, key);          // If key is smalle...