Skip to main content

Posts

Showing posts from January, 2022

Graph Data Structure

Graph A graph can be defined as a group of vertices and edges that are used to connect these vertices. A graph can be seen as a cyclic tree, where the vertices (Nodes) maintain any complex relationship among them instead of having parent child relationship. A graph G can be defined as an ordered set G(V, E) where V(G) represents the set of vertices and E(G) represents the set of edges which are used to connect these vertices. A Graph G(V, E) with 5 vertices (A, B, C, D, E) and six edges ((A,B), (B,C), (C,E), (E,D), (D,B), (D,A)) is shown in the following figure. Directed and undirected graph Graph terminology Graph Representation Directed Graph Adjancency Matrix Graph Traversal Depth first search algorithm Directed and undirected graph A graph can be directed or undirected. However, in an undirected graph, edges are not associated with the directions with them. An undirected graph does not have any edges in directions. If an edge exists between ver

Tree Data Structure

Tree A Tree is a recursive data structure containing the set of one or more data nodes where one node is designated as the root of the tree while the remaining nodes are called as the children of the root. Nodes of a tree either maintain a parent-child relationship. In a general tree, A node can have any number of children nodes but it can have only a single parent. concept of tree data structure Binary Tree Binary Search Tree Advantages of Binary Search Tree Representation of Binary search tree Traversal in Tree Root Node The root node is the topmost node in the tree hierarchy. In other words, the root node is the one which doesn't have any parent. Sub Tree If the root node is not null, the tree T1, T2 and T3 are called sub-trees of the root node. Leaf Node The node of a tree, which doesn't have any child nodes, is called leaf node. Leaf node is the bottom most node of the tree. There can be any number of leaf nodes present in

Linked List Data Structure

Linked List Prerequisites for Linked List Definition of linkedlist Important points of Linked List Types of Linked List Basic Operations performed on Linked List Difference Between Linked List and Arrays Drawbacks of Linked List Applications of Linked List In real world Singly Linked List in C Doubly Linked List in C Singly Circular Linked List in C Doubly Circular Linked Listist in C Add node in Singly Linked List Display Data of Linked List Deletion of a node from linked list Prerequisites for Linked List pointer concept (*ptr) Address Operator (&ptr) Pointer A pointer is a variable which stores the address of another variable. By using a pointer we can directly access the memory address of the variable. Like any variable or constant, you must declare a pointer before using it to store any variable address. The general form of a pointer variable declaration is type *variable-name; Here, type is the pointer

Stack Data Structure

Stack In this blogpost we are going to learn about Stack. What is the stack? What is the LIFO? What are stack operations? What is the pop operation ?, What is the push operation?, How to perform push/pop operation on stack? and conversions using stack. What is the stack data structure Basic Operations of Stack What is the push operation in Stack What is the pop operation in Stack What are applications of Stack Infix to postfix conversion Defination of 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) . There are many real-life examples of a stack. Consider an example of plates stacked over one another in the canteen. The plate which is at the top is the first one to be removed, i.e. the plate which has been placed at the bottommost position remains in the stack for the longest period of time. So, it can be simply seen to follow