Skip to main content


Showing posts from December, 2021

Linked List

Linked list can be considered as list of nodes ,where each node consist of data to be stored as well as the address of the next node. Example : consider we have a linked-list as [data | addr_of_nxt_node] -> [data | addr_of_nxt_node] -> [data | addr_of_nxt_node] -> [data | NULL] Last element of the linked list will always hold the addr of next node as NULL ,which will be the indication while traversing the list that linkedlist ends here Linked-List operations : - Insert node at begining. - Insert node at position. - Delete node from linkedlist. - Search node in linkedlist. - Sort linkedlist. Demonstration : Let's start Implementing the linkedlist First we need to define the struct of a node As we can see we will define the struct with help of struct where data will be the addr where we will store the values to be stored and next will be used to store the addr of the next ndoe adjacent to current node. Since we have defined the structure of the node ,now l


queue works on the simple principle FIFO (First In First Out) The very simple example of queues are consider you are visit your favourite restaurant and there you are standing in a line to order a food This is nothing but a queue ,the person who comes first will be able to order his/her food first and then second person and so on ,same is the case with the queue ,element added in queue will be removed from the queue first. Example : |COUNTER| person1 <- person2 <- person3 |COUNTER| person2 <- person3 |COUNTER| person2 <- person3 so person1 is in front of the counter so person1 will order the food and will leave the lineand then person2 will be on the counter and will order the food and so on . Let's Dig in the coding part ,how we will design the queue Queue Operations: 1. Enqueue() : To add an element in the queue in front position 2. Dequeue() : To remove an element from the queue from front position Demonstration : First of all we will define pointers


## It is a linear data structre that follows the principle of LIFO i.e Last In First Out Assume you are putting plates on top of previous plate ,like below : Plate-A -> Plate-B -> Plate-C        Plate-A ->  Plate-B           ->  Plate-A in order to get the Plate-A we need to remove all the plate on top of Plate-A which are Plate-B ,Plate-C which is the plate added at last will be remove first which is nothing but LIFO. ## Stack Operations: 1. Push Operation : to add an element in the stack 2. Pop Operation : to remove an element from TOP of the stack 3. Peek Operation : to print the topmost element without removing it from the stack 4. is_full Operation : whether stack is full or not 5. is_empty Operation: whether stack is empty or not ## Demonstration : # we will include the mandate libraries first Then we will define the struct of stack using struct in c. # Although there are n number of ways to implement stack ,so demonstration here is one of t

Asymptotic notations

## ASYMPTOTIC NOTATION : Efficiency of algorithm depends on amount of time ,storage and other resources required to execute an algorithm. Efficiency is measured with help of asymptotic notations. Asymptotic notations are mathematical notations used to decribe execution time of an algorithm when input tends towards a particular value or limiting value. THREE ASYMPTOTIC NOTATIONS : 1. Big-O notation : used to measure the worst case scenerio of an algorithm .It generally gives an upper bound. in simple words we can say that (O) notation is used to measure the maximum time that an algorithm can take to execute. 2. Omega notations : used to measure the best case scenerio of an algorithm .It generally gives lower bound .In simple words we can say that theta notation is used to measure the minimum time that an alogrithm can take to execute. 3. Theta notations : used to measure the average case scenerio of an alogrithm .It generally gives the average bound. In simple words we

Data Structure & Algorithm

## DATA STRUCTURES : It is a way of arranging data on a computer so that it can be accessed & updated efficiently ## ALGORITHMS : Algorithms are an instructions or a way to solve the problem using the data which is stored with the help of data structure. ## TWO TYPES OF DATA STRUCTURE: 1. Linear data structure : 1) Arrays 2) Stack 3) Queue 4) Linked-List 2. Non-Linear data structure: 1. Graphs 2. Trees