A quick and practical guide to merging two max heaps.
Baeldung Author
Said Sryheni
I am a backend JEE developer specialized in technologies like Spring and Hibernate with +3 years of experience. I have been an ICPC competitive programmer using C++ for +5 years.
Here's what I've written (so far):
Baeldung on Computer Science
- All
- Algorithms (32)
- Math and Logic (11)
- Searching (9)
- Path Finding (9)
- Graphs (8)
- Trees (7)
- Graph Traversal (7)
- Data Structures (5)
- Sorting (4)
- Programming (2)
- Networking (1)
- Core Concepts (1)
Finding the Shortest Cycle in an Undirected Graph
Filed under Graphs
A guide to finding the shortest cycle in an undirected graph.
Median of a Matrix With Sorted Rows
Filed under Algorithms
A quick and pratical guide to finding a median of a matrix with sorted rows.
Difference Between Tree Order and Degree
Filed under Data Structures, Trees
An explanation of the concepts of order and degree for trees.
Determining the Most Distant Pair of Points
Filed under Math and Logic
A guide to the problem of finding the distance between the farthest pair of points from a given set of points.
Finding the Minimum Number of Jumps to Reach the End of an Array
Filed under Searching
An overview of the problem of finding the minimum number of jumps to reach the end of a given array starting from the beginning.
Algorithm to Find All Subarrays With a Given Sum K
Filed under Algorithms
A quick and practical guide to the problem of finding the number of subarrays with a given sum K.
Finding the Number of Distinct Subsequences of a String
Filed under Searching
Understand the problem of finding distinct subsequences of a string and a few ways to approach it.
How To Find a List of Possible Words From a Letter Matrix
Filed under Algorithms, Searching
A quick and practical overview of the problem of finding the list of all possible words from a 2D letter matrix.
What Is the Best Sorting Algorithm To Sort an Array of Small Integers
Filed under Sorting
A quick and practical guide to sorting arrays of small integers.
How To Determine if a Point Is in a 2D Triangle
Filed under Algorithms
Learn three approaches to detect if a point lies inside a 2D triangle
Circle Line-Segment Collision Detection Algorithm
Filed under Algorithms, Math and Logic
A guide to detecting collisions between a circle and a line or line segment.
Hashing a Tree Structure
Filed under Trees
Learn how to build a hash function for a tree structure.
Count the Number of Set Bits in an Integer
Filed under Algorithms
Have a look at a few different approaches and algorithms for counting the number of set bits in an integer.
Finding the Number of Occurrences of a Subsequence in a String
Filed under Searching
Learn how to find the number of subsequences of a string
Searching in a Sorted and Rotated Array
Filed under Algorithms, Math and Logic
A quick overview of the most efficient way to find an integer in a sorted rotated array.
Finding the Only Unpaired Element in the Array
Filed under Algorithms, Searching
Understand the problem of finding the only unpaired element in an array, and a few approaches to solve it.
Finding Maximum Size Square in a Matrix Filled With Ones
Filed under Algorithms, Graphs
Learn how to find the maximum square size filled with ones in a matrix that contains only zeros and ones.
The Most Efficient Way to Implement an Integer Based Power Function
Filed under Algorithms, Math and Logic
Learn about different ways to implement an integer-based power function and compare their efficiency.
Finding the Next Smaller Element for Each Element in an Array
Filed under Algorithms, Math and Logic
Learn a few algorithms for finding the next smaller element for each element in an array.
Algorithms to Check If a Number Is a Power of 2
Filed under Algorithms, Math and Logic
Understand the problem of verifying if a number is a power of two, and a few ways to approach it.
Minimum Number of Steps to Reduce Number to One
Filed under Algorithms, Trees
A quick and practical overview of reducing a number to one using the minimum number of operations.
Negative Weights Using Dijkstra’s Algorithm
Filed under Path Finding
A quick and practical introduction to dealing with negative weights while using Dijkstra’s algorithm.
Pairing Socks From a Pile Efficiently
Filed under Algorithms, Math and Logic
A quick and practical overview of the sock pairing algorithm.
Finding the Shortest Path in a Graph Visiting All Nodes
Filed under Graph Traversal, Graphs, Path Finding
A quick and practical guide to finding the shortest path in a graph visiting all nodes.
Obtaining the Path in the Uniform Cost Search Algorithm
Filed under Graph Traversal, Graphs, Path Finding
A quick and practical overview of Uniform Cost Search pathfinding algorithm.
How to Merge Sort A Linked List
Filed under Data Structures
A quick and introduction to merge sorting a linked list.
Find Local Minimum in N x N Matrix
Filed under Algorithms, Math and Logic
Learn how to solve the problem of finding the local minimum in an N x N matrix
Flood Fill Algorithm
Filed under Algorithms
A quick and practical overview of the Flood Fill algorithm.
Number of Shortest Paths in a Graph
Filed under Path Finding
A quick and practical guide to finding the number of shortest paths in a graph.
Counting Inversions in an Array
Filed under Algorithms
Understand what an inversion is and look into ways of solving the problem of counting inversions in an array.
Finding a Cycle in a Singly Linked-List
Filed under Algorithms, Path Finding
Have a look at algorithms for finding a cycle in a singly linked-list.
Finding the Most Significant Bit
Filed under Algorithms, Core Concepts
A quick and practical guide to finding the most significant bit.
Non-Recursive Merge Sort
Filed under Sorting
A quick and practical overview of the non-recursive merge sort algorithm.
Introduction to Depth First Search Algorithm (DFS)
Filed under Algorithms, Graph Traversal
A quick and practical overview of the DFS algorithm.
Merge Two Sorted Arrays Into a Sorted Array
Filed under Sorting
A quick and practical guide to merging two sorted arrays into a single sorted array.
Efficient Ways to Find the Intersection of Lists
Filed under Algorithms, Data Structures
A quick and practical guide to finding the intersection of linked lists.
Remove Duplicates From a Linked List
Filed under Algorithms, Programming
A quick and practical tutorial to removing duplicates from a linked list.
Maximizing Profit for Given Stock Quotes
Filed under Math and Logic
A quick and practical guide to maximizing profit for given stock quotes.
Getting a Path From a Root to a Node in a Binary Tree
Filed under Path Finding
A quick and practical guide to getting a path from a root to a node in a binary tree.
Palindromic Substrings in O(n) with Manacher’s Algorithm
Filed under Searching
A quick and practical overview of Manacher’s algorithm.
Finding All Overlapping Intervals
Filed under Algorithms
A quick and practical guide to detecting overlapping intervals.
Maximum Single-Sell Profit
Filed under Math and Logic
A quick and practical tutorial to finding the Maximum single-sell profit in an array.
Find All Simple Paths Between Two Vertices in a Graph
Filed under Path Finding
A quick and practical tutorial to finding all simple paths between vertices in graphs.
Determine Whether Two Nodes in a Graph Are Connected
Filed under Algorithms, Graphs
A quick and practical tutorial to determining if two nodes are connected or not.
Choosing the Subarray That Adds Up to a Target Number
Filed under Algorithms
A quick and practical guide to choosing the subarray that adds up to a target number.
Finding the Kth Smallest Element in the Union of Two Sorted Arrays
A quick and practical overview of finding the kth smallest element in the union of two sorted arrays.
Find the Subset of Numbers That Add Closest to Target Number
Filed under Algorithms
A quick and practical tutorial to finding the subset of numbers that add up the closest to a target number without exceeding it
Create Balanced Binary Search Tree From Sorted List
Filed under Algorithms, Trees
A quick and practical guide to creating balanced BST from a sorted list.
Overview of Rabin-Karp Algorithm
Filed under Searching
A quick and practical overview of Rabin-Karp Algorithm.
Finding XOR of All Numbers in a Given Range
Filed under Math and Logic
A quick and practical guide to finding XOR of all numbers in a given range.
Implementing the Decrease-Key Operation for Min-Heaps
Filed under Algorithms, Data Structures
A quick and practical overview of Decrease-Key operations for Min-Heaps.
Lowest Common Ancestor of Two Nodes in a Tree
Filed under Data Structures, Trees
A quick and practical guide to finding the lowest common ancestor of two nodes in trees.
Dijkstra’s vs Bellman-Ford Algorithm
Filed under Path Finding
A quick and practical comparison of Dijkstra’s and Bellman-Ford algorithms.
Sliding Window Algorithm
Filed under Networking
A quick and practical overview of the Sliding Window algorithm.
Kruskal’s vs Prim’s Algorithm
Filed under Graph Traversal, Trees
A quick and practical overview of Kruskal’s and Prim’s algorithms.
Shortest Path to Certain Nodes in a Graph
Filed under Graph Traversal, Graphs
A quick and practical guide to finding the shortest path that visits certain nodes in a weighted graph.
Determining Whether a Directed or Undirected Graph Is a Tree
Filed under Algorithms, Graphs, Trees
A quick and practical guide to determining if a graph is a tree.
Linear Search vs Binary Search
Filed under Searching
A quick and practical overview of differences between linear and binary search.
Finding the Maximum-Minimum Capacity For a Node in a Graph
Filed under Algorithms, Graphs
A quick and practical guide to finding the Maximum-Minimum capacity for a node in a graph.
Longest Palindromic Subsequence With Dynamic Programming
Filed under Algorithms, Programming
A quick and practical explanation of the longest palindromic subsequence problem.
Knuth-Morris-Pratt Algorithm
Filed under Graph Traversal
Learn about the Knuth-Morris-Pratt algorithm that searches for occurrences of a word inside a large text
Difference Between BFS and Dijkstra’s Algorithms
Filed under Graph Traversal, Path Finding
Learn how BFS and Dijkstra’s algorithms work to find the shortest path from one node to all other nodes in a graph.