# Find Clockwise Array in Binary Search Tree

The binary search tree is a powerful data structure that helps us organize, store, and manage our data efficiently. The clockwise array refers to a way, or in more simple words, and is an ordered sequence of nodes gained by traversing the binary search tree clockwise starting from a given node.

Some advantages of traversing the tree in a clockwise manner are: -

1. They provide a consistent and casual way of visiting all the nodes in the tree.
2. Traversing the tree in a clockwise manner can simplify the implementation and reduce the complexity of the tree.
3. Traversing a tree clockwise can make us more aware and compatible with specific algorithms.
4. It can provide a clear sense of directionality while traversing the tree.

We are given an array with a size 'n', which comprises different numbers of sorted orders, and that too in increasing pattern, and the array has been rotated in the right and that too k number of times. So, our main task is to find out the value of K. In the section below, we have provided some code to solve the problem and find the value of k easily.

### Implementation

Output:

A step-by-step explanation of the code

1. The code begins by including all the necessary header files to carry out the program's various input and output operations.
2. We create a function called 'countRotation' comprising the following parameters: the 'arr' and the 'n'.
3. Inside the 'countRotation' function, the algorithm finds the minimum element in the array and its index.
4. Next, the function will return the index of the minimum element, representing the total number of rotations in the tree.
5. Now, we will observe the primary function as it is the program's entry point.
6. In the primary function, it subjects the array with specific values and sizes of the array.
7. In the end, we call the 'countRotation' function with the 'arr' and 'n' as an argument, and the returned value is printed as a result.
8. The program returns the 0-value indicating the successful execution of the program.

### Example 2)

Output:

A step-by-step explanation of the code

1. The code begins by importing the necessary Java packages and files.
2. We create a function called 'countRotation', which comprises the following parameters: the 'arr' and the 'n'.
3. Inside the 'countRotation' function, the algorithm finds the minimum element in the array and its index.
4. Next, the function will return the index of the minimum element, representing the total number of rotations in the tree.
5. Now, we will observe the primary function as it is the program's entry point.
6. In the main function, it subjects the array with certain values and sizes of the array.
7. In the end, we call the 'countRotation' function with the 'arr' and 'n' as an argument, and the returned value is printed as a result.
8. The program returns the 0-value indicating the successful execution of the program.

### Example 3)

Output:

A step-by-step explanation of the code

1. We create a function called 'countRotation', which comprises the following parameters: the 'arr' and the 'n'.
2. Inside the 'countRotation' function, the algorithm finds the minimum element in the array and its index.
3. Next, the function will return the index of the minimum element representing the total number of rotations in the tree.
4. Now, we will observe the primary function as it is the program's entry point.
5. In the primary function, it subjects the array with specific values and sizes of the array.
6. In the end, we call the 'countRotation' function with the 'arr' and 'n' as an argument, and the returned value is printed as a result.
7. The program returns the 0-value indicating the successful execution of the program.