Advertisement

Do I need to know Algorithms and Data Structures?

Started by June 03, 2016 02:31 PM
14 comments, last by Keinier 8 years, 6 months ago

>> Data structures and algorithms are the bread and butter of computer software.

this can not be overstated.

Data structures and algorithms are the bread and butter of computer software.

Data structures and algorithms are the bread and butter of computer software.

Data structures and algorithms are the bread and butter of computer software.

Data structures and algorithms are the bread and butter of computer software.

Data structures and algorithms are the bread and butter of computer software.

the more data structures and algo's you're familiar with, the bigger your "bag of tricks" to handle any programming task you encounter.

platforms, OS's, languages, libraries, engines, etc come and go. data structures and algorithms are eternal.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

In C# or Java you're never going to write double linked generic dynamic lists. You just won't.

Don't say that too fast.

I once ran into the problem that I had a few 100,000 short lists, with around 1,000,000 elements in them in total. More elements would be highly desirable. If you look at what Java lists do, you realize they add an object for each list (so 100,000 additional objects), and an object[1] for each element in a list (hello another 1,000,000 objects).

Normally not much of a problem, but my elements were really small, so the additional objects would have equal size or be even larger, doubling the memory requirements. Clearly an unacceptable solution (derived thanks to my understanding of Java list). Luckily I knew how to make a double linked list in C. That got rid of all the cruft, doubling the number of elements I could store before hitting the JVM memory ceiling.

While my example was perhaps a bit extreme, it generally is very useful to know and understand how the standard things like dictionary, set, list, etc work, and what happens with performance if you add a lot of data in them (the big-O complexity notation).

In addition, data structures and algorithms is a large collection of solidly engineered smart tricks. Studying them makes that you see and understand a lot of those tricks. That makes you a better programmer. when you run into a unknown problem, you may find it looks like an algorithm you saw before, you'll remember its trick, and perhaps that will work in your new problem too? That expands your bag of tricks significantly.


[1] I needed fast arbitrary removal, so ArrayList was not feasible.
Advertisement

Honestly, for the most part, there are some things you can leave to pre-canned code. There are instances where you need to truly understand things, but not always. If I'm searching for a key/value pair in a dictionary, I don't need to understand exactly how that dictionary is coded. But, I DO need to understand why use a dictionary instead of a linked list, or standard array, or whatever option is available in the language. I need to understand how to use Vectors for some things, but I don't necessarily need to know the actual math behind calculating the things. If I need quaternions for something, I can just use a library that implements them. In Unity, I can just call a rotate function on a transform, and I don't have to understand how the underlying quaternion works.

Of course, I agree that more knowledge is better at times. But many times it isn't necessary, and in fact can slow somebody down if all they want to do is make a game. This of course boils back to the whole "make games, not engines" shtick.



[1] I needed fast arbitrary removal, so ArrayList was not feasible.


Did you need them to be sorted? If you didn't, you could have used the swap and pop idiom, which is O(1).

[1] I needed fast arbitrary removal, so ArrayList was not feasible.


Did you need them to be sorted? If you didn't, you could have used the swap and pop idiom, which is O(1).

I know that trick, but you'd still need a vector object for the list itself.

The real situation is more tricky than I wanted to explain in the post. Basically you have a parent with a list-like thing with children, and you must go from parent to child as well as from child to parent quickly. (and with a child having exactly two parents, this makes you can 'jump' from parent to parent).

You need the child to decide whether it's the right one for jumping (if not pick the next child). A vectorlist makes that you need 2 dereferences for getting that information. By merging the list and the child, you can do it in 1 dereference, and you can drop the list object thingie.

A game is a complex software, you will need to build a image from your scene, this scene is an abstract structure like tree that represents any object in it. All transaction in the game must be in real-time, you don't need to know all structures or algorithms but yo need know that it exists, and you should can research about it.

Game maker

This topic is closed to new replies.

Advertisement