鈥 鈥渟plit 鈥 is the function which accepts the array 鈥鈥 and a value 鈥溾 as the input parameters.
鈥 Initially, the variable 鈥 count鈥 is assigned with the value.
鈥 The function has 2 鈥渇or 鈥 loops. In the first 鈥 for鈥 loop,
o Process all the elements in the array and brings the elements that are smaller than the value 2 鈥 鈥 to front of the array by swapping.
o Thus, the array is split into sub-array by moving all the smaller elements in the array to front.
鈥 It first checks if the value in the k鈥渢h鈥 element of the array is less than the value of 鈥 val鈥.
鈥 If it is true, it swaps the k鈥渢h鈥 element of the array 鈥 s鈥 with the position of the array element which has the value of count.
鈥 Then, the value of the 鈥渃ount鈥 is incremented.
鈥 In the second 鈥渇or鈥 loop,
o Find the position of the value 鈥 val鈥 and move it next to the sub-array by swapping.
鈥 It first checks if the value in the k鈥渢h鈥 element of the array is equal to the value of 鈥渧al 鈥.
鈥 If it is true, it swaps the k鈥渢h鈥 element of the array 鈥 s鈥 with the position of the array element which has the value of count.
鈥 Then, the value of the 鈥 count鈥 is incremented.
o Here, both the 鈥 for鈥 loops require constant time.
Therefore, it takes the running time of .