Java Fun
It has been a while since I have had the chance to work on some personal projects I've been wanting to work on.
The first is reinvestigating B Trees. We learned about these the fall of my sophomore year, but did not have to implement them if we chose to do the much easier AVL Trees. I chose to spend my time making the specific form of B trees called the B+ Tree. The wikipedia article that is linked is not very good, and at the end of my investigation I plan to revamp it completely. This data structure is very interesting to me, especially because I must understand it in order to create an R tree (a descendent of the B tree that manages n-dimensional spatial information), which is crucial to the research I must complete this summer. Not only must I make an R tree, but I must optimize it to my specific problem. All this could not occur if I did not have a thorough understanding of B trees, which cannot come by any other way than implementing it.
That is my honest opinion about most subjects of computer science. You can listen to lectures, and you can study a book over and over, but you cannot fully understand all of the computation needed until you have rigorously translated the algorithms into a computational language, whatever your choice may be. In this case, I'm using Java 1.5 (5.0 to those who can't count). I have taken a liking to their adaptation of C++ Templates, dubbed "Generics." This allows me to make a general class that can be reconfigured at compile time of another application to only accept a certain object type and automatically output that type without previously necessary casting. That's a very nice idea, and C++ failed at it's use. Templates were a disaster to work with and Generics fix this mostly. So far I would really like a way to do multiple generic types, type inheritance (I want my generic on any Type that implements Comparable, for instance. That way I know that all compareTo methods would work properly regardless of type), and proper array specification. When you make an array of generic objects, there are two ways to do it that will both compile, but both give errors:
GenericClass<Type>[] array1 = new GenericClass<Type>[size];
GenericClass<Type>[] array2 = new GenericClass[size];
If only one of these would work completely instead of giving me meaningless warning messages or requiring me to cast (which is what generics are supposed to avoid).
Then I have my other project: Sudoku. I've longed to get into this type of puzzle, due to it's naturally solvable nature. However, I have trouble making decisions because I like to follow strict algorithms for solving puzzles and this is an NP problem. I say NP because there is no polynomial-time algorithm to find a solution from scratch of any given problem, even though a possible solution can be checked in polynomial time.
This is the basic principle of Non-deterministic Polynomial time classification. NP problems are either a pain to implement or a pain to execute, but usually both. I've gone ahead and designed a Sudoku app that allows for input of values and updates the possible values of each square. However, I have yet to begin the solution algorithm. The previously linked wikipedia article has a great description of the alglorithm, which I will probably mimic. Right now, I'm stealing UI ideas from Alias Sketchbook Pro as seen in the image. When clicking on a space, you see a number wheel of possible numbers to place. This is a useful feature to never place an illegal value and even help with solutions by knowing this information. I'm also working on a way to see the possible numbers on every spot at all times. This is a good strategy for developing solutions manually. However, my real goal is to finish the algorithm, but an application to help solve tough puzzles is always nice.
2 Comments:
I had that same kind of problem when I started using generics in Java, I can't remember what I was doing wrong though.
In any event, you shouldn't have to cast. Every once in a while I would get a warning when I went from something that was type-abstract to something generic. It never gave me problems though.
Oh, it will compile and run fine both ways. I just don't like getting warning messages in my code if I can avoid them.
Post a Comment
<< Home