Posts

Summary of Everything

Image
Linked List Linked List is a type of linear data structure. It is not like an array but instead linked list elements are not stored at a contiguous location. In linked list the elements are linked using pointers. A linked list is better than array in terms of insertion and deletion since linked list makes it easier to do that. A drawback about using Linked List is that it doesn't allow random access instead it has to access it sequentially starting from the 1st node. we cannot use binary search with linked list with its default implementation. Stack and Queue Stack is a linear data structure that follows a particular order in which the operators performed. The order can be "Last to enter First to get out" or "First to enter First to Get Out". In C# stack has 4 basic operators which are Push, Pop, Peek, isEmpty. Push is used to add an item in the stack. Pop is used to remove an item in the stack. Peek is used to return the object at the beginning of the sta...

Binary Search Tree

Image
Binary Search Tree Binary Search Tree is a node-based binary tree which has a few certain properties. Nodes on the left of the tree contain nodes with a lower value than the node's value while the one on the right contains nodes that have greater keys than the node's value. Also, Binary Search tree can only have a maximal of 2 child node under each node. In Binary search tree there are traversals: 1. InOrder(Left, Root, Right) 2. PreOrder(Root, Left, Right) 3. PostOrder(Left, Right, Root) //data printing //preOrder void preOrder(struct node *node) { if (node!=NULL) { printf("%d ", node->key); preOrder(node->left); preOrder(node->right); } } //inOrder void inOrder(struct node *node) { if (node!=NULL) { inOrder(node->left); printf("%d ", node->key); inOrder(node->right); } } //postOrder void postOrder(struct node *node) { if (node!=NULL) { postOrder(node->left); postOrder(node->right); printf("%d ...

Stack and Queue

Image
Stack and Queue Stack is a linear data structure that follows a particular order in which the operators performed. The order can be "Last to enter First to get out" or "First to enter First to Get Out". In C# stack has 4 basic operators which are Push, Pop, Peek, isEmpty. Push is used to add an item in the stack. Pop is used to remove an item in the stack. Peek is used to return the object at the beginning of the stack without removing it. Clear is used to remove all objects in the stack. But before all this we need to use the command Stack() to create the stack  Stack stack_name = new Stack();. A Queue is a linear structure which follows a particular order in which the operations are performed. The ordering used in queue is First in First out.  To create a Queue we have 4 constructors which are used in making them. Queue(), Queue(collection), Queue(Int32), Queue(Int32, Single).( Queue queue_name = new Queue();) To add a queue we use Enqueue() to add somethi...

Linked List

Linked List Linked List is a type of linear data structure. It is not like an array but instead linked list elements are not stored at a contiguous location. In linked list the elements are linked using pointers. A linked list is better than array in terms of insertion and deletion since linked list makes it easier to do that. A drawback about using Linked List is that it doesn't allow random access instead it has to access it sequentially starting from the 1st node. we cannot use binary search with linked list with its default implementation. A Linked list is represented by a pointer on the 1st node of the linked list which is called the "head". If a linked list is empty the value of the head is NULL. Each node in a list consist of a minimal of 2 parts which is data and a pointer. 
Image
Hashing Hashing is a technique used for storing and retrieving keys in a quicker option.  A  hash is  a value computed from a base input number using a hashing function.  In hashing, a string of characters is transformed into a usually shorter 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 an item using shorter hashed keys than to find it using the original value. Hash Table Hash table is an array where it stores the original string. The index of the table is the hashed key while the value is the original string. The size of the hash table is usually several orders of magnitude lower than the total number of possible string, so several strings might have the same hashed-keys. Example: Supposed we want to store 5 string: Apple, Fish, Banana, Dog, Chair into a hash table with size 26. The hash function we are gonna use is “transform the first letter o...