Found 510 Articles for Algorithms

Flooding versus Fixed Routing Algorithms

Moumita
Updated on 22-Feb-2021 11:25:54

1K+ Views

Flooding and fixed routing are methods to transmit data packets from the source to the destination through a number of intermediate routers connected by transmission lines.Flooding is a non-adaptive routing technique following this simple method − when a data packet arrives at a router, it is sent to all the outgoing links except the one it has arrived on.Fixed routing algorithm is a procedure that lays down a fixed route or path to transfer data packets from source to the destination. The route is a mathematically computed best path, i.e. “least–cost path” that the packet can be routed through. The ... Read More

Insertion in the Red Black Tree in Data Structure

Dev Prakash Sharma
Updated on 05-Feb-2021 12:42:32

7K+ Views

Red Black Tree is a Self-Balanced Binary Search Tree in which each node of the tree is colored with either Red or Black. There are three types of operations we can perform on a Red Black Tree – Searching, Insertion and Deletion.Let us suppose we have to insert an element in the following Red Black Tree.To insert an element in a red-black tree the idea is very simple − we perform insertion just like we insert in a regular binary tree. We start off from the root node by checking the color of the node and insert it into a ... Read More

Floyd Cycle Detection Algorithm to detect the cycle in a linear Data Structure

Dev Prakash Sharma
Updated on 05-Feb-2021 12:22:42

485 Views

Floyd Cycle is one of the cycle detection algorithms to detect the cycle in a given singly linked list.In the Floyd Cycle algorithm, we have two pointers that initially point at the head. In Hare and Tortoise’s story, Hare moves twice as fast as Tortoise, and whenever the hare reaches the end of the path, the tortoise reaches the middle of the path.AlgorithmInitialize Hare and Tortoise at the head node of the List.Initially, the hare moves twice as fast as the tortoise.Move the hare and tortoise both and find if the hare reaches the end of the Linked List, return ... Read More

Auto-complete feature using Trie

Hafeezul Kareem
Updated on 21-Sep-2020 13:19:12

445 Views

We have a Trie, and when a user enters a character, we have to show the matching string the Trie. This feature we call it as auto-completion. For example, if a Trie contains "xyzzzz, ""xyz, " "xxxyyxzzz" and when the user enter xy, then we have to show them xyzzzz, xyz, etc.., Steps to achieve the result.Search for the string using the standard Trie algorithm.If the string is not present, then return -1.If the string is present and is the end of a word in Trie, then print the string.If the matching string doesn't have any node, then return.Else print ... Read More

Segment Trees in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:52:15

358 Views

In this section we will see what is the segment tree. Before discussing that, let us see one problem.Suppose we have an array arr[0, …, n-1], We can do following operations −Find the sum of elements from index l to r, where 0 ≤ l ≤ r ≤ n-1Change the value of a specified element of the array to a new value x. We need to do arr[i] = x. The i in range 0 to n – 1.We can solve this problem by using the Segment tree. The segment tree can help us to get the sum and query ... Read More

Interval Trees in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:50:46

1K+ Views

In this section we will see what is the interval tree. As the name suggests, that the interval trees are the trees which are associated with the intervals. So before discussing about the interval trees, let us see the elementary intervals.An interval is basically a range. So if one interval is written as [a, b] it indicates that the range is starting from a, and ending at b.Now suppose there is an interval [10, 20]. So there are three range values. First one is -∞ to 10, 10 to 20 and finally 20 to ∞Now, suppose we will create second ... Read More

B+ tree Deletion in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:47:36

649 Views

Here we will see, how to perform the deletion of a node from B+ Tree. Suppose we have a B+ Tree like below 7minus;Example of B+ Tree −Deletion has two parts. At first we have to find the element. That strategy is like the querying. Now for deletion, we have to care about some rules. One node must have at-least m/2 elements. So if we delete, one element, and it has less than m-1 elements remaining, then it will adjust itself. If the entire node is deleted, then its children will be merged, and if their size is same as ... Read More

B-tree Deletion in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:31:37

919 Views

Here we will see, how to perform the deletion of a node from B-Tree. Suppose we have a BTree like below −Example of B-Tree −Deletion has two parts. At first we have to find the element. That strategy is like the querying. Now for deletion, we have to care about some rules. One node must have at-least m/2 elements. So if we delete, one element, and it has less than m-1 elements remaining, then it will adjust itself. If the entire node is deleted, then its children will be merged, and if their size issame as m, then split them ... Read More

B-tree Insertion in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:25:53

635 Views

Here we will see, how to perform the insertion into a B-Tree. Suppose we have a B-Tree like below −Example of B-Tree −To insert an element, the idea is very similar to the BST, but we have to follow some rules. Each node has m children, and m-1 elements. If we insert an element into one node, there are two situations. If the node has elements less than m-1, then the new element will be inserted directly into the node. If it has m-1 elements, then by taking all elements, and the element which will be inserted, then take the ... Read More

B-tree Query in Data Structure

Arnab Chakraborty
Updated on 11-Aug-2020 07:27:13

515 Views

Here we will see, how to perform the searching in B-Tree. The B-Tree searching is also known as B-Tree Querying. Suppose we have a B-tree like below −Example of B-Tree −The searching technique is very similar to the binary search tree. Suppose we want to search 66 from the above tree. So we will start from root, now 66 is larger than root element 46. So we will move to the right child of the root. Then the right child has more than one element. The elements are sorted, they are [56, 81]. Our target key is larger than 56, ... Read More

Advertisements