Postingan

AVL and B3

AVL tree is a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees cannot be more than one for all nodes.  Most of the BST operations (e.g., search, max, min, insert, delete.. etc) take O(h) time where h is the height of the BST. The cost of these operations may become O(n) for a skewed Binary tree. If we make sure that height of the tree remains O(Logn) after every insertion and deletion, then we can guarantee an upper bound of O(Logn) for all these operations. The height of an AVL tree is always O(Logn) where n is the number of nodes in the tree so in short there it is a sorted BST to make searching, inserting, etc, faster. since it has a habt of rebalancing it self. 4 possible case:- left left case left right case right right case right left case for each of the following cases, there are actions took to rebalance the tree and sort the tree by rotating it. B-tree B-Tree is a self-balancing search tree. In most of the ...

summary

To summarise what was learnt in class, we studied about linked list and its type, which is single and double, stack and queue concept, moreover we studied about hashing and how it is fast in order to retrieve data, and binary search tree, the summary is below. link to the coding assignment https://drive.google.com/open?id=1zQnFNFnsSo1HLUdupK6EomdaTY7KRMLW Linked list is a data structure that consist of a sequence of data records such that each record there is a field that contain a reference to the next record in the sequence 3 types :- - single - double - multiple in single list we can create a pointer that can point in one direction, a double linked list we can point to two direction, while a multiple linked list can point to more than two. code snippet for a double linked list. in a single linked list we only have one pointer for ex:- struct tnode *next; there is 2 methods of a linked list, insert and delete. in the code snippet we have insert, to insert ...

Hashing and hash table, Trees and binary tree

Hashing hashing is a technique used for storing and retrieving keys in a rapid manner. in hashing a value is transformed into a shorter value in a way in which it represent a key to that specific value, it is used to index and retrieve data in a way that it is faster that to search manually. hashing can also be defined as a concept of distributing keys in a table(array) using a hash function. Hash function some method to hash a function includes:- - mid-square:- * square the string and then use the appropriate number of bits from the middle of the square to obtain the hash-key - Division :- * divide the string using the modulus operator - folding :- * partition the string into several parts, then add the part together to obtain the hash key - digit extraction :- * predefined the digit of the given number is considered as the hash address - rotating hash :- * use any method of hashing then shift the digits to get a new address Collision there will be cases in which a cert...

Stack and Queue

Gambar
Stack concept data struct which stores data in an ordered matter. It is a linear data structure, elements are added and removed only at one end, which i called top. In a linked list we can use  linked list to implement this data structure, we can push and pop from one end. operation. push(x) :- push a new element pop():- remove an item from the top top:- reveal the top element Queue concept elements are entered through the rear and leave through the front, it follows the FIFO(first in first out) concept. we can use linked list to implement this data structure. operation. push(x):- push a new element through the rear pop():- pop an element through the front front():- return or reveal the front item prefix :- operator is written before operand infix :- operator is written between operand postfix :- operator is written after operand infix =  (10 + 5) * ( 10 - 5 ) / 2 prefix = * + 10 5 / - 5 10 2 postfix = 5 10 + 5 10 - 2 / * // idk if i'm wrong but i try with...

Linked list, pertemuan 2 dan 3

Gambar
Linked list is a data structure that consist of a sequence of data records such that each record there is a field that contain a eference to the next record in the sequence 3 types :- - single - double - multiple in single list we can create a pointer that can point in one direction, a double linked list we can point to two direction, while a multiple linked list can point to more than two. code snippet for a double linked list. in a single linked list we only have one pointer for ex:- struct tnode *next; there is 2 methods of a linked list, insert and delete. in the code snippet we have insert, to insert a new node and free all node starting from the head. we can free from the head, tail or free a certain type of node. most of the explanation of how these 2 functions work is explained in the screenshot.