Articles for category: Data Structures and Algorithms

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 ...

Merge Sort Algorithm

Merge Sort algorithm is a Divide and Conquer algorithm. It divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. Merge Sort algorithm is one of the most respected sorting algorithms, with a worst-case time complexity of O(nlogn). Merge sort works by dividing the array repeatedly to ...

Euclidean Algorithm [Basic and Extended]

The Euclidean algorithm provides a method for determining the greatest common divisor (GCD) of two positive integers. The GCD represents the largest integer that divides both numbers without leaving a remainder. Rather than relying on factorization, the Euclidean algorithm computes the GCD through a series of efficient mathematical operations. Basic Euclidean Algorithm for GCD The ...

Double Hashing

Double Hashing is a computer programming technique used in conjunction with open addressing in hash tables to resolve hash collisions, by using a secondary hash of the key as an offset when a collision occurs. Takeaways Introduction to Double Hashing Have you ever spoken with a bank customer care executive? For any complaint or query, ...

Heap Sort Algorithm

This article delves into the Heapsort Algorithm, a prominent and efficient sorting technique in computer programming. It operates by creating a min-heap or max-heap from the array’s elements, where the root signifies the minimum or maximum value. Heap sort involves two primary recursive operations: building a heap (H) using array elements and repetitively deleting the ...

Median and Order Statistics

The median is essentially the “halfway point” of the set of data. Order statistics are sample values placed in ascending order. The study of order statistics deals with the applications of these ordered values and their functions. Takeaways The distribution function for the Yi order statistic derived using the binomial distribution is Introduction to Median and Order Statistics On normal occasions, would ...

Quick Sort Algorithm

Quicksort is a prominent divide-and-conquer-based sorting algorithm renowned for its efficiency. Operating by selecting a pivot and partitioning the array around this pivot, Quicksort places the pivot in its correct sorted position. This technique achieves an average of nlogn comparisons for sorting n elements, making it notably swift. The algorithm’s essence lies in its divide-and-conquer approach: it breaks down ...

Floyd Warshall Algorithm

Floyd Warshall algorithm is used to find the shortest path between all vertices in the weighted graph. This algorithm works with both directed and undirected graphs but it does not work along with the graph with negative cycles. Takeaways Introduction of Floyd Warshall Algorithm If you’re looking for an algorithm for scenarios like finding the shortest ...

Binary Tree in Data Structure

A binary tree is a tree-type non-linear data structure with a maximum of two children for each parent. Every node in a binary tree has a left and right reference along with the data element. The node at the top of the hierarchy of a tree is called the root node. Takeaways A binary tree is the specialized version of the ...

Hashing in Data Structure

Hashing is a technique or process of mapping keys, values into the hash table by using a hash function. It is done for faster access to elements. The efficiency of mapping depends on the efficiency of the hash function used. Takeaways Introduction to Hashing in Data Structure Before going into Hashing in Data Structure let’s understand ...