Question: Write a method called partition that accepts a list of integers and an integer value E as its parameter, and rearranges (partitions) the list so
Write a method called partition that accepts a list of integers and an integer value E as its parameter, and rearranges (partitions) the list so that all the elements with values less than E occur before all elements with values greater than E. The exact order of the elements is unimportant, so long as all elements less than E appear before all elements greater than E. For example, for the linked list [15, 1, 6, 12, –3, 4, 8, 21, 2, 30, –1, 9] , one acceptable ordering of the list after a call of partition(list, 5) would be [–1, 1, 2, 4, –3, 12, 8, 21, 6, 30, 15, 9] . You may assume that the list contains no duplicates and does not contain the element value E.
Step by Step Solution
3.41 Rating (151 Votes )
There are 3 Steps involved in it
public static void partition List list int value partition origina... View full answer
Get step-by-step solutions from verified subject matter experts
