Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a code in Java. Implement the recursive k-th smallestfunction. Your progra

ID: 3612696 • Letter: W

Question

Write a code in Java. Implement the recursive k-th smallestfunction. Your program will prompt the user with message"integer:", then read an integer. Repeat this 10 times, and put thenumbers in an array of size 10. Then print "k:" and read the valueof k. Finally print the k-th smallest of the 10 numbers. If k=0,print the smallest of all. . Do the partition as follows. Declare aglobal array "scratch" of size 10. Write a function intpartition(int A[], int f, int l), which partitions the segmentA[f]...A[l] and returns the pivot index. Use A[f] as the pivot.Copy numbers smaller than the pivot to the scratch array, startingat scratch[f]. Then copy the pivot, then copy numbers greater thanthe pivot. Finally copy the numbers from scratch[f] to scratch[l]back to A[f] to A[l], and return the position of the pivot. Write a code in Java. Implement the recursive k-th smallestfunction. Your program will prompt the user with message"integer:", then read an integer. Repeat this 10 times, and put thenumbers in an array of size 10. Then print "k:" and read the valueof k. Finally print the k-th smallest of the 10 numbers. If k=0,print the smallest of all. . Do the partition as follows. Declare aglobal array "scratch" of size 10. Write a function intpartition(int A[], int f, int l), which partitions the segmentA[f]...A[l] and returns the pivot index. Use A[f] as the pivot.Copy numbers smaller than the pivot to the scratch array, startingat scratch[f]. Then copy the pivot, then copy numbers greater thanthe pivot. Finally copy the numbers from scratch[f] to scratch[l]back to A[f] to A[l], and return the position of the pivot.

Explanation / Answer

Assume A is an array, first is initially 0, last is initiallyn-1 pivotIndex is the location where the pivot has beeninserted after performing partition, p is the pivot value

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote