Balanced min heap and balanced max heap (toggling logic)