
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A computer science homework assignment focused on developing a sorting algorithm. Students are required to create an algorithm, either textual or java code, that takes an array of integers as input and returns an array of integers with the same elements but in ascending order. The assignment includes examples and instructions for submission and presentation.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Homework 2, due Jun 29th, before class
Since this homework is more complex than the previous one, it will be worth 10 points!
Sorting is a very important problem in Computer Science. It can be defined as:
Input: List of elements (ei) that can be compared, e.g. ints Output: List of elements (fj ) such that:
We will use arrays of ints to model the list of elements: int[] e;
The elements can be easily compared by using the well-known operators: e[i]<e[j]
Your task is to develop an algorithm (either textual or Java code), that takes as input an array of ints and returns as output an array of ints that contains the same elements, but in ascending order. You may assume that the elements are pairwise unequal, that is, an element does not appear twice in the input.
Examples:
As seen in the example, your algorithm has to work on arbitrary-length arrays (though you should start on a short, constant array length, e.g., 4).
Before class on the due date, hand in your algorithm (either in text or as source code; working source code may give extra credit) as well as some text explaining your algorithm (e.g., how and why it works). All in all, one page should be fine. If you do use resources and not only your brain, list them.
Furthermore, you need to be prepared to present your algorithm to the class in about 5- minutes. I have scheduled two to four presentations for class. Voluntary presentation will be awarded with extra credit, while bad performance will reflect negatively on your homework score.