Write a method called partition that accepts a list of integers and an integer value E as

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 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.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Building Java Programs A Back To Basics Approach

ISBN: 9780135471944

5th Edition

Authors: Stuart Reges, Marty Stepp

Question Posted: