Posts

Showing posts from March, 2020

Hashing and Binary Tree

Image
Binary Tree Unlike Arrays, Linked Lists, Stack and queues, which are linear data structures, trees are hierarchical data structures.  A binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child. It is implemented mainly using Links. Hashing Hashing is the transformation of a string of character s into a usually shorter fixed-length value or key that represents the original string. Hashing is used to index and retrieve items in a database  because it is faster to find the item using the shorter hashed key than to find it using the original value. It is also used in many encrytion  algorithms.

Linked List

Image
Linked list Linked list adalah sebuah data structure yang bersifat linear, yang elemen-elemennya tidak tersimpan di sebuah lokasi memori yang saling berjejer. Berbeda array, linked list mampu menyimpan elemen-elemennya dengan jumlah yang sangat besar karena tidak perlu memberitahu  jumlah memori yang harus di siapkan terlebih dahulu. Elemen-elemen yang ada di linked list terhububung menggunakan pointer yang saling menunjuk elemen lain seperti contoh dibawah ini. Doubly linked list Salah satu contoh bentuk linked list adalah doubly linked list. Doubly linked list tetap memliki HEAD dan TAIL tapi perbedaannya adalah setiap elemen meliki dua pointer untuk menunjuk elemen sebelum(*PREV) dan elemen sesudah(*NEXT) seperti gambar dibawah. -Deklarasi struct dalam pembuatan doubly linked list di C adalah typedef digunakan untuk memudahkan penulisan dari struct Data menjadi Dt. -Unutk memasukan data dari HEAD (pushHead). Sebelum mengecek AGE kita perlu mengecek...