Articles for category: Data Structures and Algorithms

Binary Search Tree (BST)

A binary search tree (BST) is a sorted binary tree, where we can easily search for any key using the binary search algorithm. To sort the BST, it has to have the following properties: The node’s left subtree contains only a key that’s smaller than the node’s key. Takeaways Searching is a trivial part of everyday life. It’s ...

Counting Sort Algorithm

Counting Sort Algorithm is a sorting algorithm that works best when you have a small range of numbers to sort. Instead of comparing elements like in other sorting methods, it counts how many times each number appears and then puts them in order based on that count. This makes it really fast when the range ...

Types of Graph in Data Structure with Examples

A graph can be defined as group of vertices and edges that are used to connect these vertices. In data structure, a graph G=(V,E) is a collection of sets V and E where V and E are the collections of vertices and edges respectively. An edge is a line or arc connecting 2 vertices and it is denoted by a pair (i,j) where i,j belong to a set of vertices V. Let’s see types ...

Insertion Sort Algorithm

Insertion sort is an important method in organizing data, especially good at sorting small groups of information. It works by dividing a list into two parts: one that’s already sorted and one that’s not. Just like when you sort playing cards, it takes each item from the unsorted section and finds the right spot for ...

Linear Search Algorithm

Searching is a method to find some relevant information in a data set. In computer programming, searching is usually referred to as finding a particular element in a data structure. Linear search algorithm is a straightforward search algorithm. This type of search performs a sequential search on all items individually. In this article, we will ...

Binary Search Algorithm

Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item, until you’ve narrowed down the possible locations to just one. Takeaways This is the second part of a three-part series on Searching Algorithms. ...

Interpolation Search Algorithm

Interpolation search is an algorithm similar to binary search for searching for a given target value in a sorted array. Takeaways This is the third part of a three-part series on Searching Algorithms. In the previous article about binary Search, we discussed one of the best searching algorithms out there. If you didn’t get a chance to read ...

Selection Sort Algorithm

The selection sort algorithm efficiently arranges elements into two sections: sorted and unsorted sublists. This method simplifies list organization, enhancing sorting efficiency. In this article, we delve into the mechanics of selection sort, explaining its process and effectiveness in sorting various types of lists. Let’s explore what selection sort is and how it works. Takeaways ...

Bubble Sort Algorithm

Bubble Sort, a basic sorting algorithm, operates by repeatedly swapping adjacent elements if they are incorrectly ordered. Consider a list with elements 5, 4, 3, and 2; sorting algorithms like Bubble Sort can organize them in either ascending or descending order, rearranging elements to form meaningful sequences, as illustrated in this example. Ascending Sorting  Descending Sorting  ...

Binary Subtraction – Rules, Examples, Procedure

Binary subtraction of numbers can be done by adding the 2’s complement of the second number to the first number. Binary subtraction is just the binary addition of a negative number. Takeaways In binary subtraction, we are adding the 2’s complement of the subtrahend and adding into the number from which we want to subtract that. Before we begin, let’s look ...