Posts Tagged ‘array’

Bubble Sort

The Bubble Sort algorithm gets it’s name from the fact that on each pass, one element of the array ‘bubbles’ it’s way through to it’s correct (sorted) position in the array. Rather than me try and explain the details the following video gives a great visual demonstration of how the algorithm works. The source code…

Read More

Selection Sort

Java 19.6.2015 No Comments

When you are learning Java you are very likely going to be asked to write a program to sort values. We will start with one of the simpler sort algorithms, the Selection Sort (also known as an Exchange Sort). It’s not a particularly efficient algorithm and really only suitable for small lists.

Read More

Using a List instead of an array

Java 8.3.2012 2 Comments

Lists and arrays can both be used to store ordered collections of data. Both have their strengths and weakness which we shall discuss in a later post. Previously we showed you how to generate Pascals Triangle and in that Java example we used arrays to represent each row of the triangle. The following code shows…

Read More

Money Change Breakdown

Java 28.3.2011 9 Comments
Money Change Breakdown

What is the smallest number of coins (or notes) that are required to give a specified amount of change? This is the next problem we will address. To solve this problem we use basically the same process a shop keeper would when giving change to customers. That is we look for the largest denomination coin/note…

Read More
s2Member®