The blog has now moved!

Tuesday, March 06, 2007

Recursion

I got up, and for the rest of the day alternated between work and Warcraft 3. I have two lots of Java Corusework, some of it is due in two weeks. I've done almost all of it. Seeing as I've got two things to talk about and you'll not be interested in Warcraft 3 strategies, I'll explain my Java project minus geeky terminology (well, I'll try not to use geek-speak). I have to make a Linked List Editor. Well, you already know half of what I have to do. When you make a shopping list, you have a list of items. There, that's halfway and I even talked about something non-geeky, aren't you amazed? Okay, the Linked part isn't quite so easy, or is it? To use our shopping list, lets say we have the following. Tuna Fish Mayonnaise Bread Milk Tea Bags Sugar Right, we'll use that as our list. Lets suppose that we know how Tescos (or ASDA or Sainsburys as the case may be) is laid out. We know that it's fastest to perform that shopping in a certain order, we could number each item in our list and say what comes after what. Something like this? 1) Tuna Fish -> 3 2) Mayonnaise -> 5 3) Bread -> 4 4) Milk -> 2 5) Tea Bags -> 6 6) Sugar -> End of List Now our list tells us what to get and what order we want to get it in, we have just created a linked list. Yes, in the form of Food Shopping I've explained what is otherwise known as a "Data Construct". Maybe I should teach computer science to non-geeks or something, maybe I should have a fan club, we'll never know because I'm about to explain the tougher part of my assignment. To make this list, I have some tools at my disposal. I can make my own tools too, so I've made a tool that is a "List Object". Each List Object has a value (such as Tuna Fish) and also a Next/Linked Item (where next we're going to go). Here's the REALLY clever part. Rather than have lots of them and make a list as you would assume, I've made one. Each item contains another item, which contains another item which contains another and so on and so forth until one of them contains a special Empty item (in our case it's the checkout where you hand over some money). Tell you what, I'll draw a diagram. List Object - Value - Next Object     - Value     - Next Object         - Value         - Next Object             - Value             - Next Object                 - Value                 - End of List Object Okay, so how is this in any way useful? Well, I'm not 100% sure of the practical purposes but it's a new way of thinking and apparently allows you to prove your code works. I just think it's a really geeky way of doing things and makes it really hard for other people to understand it. However, I've recently had a chat with a University professor called Barry. He's quite cool and told me that when I learn how to do things recursively I will begin to find it easier. Hence why I am making an effort to use it. And apparently we're not allowed to use something called an Array to do it (geek-speak for List). See, by reading my blog you learnt some Computer stuff as explained through the medium of a shopping list! Incidentally, you've probably noticed that the blog now has a new look, do you prefer or dislike this new look? I chose it because it actually makes use of my entire screen rather than a narrow column of it. A large amount of credit should go to my Mum for actually teaching me how to shop, find the shortest and fastest queue and generally teaching me how to live.

2 comments:

Lauren Heffer said...

You forgot to mention the car crash!! The most exciting part of our day!! Lol.

Teifion said...

Oh yeah, there was a car crash but nothing actually happened that was very interesting, we didn't see it happen, we just saw that a car had pulled out on the other one and it was funny that the chavs (who were in the wrong) were all agitated.