Posts

Showing posts from March, 2020

Binary Search Tree

Image
Binary Search Tree  is a node-based binary tree data structure which has the following properties: The left subtree of a node contains only nodes with keys lesser than the node’s key. The right subtree of a node contains only nodes with keys greater than the node’s key. The left and right subtree each must also be a binary search tree The above properties of Binary Search Tree provide an ordering among keys so that the operations like search, minimum and maximum can be done fast. If there is no ordering, then we may have to compare every key to search a given key.

Hashing and Hash Tables, Trees & Binary Tree

Hashing Suppose we want to design a system for storing employee records keyed using phone numbers. And we want following queries to be performed efficiently:          Insert a phone number and corresponding information.         Search a phone number and fetch the information.        Delete a phone number and related information. We can think of using the following data structures to maintain information about different phone numbers.        Array of phone numbers and records.        Linked List of phone numbers and records.        Balanced binary search tree with phone numbers as keys.         Direct Access Table. Hashing is an improvement over Direct Access Table. The idea is to use hash function that converts a given phone number or any other key to a smaller number and uses the small number as index in a ...

Stack and Queue in Data Structure

Image
Note: The following article is in English Stack Stack is a linear data structure which follows a particular order in which the operations are performed. The order may be LIFO (Last In First Out) or FILO(First In Last Out). Mainly the following three basic operations are performed in the stack: ·          Push: Adds an item in the stack. If the stack is full, then it is said to be an Overflow condition. ·          Pop: Removes an item from the stack. The items are popped in the reversed order in which they are pushed. If the stack is empty, then it is said to be an Underflow condition. ·          Peek or Top: Returns top element of stack. ·          isEmpty: Returns true if stack is empty, else false.

Circular Linked List, Doubly Linked list, and Circular Doubly Linked List

Single Linked List Circular Single Linked List Circular adalah Single Linked List yang pointer nextnya menunjuk pada dirinya sendiri. Jika Single Linked List tersebut terdiri dari beberapa node, maka pointer next pada node terakhir akan menunjuk ke node terdepannya. Pengertian: ·       Single : artinya field pointer-nya hanya satu buah saja dan satu arah. ·       Circular : artinya pointer next-nya akan menunjuk pada dirinya sendiri sehingga berputar Ilustrasi Single Linked List Circular -     Setiap node pada linked list mempunyai field yang berisi pointer ke node berikutnya, dan juga memiliki field yang berisi data. -     Pada akhir linked list, node terakhir akan menunjuk ke node terdepan sehingga linked list tersebut berputar. Node terakhir akan menunjuk lagi ke head.