Understanding the comparator pattern


A heap data structure can store primitive data types in their natural order defined by the < and > operators. However, there are some problems that require ordering user-defined datatypes. In most cases, we first need to define the new datatype and then define a comparator to be able to store this datatype in a heap.

The comparator pattern is a classification of problems that can be solved using a heap and a custom comparator

In this lesson, we will learn more about using the custom comparator technique to solve problems and how to identify a problem as a comparator pattern problem.

Liking the course? Check our discounted plans to continue learning.