Postingan

Menampilkan postingan dari Maret, 2020

Binary Search Tree

Gambar
Binary Tree Binary Tree adalah struktur data yang mirip dengan Linked List. Bila Linked List dianalogikan sebagai rantai yang linier maka Binary Tree dianalogikan sebagai pohon. Binary Tree dikelompokkan menjadi tree yang tidak berurut (unordered Binary Tree) dan tree yang terurut (ordered Binary Tree). Binary Tree dapat digambarkan berdasarkan kondisinya, yaitu:  Binary Search Tree (BST) merupakan tree yang terurut (ordered Binary Tree) yang memiliki kelebihan bila dibanding dengan struktur data lain. Diantaranya adalah proses pengurutan (sorting) dan pencarian (searching) dapat dilakukan bila data sudah tersusun dalam struktur data BST. Pengurutan dapat dilakukan bila BST ditelusuri (traversed) menggunakan metode in-order. Detail dari proses penelusuran ini akan dibahas pada pertemuan selanjutnya. Data yang telah tersusun dalam  struktur data BST juga dapat dicari dengan mudah dan memiliki rata-rata kompleksitas sebesar O(log n), namun membutuhkan waktu sebesar O(...

Hashing Table and Binnary Tree. The Implementation in Blokchain

Introduction  Hash Table :  An array that stores pointers to records corresponding to a given phone number. An entry in hash table is NIL if no existing phone number has hash function value equal to the index for the entry. Collision Handling : Since a hash function gets us a small number for a big key, there is possibility that two keys result in same value. The situation where a newly inserted key maps to an already occupied slot in hash table is called collision and must be handled using some collision handling technique. Following are the ways to handle collisions: Chaining: The idea is to make each cell of hash table point to a linked list of records that have same hash function value. Chaining is simple, but requires additional memory outside the table. Open Addressing:  In open addressing, all elements are stored in the hash table itself. Each table entry contains either a record or NIL. When searching for an element, we one by one examine table slots until...

Single Linked List (Push and Pop)

Implement a  stack  using linked list concept. all the  linked list   operations perform based on Stack operations LIFO(last in first out) and with the help of that knowledge we are going to implement a stack using  linked list.  Stack ope rations: push () : Insert the  element  into  linked list  nothing but which is the top node of Stack. pop () : Return top  element  from the Stack and move the top pointer to the second node of  linked list  or Stack Example of push and pop using linked list in c: Single linked list: push_front: 5, 3, 7, 9 the output are: 9 ->7 ->3 -> 5 -> NULL void push_front(int number){ current=(struct data*)malloc(sizeof(struct data)); current->number = number;  if(head==NULL){ head=tail=current; tail->next=NULL; } else{ current->next=head; head=current; } } void show (){ current=head; while(current!=NU...