Back to problems

Sort Colors in a RecordCollection In-Place

Algorithm · Snowflake · Medium

Problem: Rearrange Colors Directly in a RecordCollection A RecordCollection holds an internal sequence of color values. Colors use these integer codes: 0 represents Red 1 represents Green 2 represents Blue The RecordCollection exposes the methods below, so its underlying storage does not need to be written by you: Retrieves the color stored at position i. Exchanges the colors located at positions i and j. Write the following function, which arranges every color in the…

Checking your access…