Fun in sorting…a QuickSort example

Over the Christmas break I had plans to create a number of Java class for a variety of sorting algorithms. Part of this was to remind me of my early days in learning to code but also to eventually build a sorting demonstration tool such as this Android app I found recently called Sorts. Fortunately there were far better things to do over the break then program, as such it was not until recently that I had a chance to start on this task.

My desire was to create a class for each algorithm with the needed functions. The main function in this class should allow for any object that implements comparable so that these sorting algorithms are as universal as possible (a slight modification from my early days). However this was an area of working with Java that I have not had much practise in (that being to make use of generic in Java). As such after various articles found via Google I was able to come up with the following implementation of a simple QuickSort (I still need to figure out how to add some form of a demo layer).

package org.oavatos.sorting.algorithims;

import java.util.ArrayList;
import java.util.Arrays;

public class QuickSort<E extends Comparable<E>> {

	public ArrayList<E> simple(ArrayList<E> data) {
		if (data.size() <= 1) {
			return data;
		}

		ArrayList<E> alLess = new ArrayList<E>();
		ArrayList<E> alMore = new ArrayList<E>();
		ArrayList<E> alAll = new ArrayList<E>();

		E pivot = data.remove(data.size() / 2);

		for (int i = 0; i < data.size(); i++) {
			if (data.get(i).compareTo(pivot) <= 0) {
				alLess.add(data.get(i));
			} else {
				alMore.add(data.get(i));
			}
		}

		// Put the arraylist back together
		alAll.addAll(simple(alLess));
		alAll.add(pivot);
		alAll.addAll(simple(alMore));

		return alAll;
	}

	public static void main(String[] args) {

		Long[] myInts = { 11l, 6l, 3l, 8l, 9l, -1l, 23l, 8l, 0l, -2l };

		/**
		 * Simple quick sort
		 */
		System.out.println("QuickSort: Simple");
		ArrayList<Long> alData = new ArrayList<Long>();
		alData.addAll(Arrays.asList(myInts));
	}
}
Posted in Programming | Tagged , | Leave a comment

A year in pictures (aka Hello Picasa)

When my son was born 7 years ago we would take a lot of photos. At that time Google Picasa was new and I was leery of storing my photos on a remote server. As such I had installed Gallery to manage our photo collection. You can see the albums we have put up by going to gallery3. This year when I arrived at my in-laws I realised that I had not taken any of the photos off of either of our cameras since last Christmas vacation. I was not looking forward to having to upload them all again and label them as I had done in the past.

Now over the last year (since I purchased a smart phone (Android)) I have been uploading more photos to on-line photo sharing sites then I had ever thought of doing. As such I thought I would look into Google Picasa again. I had used it last Christmas to quickly sort our pictures into those of my son and those of my daughter then I uploaded them all to my home server. This time however I tagged the photos and had Picasa place them into folders named as year-month and then uploaded them all into the Google cloud. This has made dealing wit a years worth of photos between two cameras (have to dealt with the cell phones yet) very easy. I currently get 20G from google so will likely need to pull off old photos when I near that limit (at this point with Gallery we have 32G! of photos not including the resizes and thumbnails after 7 years).

2011-01
2011-02
2011-03
2011-04
2011-05
2011-06
Ottawa (2011)
2011-07
Wisconsin Dells (2011)
2011-08
2011-09
2011-10
2011-11
2011-12
Posted in personal | Tagged , , , | 2 Comments

OS X Tips: Enable “path view” in Finder

A number of months back I switched from Linux (Gentoo) to a Mac at work. Over the months I have been slowly tweaking settings to make it work the way I like my environment to be. I however should have been making notes on what I have changed/found. I will now start trying to do this.

The below is taken from Terminal Tips: Enable “path view” in Finder
To make directory paths visible atop Finder windows, open Terminal.app (/Applications/Utilities/) and type the following command:

defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES

You then will need to restart the Finder.

Posted in system, tips | Tagged , | Comments Off

An alternative to Sungard’s Rhomobile MAPP Springboard Part 2

I was lacking any form of a demo (other then the attached apk) in my last post to show what we were experiencing and why I have opted to see if I could develop an alternative. So here are two videos to show what we are currently releasing and what I am working on. These videos were taken from a CDMA HTC Hero were I had installed a VNC server which I then connected to the VNC server from my Mac and captured the video using Capture ME.

Rhodes based application

So as you watch the above video what you may notice is that after launching the application you will need to wait roughly 30 seconds for the springboard to appear. Now I know the HTC Hero is an older device and therefore is slow by nature, but hold those comments until you view the second video.

Native Android based application

In watching this video you will notice that from launching the application to having the springboard appear you are waiting about 10 seconds. So going native has reduced our launch time by two thirds. Now don’t get me wrong Rhodes is still an impressive means to release a mobile application for multiple platforms without requiring one to learn the native language of that device. It is possible that there may be some setting we have missed that may cause the display to render much quicker…though to be truthful we have checked with others and seem to be on par with their implementations of using the Sungard springboard.

I also received some feedback in regards to my previous post:

seems a bit silly. If you have any actual business logic Rhodes is much faster than an Android Java app

In reading over my previous post again I realise I was not very clear in what my plan after the springboard is. Now this is mainly because for now I am just focusing on the springboard. However here is what I am currently thinking (though that may change when I get closer).

Most of the content in our current mobile application can either be served as static HTML pages, or are web services. So in the case of a simple HTML application there is no business logic the “micro-application” would need to take care of other then to report any issues of not being able to fetch the HTML. For any of the web service widgets the idea would be to have the web service take care of the bulk of the business logic and report back to the widget in such a way that the widget could render any error conditions to the user.

Of course this would not cover some of the other areas of the business logic, such as any interaction a widget may need to act on (i.e. after doing a directory search adding the contact to your address book). I am still thinking about that part of the equation, but am not focusing on that until I finish the springboard component. It will also be on a app by app basis. My preference would be to try and distil our content down to a handful of application types but realise we may not always be able to do that.

Posted in Programming | Tagged , , | Comments Off