TopcoderArchiveVisit Topcoder
Archive
Algorithm problem

BubbleSort

Problem statement, definition, constraints, and public examples.

Problem Statement

Below is a program that partially (and incorrectly) implements a Bubble Sort
algorithm. This algorithm will take an unsorted ArrayList of integers and
return the list sorted.
Your task is to debug this class so that when the init() method is called from
an external program, given an unsorted ArrayList, it will return the sorted
equivalent.
If you are not familiar with a java ArrayList, here are a few hints:
(1) ArrayList objects are used to hold other objects, indexable from 0.
(2) To insert Object obj into the end of an ArrayList, call add(obj)
(3) To access the element at index i, call get(i)
(4) To remove the element at index i (and shift all the rest accordingly), call
remove(i)
(5) To set the element at index i to Object obj, call set(i, obj)     

Definition

Class:
BubbleSort
Method:
init
Parameters:
ArrayList
Returns:
ArrayList
Method signature:
ArrayList init(ArrayList param0)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems