CSES - Order of addition

Implement a test using the class TreeSet of the preceding task, where the elements 1 \dots n are added to the set. The test has two parts, both with n=1000.

In the first test, the elements are added in the order of their value, and in the second test, they are added in random order. In both tests, measure the height of the tree after the additions.

In this task, you get a point automatically, when you report the results and supply the code you used, and press the submit button.

Height in test 1:

Height in test 2:

The code you used:

How do you explain the difference in the tests?