Slashdot Mirror


Advanced Data Structures?

mdf356 asks: "It's been 5 years since I left graduate school and started designing and writing software for a living. After 5 years of writing operating systems code, I feel like I've forgotten some of the more advanced data structures I used to know. The next time an interesting problem arises, I'd like to have more in my toolbox than hashes, linked lists, heaps and various binary and n-way trees. I'd like something short and sweet, more in the line of the standard C book. Algorithm Design by Kleinberg and Tardos looks likely to be too basic, but I haven't read it (I'd like to avoid paying $90 for something that won't meet my needs). CLR is far too large and almost exclusively covers basic territory. Tarjan's Data Structures book looks like it has potential, but seems focused on network algorithms, which are unlikely to be applicable to the kernel programming I do. What are some good reference books on more advanced data structures and algorithms, particularly ones with potential applicability to an operating systems kernel?"

118 comments

  1. Canonical Terms of Academia by eldavojohn · · Score: 4, Insightful
    Tarjan's Data Structures book looks like it has potential, but seems focused on network algorithms, which are unlikely to be applicable to the kernel programming I do.
    You'd be surprised. Some of the very basic network algorithms are kind of universal. Because, let's face it, some operating systems revolve around message passing.

    CLR is far too large and almost exclusively covers basic territory.
    Well, let's be fair, when you get to advanced data structures, it's kind of up to you to really do all the imagining that makes them great. Don't dismiss CLR too quickly, as the book has a lot of great concepts that, if you're serious about algorithms and data structures, are quite useful as a starting toolbox.

    Honestly though, when I went through college, the very last thing they tried to shove down my throat wasn't advanced data structures but instead Design Patterns. I'm not talking about algorithm design but instead just designs in general. This book might not do it in C but the ideas are pretty language independent. It's your 'cookbook' of designs laid out in class diagrams and sometimes more documentation is provided. Anyways, what I would actually suggest is that you combine a book that covers C structures with book and what you would have is a way for you to make a set of complex classes that emulate a proxy. Or you have an adapter class that is a "advanced data structure." I guess what I'm trying to say is that I don't see the point of paying attention to advanced data structures when it's really the way these data structures interact that is complex and important.

    The big problem is that, in order to make design patterns work for you, you have to go through a lot of documentation and diagrams. Take this for example, you're writing an OS code and there's a part of the operating system that's going to be changing frequently depending on processor (I don't know a lot about OS development), let's say the scheduler. So what do you do? Do you just willy-nilly throw the scheduler and start going? Well, what would be best is that if you encapsulated the scheduler inside a package or library so that it could easily be exchanged for another one. You try to keep it small and modularize the classes and data structures that change from those that don't. Then, a new processor comes out that might demand a new scheduler and you open up this mini-project, edit/debug it and roll it out as something that just replaces the classes and libraries on all your deployed versions. Sounds like common sense, right? Well, for some it is and for some it isn't but to me this interaction is a complication of data structures and I think that the answer you're looking for isn't necessarily a book called "advanced data structures" just a few that explain how they work.
    --
    My work here is dung.
    1. Re:Canonical Terms of Academia by tedgyz · · Score: 2, Interesting
      Well, let's be fair, when you get to advanced data structures, it's kind of up to you to really do all the imagining that makes them great. Don't dismiss CLR too quickly, as the book has a lot of great concepts that, if you're serious about algorithms and data structures, are quite useful as a starting toolbox.
      Good point. While it doesn't cover everything, it is hardly an "Introduction". I've been programming for 20 years (including kernels). This book fits the 80/20 rule - covering 80% of what I've needed. The "Trie" structure is one omission that comes to mind.
      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    2. Re:Canonical Terms of Academia by s31523 · · Score: 1

      Honestly though, when I went through college, the very last thing they tried to shove down my throat wasn't advanced data structures but instead Design Patterns.

      I didn't get this too much in college, and got a little in grad school, but I went on to some self discovery afterwards and I gotta tell ya, Design Patterns are a must when it comes to doing OO design. Design patterns can be used in any structured design method as well, it just takes some creativity... I use this online link, which is really cool (it even has code, CODE!)

      As far as data structures go, I haven't found a good "quick reference".

      Algorithms, by Robert Sedgewick is pretty good. It has many of the best methods for solving a ton of problems. It isn't a quick reference, but I am not sure there would be such a thing, but at least this book is focused.

    3. Re:Canonical Terms of Academia by Profound · · Score: 4, Insightful

      >> This book might not do it in C but the ideas are pretty language independent.

      Design patterns is a book about Object Oriented design, aimed at the C++/Java level of abstraction. In low level languages it is clumbsy to write them, and in higher ones, unnecessary.

    4. Re:Canonical Terms of Academia by nulix · · Score: 1
      Honestly though, when I went through college, the very last thing they tried to shove down my throat wasn't advanced data structures but instead Design Patterns
      Design Patterns might not be what he's looking for. Design Patterns (in my experience) tend to map well to OO concepts and/or are described in OO concepts, kernel programming, however, does not fit well with the OO concept. I think he might be better of sticking to advanced data structures and algorithms rather than patterns if he wants to apply it to kernel programming.
    5. Re:Canonical Terms of Academia by Anonymous Coward · · Score: 0

      Introduction to Algorithms, Second Edition
      Thomas H. Cormen
      Charles E. Leiserson
      Ronald L. Rivest
      Clifford Stein
      The MIT Press
      Cambridge , Massachusetts London, England
      McGraw-Hill Book Company
      Boston Burr Ridge , IL Dubuque , IA Madison , WI New York San Francisco St. Louis
      Montréal Toronto

    6. Re:Canonical Terms of Academia by bill_kress · · Score: 1
      ...and in higher ones, unnecessary.


      What an interesting statement.

      Seriously? No design patterns are useful in "higher level" languages?

      Could you please elaborate?
    7. Re:Canonical Terms of Academia by korpique · · Score: 1

      Say iterators. In Perl (and Python IIRC) they're implemented by the virtual machine long as your data structure provides methods. The pattern's there but pretty mutilated by the fact that it's use is forced by the machine that runs your code. Delegates are useless if you have dynamic multiple inheritance like in Lingo; I think Perl at least used to have that too with mutilating @ISA array. Likewise in Javascript etc, although lacking classes you'd have to map each method separately, ugly, but delegatable to common initializers. Umm, ok, bad example, I'll stop here :)

      --
      I was the real korpiq until I woke up clowned.
    8. Re:Canonical Terms of Academia by jgrahn · · Score: 1
      Design patterns is a book about Object Oriented design, aimed at the C++/Java level of abstraction.

      Well, it's about generalization, loose coupling and that kind of stuff. Lots of polymorphism. Orthogonal to algorithm work, and not always something you want to invest programming time and CPU cycles info.

    9. Re:Canonical Terms of Academia by Profound · · Score: 1

      For a good overview of this, see http://www.norvig.com/design-patterns/

      16 of 23 patterns have a qualitatively simpler implementation in Lisp

      -Visitor is unnecessary in Multi-dispatch polymorphism (as mentioned in the book it is a hand written implementation)
      -To be cheeky singleton is unnecessary when you have globals :)

    10. Re:Canonical Terms of Academia by bill_kress · · Score: 1

      Okay, so because 3 patterns are somewhat implemented by the system, how is it not useful to know the names for those and the other dozens?

      Design patterns are almost all obvious to a decent programmer--you probably invented them before you ever heard of them. Knowing design patterns means that you and I can discuss Iterators without redefining what they mean each time we talk to someone new.

      How is that need replaced by these new languages?

      Also, you say the need for "Design Patterns" is eliminated??? Every single one (is what that statement implies). How would you say the "immutable" pattern is no longer necessary? Simply to say that it's impossible to implement on a "New" language doesn't cut it.

      How about the Observer pattern? You don't need that any more?

      On top of that the biggest thing you learn from design patterns is bad code smells, and trust me you can write smelly code in ANY language.

      I really wonder what your original attempt was? Either to dismiss java/c++ or design patterns or to hype "next gen" languages. Regardless I don't think you understand what design patterns do if you think they are deprecated by "new languages"

    11. Re:Canonical Terms of Academia by bill_kress · · Score: 2, Insightful

      So to say a pattern has a simpler implementation in another language means that you don't need to know it, understand it, understand when to use it and how?

      The patterns aren't about how to implement something--they are all trivial to implement, I've yet to see one that I didn't create and implement myself before the books were even concieved of.

      The big things about design patterns are that you have a common name for a pattern and some code smells to look for that indicate the need for a pattern. Because you have "Multi-dispatch polymorphism" available, did you use it? Did you know what smells indicated you should use it? Can you quickly communicate what it does without using the word "Visitor"? You using it in that paragraph communicated to me just what you were talking about, so you needed and used design patterns right there.

    12. Re:Canonical Terms of Academia by try_anything · · Score: 1

      It all depends on what you mean by design patterns. Sometimes people describe design patterns as recurring patterns in programs. However, judging by the design patterns they catalogue, what they mean in practice is recurring patterns in source code. Aspects of program structure that do not have to be laboriously and repetitively specified do not qualify as design patterns. "Named memory cell that contains a value" is not a design pattern, despite its ubiquity, because most languages allow it to be expressed quite efficiently.

      So, design patterns are patterns that recur in code because they describe a recurring structure that cannot be efficiently expressed in the language. Every language provides abstractions to allow programmers to factor out redundancy, but no language is perfect, so design patterns emerge as coders are forced to recode the same structures over and over again.

      Naturally, since different languages support different abstractions, they result in different sets of design patterns. A person coming from a functional language to Java will see many of Java's design patterns as workarounds for Java's lack of support for functional programming. Similarly, a programmer moving from Java to C will notice C design patterns that are essentially workarounds for the lack of OO support in C. "Struct member pointing to table of operations for operating on that struct" would be a C design pattern for supporting polymorphism.

      Unfortunately, design patterns books don't give much consideration to the difference between how to design a program's structure and how to express that structure in a particular language.

    13. Re:Canonical Terms of Academia by Nicolay77 · · Score: 1

      I totally agree with you.

      The things commonly known as "Design Patterns" are really just several implementations of one of the two real patterns: The Human Compiler at Work. You have to do that stuff by hand because your language is not powerful enough.

      The other real pattern, is macros (as in lisp macros). That is, extend your language to do that stuff for you.

      --
      We are Turing O-Machines. The Oracle is out there.
  2. data structures books by Binder · · Score: 4, Informative

    Algorithms in C, Parts 1-5 (Bundle): Fundamentals, Data Structures, Sorting, Searching, and Graph Algorithms (3rd Edition) by Robert Sedgewick

    The Art of Computer Programming, by Donald E. Knuth

    Two seminal works on the subject. It really depends on your needs however. Nearly anything you would need can be built off of the subjects in those books, but for more specialized datastructures you will probably have to move to specialized books.

    1. Re:data structures books by xtracto · · Score: 1

      The Art of Computer Programming, by Donald E. Knuth

      I highly recommend this book (all of its volumes). From what the original poster wrote I believe that is what he is looking for.

      There is a limit of precooked data structures that you will find in books but reading Knuth works (anyone of them) will make allow you to develop a highly abstract thinking that will allow you to create the *right* structure for your work. I would also recommend his "Concrete Mathematics" book.

      --
      Ubuntu is an African word meaning 'I can't configure Debian'
    2. Re:data structures books by phonics · · Score: 1

      I second the Sedgewick books. I still need to get through the second one (graphs) but it has great diagrams and thorough explanations without being as strictly rigorous as something like Knuth. However, I do have to say that the writing is still confusing in parts, and the source code (I got the C++ edition) is sometimes a little too terse but is very much like operating systems code.

      If you want design patterns, the seminal book is Gamma, Helm, Johnson, and Vlissides text "Design Patterns: Elements of Reusable Object-Oriented Software". It's the standard, but kinda hard to read. I've been reading "Head First Design Patterns" on O'Reilly's Safari books online - it's much easier to digest, but stylistically may be a bit too cheeky for you. YMMV. These books are hits #1 and #2 on Amazon when you search for Design Patterns.

      Also, don't dismiss network algorithms! Ok, now I'm done :)

    3. Re:data structures books by muridae · · Score: 1

      Third vote for Sedgewick's Algorithms in C++. I picked up the 2nd edition (I think) hard back for under 10$ some years back. It has been more useful then any of the books that have been required reading while I've worked on my CS degree.

    4. Re:data structures books by gidds · · Score: 1
      Yep, Sedgewick is well, well worth seeing. I'd never heard of it when I stumbled upon it in a bookshop: it was half an hour or so before I looked up and realised where I was, then I bought it on the spot. Unlike most similar books, I found it interesting to read! Not because it dumbs down or adds jokes, but because it makes the material itself interesting. It has enough detail to demonstrate the point, but not so much that it's hard to read -- so it's not a copy-and-paste sourcebook, but more like a course that gives you the ideas and understanding that you need to go off and write it yourself.

      OTOH, Knuth is exhaustive -- in both senses of the word! If it was known about at the time, it'll be in there; but it's hardly bedtime reading. (And not just because if you fell asleep and dropped it, it'd HURT!)

      I don't think any of my other favourites are terribly relevant here. Bentley's Programming Pearls and its sequel are very interesting, but are more about intriguing corner cases, gotchas, and useful techniques than about big algorithms. Van der Linden's Deep C Secrets is mostly about C, though there's a lot of OS-level stuff along with it, and the odd bit of C++ too. And Bloch's Effective Java and Java Puzzlers don't have too much to say outside Java, or at least OO languages generally.

      (I think what makes these favourites for me is the level of insight; they're all written by people who clearly have a huge understanding of the subject matter, and manage to pack a lot of wisdom into them there words.)

      OTOH, I find it hard to recommend Gamma et al. It was tremendously influential, and it's a good work, but it's a bit abstract. I found that I only really understood each listed pattern once I'd already come across a specific implementation or need, by which time the book didn't have much to add. It's good for understanding what patterns are, and why they're useful, and it introduces the standard names for many patterns, but the specifics might best be learned elsewhere.

      --

      Ceterum censeo subscriptionem esse delendam.

    5. Re:data structures books by oSand · · Score: 1

      Knuth writes very well, but MIX? Fuck that.

    6. Re:data structures books by RoloDMonkey · · Score: 1

      I have to completely agree with this. I don't use Knuth much because he is heavy on the math, but Sedgewick pared all that down and said use this if you are doing this, and use this other thing if your going to be doing this.

      Even if you aren't using C, I recommend "Expert C Programming: Deep C Secrets" by Peter van der Linden. It is simply the best programming book I have ever read. Clear, funny, and full of explanations of all those things that aren't explained in classes or other books that have you tearing your hair out in the real world. There is a reason why this 12 year old book, about a language that is more than thirty years old, is still in print.

      Speaking of old books, I am assuming that anyone that programs in C already has Kernighan and Ritchie's "The C Programming Language." Originally printed in 1978, with a second edition in 1988, this is the seminal work on C programming, and it is still in print today. I'm proud to say that my dog-eared copy is old enough that it does not say "ANSI Standard" on the cover.

      --
      Long live the Speaker Bracelet
      Rolo D. Monkey
    7. Re:data structures books by Mark+of+THE+CITY · · Score: 1

      What would you substitute, flowcharts or some high-level language? I learned data structures in part from Wirth's book, which used Pascal; it worked well for me.

      --
      The clearance system sounds logical. It is not. It is completely arbitrary. -- John Bolton
  3. If you can use C++ I recommend the STL by Progman3K · · Score: 1, Insightful

    No need to keep re-coding hasing lists when you have access to generic algorithms.

    Are you trying to code a linked-list, or are you trying to solve a problem?

    --
    I don't know the meaning of the word 'don't' - J
    1. Re:If you can use C++ I recommend the STL by Progman3K · · Score: 1

      D'oh! I meant 'HASHING'

      Dang kybard!
      *Yes, that's a Dilbert reference*

      --
      I don't know the meaning of the word 'don't' - J
    2. Re:If you can use C++ I recommend the STL by Anonymous Coward · · Score: 0

      RTFA

    3. Re:If you can use C++ I recommend the STL by 91degrees · · Score: 1

      STL is great, but it's a bit of a resource hog. And kernel programmers are real misers (not to mention control freaks) when it comes to resources.

    4. Re:If you can use C++ I recommend the STL by mdf356 · · Score: 1

      I'm looking for more tools. I know of the fundamentals of basic data structures, but some problems come up requiring fast operations that don't fit any of the basic structures. I'm hoping to avoid reinventing the wheel if I don't need to. Thanks, Matt

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    5. Re:If you can use C++ I recommend the STL by cheezit · · Score: 1

      In many cases, pairing basic data structures can give you the behaviors you want, without introducing a complex and obscure structure. For instance, if you need a structure with stack push/pop, enforced uniqueness, and that you can search in constant time, pairing a stack and a map gives you those behaviors with constant insert time. The insert/remove time may be double what it would be if you were to use a single structure, but as it is constant it will be efficient over large data sets.

      As far as structures that don't seem to be "standard", the ones I have found useful lately are tries and Bloom filters. My vote for least-utilized standard structure would be "set", which can be amazingly useful if you pick the right backing implementation.

      --
      Premature optimization is the root of all evil
    6. Re:If you can use C++ I recommend the STL by slcdb · · Score: 1

      C++ in a kernel? Sweet mother of God! Please don't do it! :D

      --
      Despite what EULAs say, most software is sold, not licensed.
    7. Re:If you can use C++ I recommend the STL by joto · · Score: 1

      C++ in a kernel? Sweet mother of God! Please don't do it! :D

      Why not? It's not like you have to use STL, MFC, multiple inheritance, and covariance just because you happen to use C++. C++ offers several advantages over C, and which features you decide to use, and where, is up to you. C is not perfect. There's little reason to stick to it, except tradition. C++ certainly isn't perfect either, but it has some advantages over C.

      Unix succeded pretty much because it was one of the first OS-kernels that was not written in assembly (of course Multics, which did not succeed, was also written in a high-level language..). Personally, I think it's time that we started writing OS kernels in better languages. Computers based on Lisp and SmallTalk, have been influential and popular among their users. Just because they didn't become succesful commercially, doesn't mean it wasn't a good idea.

      I'm not entirely sure about whether SmallTalk was ever used in the kernel at Xerox, but at least the Lisp-machines had kernels and compilers written in Lisp, and demonstrated that Lisp is an excellent language to write an OS-kernel in.

      Today, we have an enormous choice of excellent computer languages to choose from. And new ones can be designed, if you are not happy with one of the existing ones. Even Microsofts research division is writing OS's in new high-level languages. Unfortunately, if it isn't windows (or unix, or one of the popular realtime OS's, such as VxWorks), it ain't going to sell. For all I know, maybe the perfect OS already exist, but nobody uses it because it fails to be windows (or unix).

    8. Re:If you can use C++ I recommend the STL by Henry+V+.009 · · Score: 1

      I'd recommend taking a look at the book Efficient C++ for a set of benchmarks comparing the STL to handwritten code.

  4. Link lists? by tedgyz · · Score: 3, Funny

    You use linked lists in your kernel?!?

    --
    "No matter where you go, there you are." -- Buckaroo Banzai
    1. Re:Link lists? by aligature · · Score: 5, Insightful

      Linked lists are not necessarily a poor choice for a data structure. The cost of adding and removing elements from a balanced binary tree is completely wasted when you only need to add or remove from the beginning or end of a list. A linked list is a perfect data structure for a fifo or deque. All data structures have their advantages and disadvantages; your choice should depend entirely on your requirements.

    2. Re:Link lists? by jack_csk · · Score: 2, Funny

      Why are you surprised? He just forgot to tell you that he's working in Redmond, WA.

    3. Re:Link lists? by tedgyz · · Score: 1

      I was implying that he would be using fixed-sized arrays. :-)

      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    4. Re:Link lists? by AlastairMurray · · Score: 1

      It has been years since I actually looked at the code, but certainly back in the 2.4.x days the Linux kernel scheduler made use of linked lists (along side some clever pointer arithmetic that made for interesting reading.)

    5. Re:Link lists? by revlayle · · Score: 1

      Well, that's hardly a linked list then, is it?

    6. Re:Link lists? by supermank17 · · Score: 1

      There are situations where linked-lists are useful in the kernel. I certainly remember using them occasionally back in my OS class from days gone by, and I also remember seeing them in Linux kernel code.

    7. Re:Link lists? by Patrik_AKA_RedX · · Score: 1

      Not just linked lists. Even ... GOTO's.

      Just kidding... You can stop having a hearth attack...

    8. Re:Link lists? by tedgyz · · Score: 1

      But it would be debatable if any true "kernel" development occurs in Redmond. Most kernels I know don't bind in MediaPlayer. :-)

      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    9. Re:Link lists? by tedgyz · · Score: 1

      To fully clarify my satire - I was feining shock that an "advanced" structure like linked-list exists in the kernel.

      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    10. Re:Link lists? by Sancho · · Score: 1

      Go read some kernel code sometime. There are many more GOTO statements than you think.

    11. Re:Link lists? by Anonymous Coward · · Score: 0

      Linux does. See the recent Slashdot story, Weakness In Linux Kernel's Binary Format. Hmm, maybe that proves your point.

    12. Re:Link lists? by Anonymous Coward · · Score: 0

      Virtually every efficient memory allocation/deallocation routine relies on linked lists; it's not exactly what some people think of as a proper linked list structure, but it uses the same concept. Same goes for a lot of lightweight queues and stacks, depending on how they are being used.

      Don't bash a data structure or algorithm simply because you aren't creative enough to think of a niche it fills... Well, okay, feel free to bash the bubble sort. ;-)

    13. Re:Link lists? by tedgyz · · Score: 1

      I was being sarcastic.

      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    14. Re:Link lists? by tedgyz · · Score: 1
      Go read some kernel code sometime. There are many more GOTO statements than you think.
      The horror! The horror!

      In the object-oriented, application world, if-then-else is the new GOTO. Most if's I see today could be replaced with inheritance.
      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    15. Re:Link lists? by nategoose · · Score: 0

      Linked lists are just about the most common data structure in an OS kernel. I know they are common in Linux. Scheduling of processes is really just moving process nodes around within various queues which are typically made of linked lists. File systems use linked lists for unused disk blocks. Memory management uses them for free memory lists and other stuff I know I'm forgetting. IO uses them for chunks of data that needs to be written to a devise or that is waiting to be read by a process or processed by a driver. Just because they are the first data structure you learned does not mean that they aren't the be best for many circumstances. Both the code and the data overhead for them is very small, and they really do work well for stacks, queues, and dequeues -- all of which are very very common in OSes.

    16. Re:Link lists? by tedgyz · · Score: 2, Interesting

      It was sarcasm. Back in the day, kernels mostly used fixed-size arrays. I guess I'm showing my age.

      --
      "No matter where you go, there you are." -- Buckaroo Banzai
    17. Re:Link lists? by lgw · · Score: 1

      GOTO is still the right way to exit multiply-nested loops, if there's no clean way to use RETURN instead.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    18. Re:Link lists? by thesnide · · Score: 1
      It's actually quite useful to have a proper exception handling scenario, in order to release things nicely. In a language like C you don't have a destructors, so you have to implement yourself.

      Using GOTO can be useful to "linearise" the execution flow such as in :

      int foo()
      {
      // Acquire resource A
          A* a = allocate_a();
          if (a == NULL) {
              goto ERROR_A;
          }
       
      // Acquire resource B
          B* b = allocate_b();
          if (b == NULL) {
              goto ERROR_B;
          }
       
      // Do something
          int retval = first_processing(a, b);
          if (retval == -1) {
              goto ERROR_PROCESSING;
          }
      ...
       
      // Everything runned smoothly
          return retval;
       
      // Error handling
      ERROR_PROCESS:
        release_b(b);
      ERROR_B:
        release_a(a);
      ERROR_A:
        return -1;
      }
    19. Re:Link lists? by mdf356 · · Score: 1

      We do a lot with fixed size arrays, yes. But sometimes the elements are chained together with indices.

      The great thing about programming for the virtual memory manager is that arrays that take up a few TB aren't wasteful of anythig except effective address space. :-)

      Cheers,
      Matt

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
  5. KISS! by Just+Some+Guy · · Score: 2, Insightful
    Tarjan's Data Structures book looks like it has potential, but seems focused on network algorithms, which are unlikely to be applicable to the kernel programming I do.

    WTF? People who try to move cleverness in low-level critical code should be shot. Look, there's a time and a place for everything, but this is the wrong approach for the problemspace you're working in. You didn't say which kernel you're working with, but odds are extremely good that it already comes with a set of pre-defined macros or functions for handling data structures. Use them. They're much better tested and understood than the stuff you want to play with, and much less likely to make your codevelopers hate you.

    I don't want to be a stick in the mud, but seriously, this just isn't the place to start experimenting.

    --
    Dewey, what part of this looks like authorities should be involved?
    1. Re:KISS! by mdf356 · · Score: 1

      The issue comes when no existing data structure I can think of meets the performance requirements of some new feature. I'd like to not reinvent the wheel. Thanks, Matt

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    2. Re:KISS! by Mr2cents · · Score: 4, Informative

      Wikipedia has a nice collection of data structures. Maybe that's what you're looking for?

      http://en.wikipedia.org/wiki/List_of_data_structur es

      --
      "It's too bad that stupidity isn't painful." - Anton LaVey
    3. Re:KISS! by cmburns69 · · Score: 1

      The difference in the data structures is often like the age-old saying "It can be cheap, high quality, and fast. Choose two." For some problems, there can't be a data structure that has all the benefits and none of the tradeoffs...

      Out of curiosity, what problem are you trying to solve that is not covered by an existing data structure?

      --
      Online Starcraft RPG? At
      Dietary fiber is like asynchronous IO-- Non-blocking!
  6. What are you missing? by thsths · · Score: 1

    > I'd like to have more in my toolbox than hashes, linked lists, heaps and various binary and n-way trees.

    You forgot arrays (very useful!), but maybe that is just too trivial. Anyway, what exactly are you missing? Most problems I know can be solved using these basic data-structures, or a combination thereof.

    If you really want to, you can actually get by with just one data-structure:

    Lisp uses only nested linked lists, that can be interpreted as binary trees.

    Perl only really knows hashes. Arrays and lists exist, but the support is weak.

    Embedded programs often use arrays only, sometimes extended with linked lists.

    Databases use B-trees pretty much exclusively. They may not always be the fastest solution, but they perform well enough under a wide range of circumstances.

    Of course you can go and use advanced graph theory. It may even have its benefit, but will the next person working on your code know what you are doing? Lets face it, most people are spoiled by "convenient" languages. They know array and dictionary, that's as far as most people every get.

    Thomas

    1. Re:What are you missing? by mdf356 · · Score: 1

      The big-O time of operations is very important. With the large volume of data an OS has to keep track of, O(n) is unacceptable, and even O(lg n) is sometimes unacceptable for some routines. The kernel coders never get spoiled by convenient languages because we're still writing in C so we can completely control resource usage. Thanks, Matt

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    2. Re:What are you missing? by kalirion · · Score: 1

      In cases where O(lg n) is unacceptable, aren't you pretty much stuck with either an array or a hash-based structure?

    3. Re:What are you missing? by Greyfox · · Score: 4, Interesting
      If you really want to, you can actually get by with just one data-structure:

      And most programmers do. Read some code out in the industry and you'd think that 90% of the programmers out there never took a data structures class. Even if you're using a language like Java or C++ you really should know the implementation details of each so you can make informed decisions about the trade-offs in performance and maintainability. If you can't visualize the layout of your data and how you'll be accessing it, you really won't be able to pick the best structure for the job (Or roll your own if none of the usual ones fit.)

      I can't think of a C project I've worked on where I didn't have to write a basic data structure like a stack or a linked list. On a couple of them the programmer passed data around as char data and used offsets to get at the data in them. On one, the programmer didn't even know about structs (Or null string termination.)

      Having a "Convenient" language really isn't much of an excuse for not knowing this stuff. My data structures prof deliberatly chose an inconvenient language (BASIC) to show data structure implmentations. You can implement any structure in terms of array if you have to.

      It'd be nice if more programmers would actually put some thought into their code before they go and start writing stuff. I wouldn't seek to discourage that...

      --

      I'm trying to teach myself to set people on fire with my mind... Is it hot in here?

    4. Re:What are you missing? by mschaef · · Score: 5, Informative

      "Lisp uses only nested linked lists, that can be interpreted as binary trees."

      As much as people keep saying it, this is totally false... Common Lisp does not even have lists as an intrinsic type. What it does have are cons cells, several kinds of numbers, symbols, characters, strings, several kinds of vectors and arrays, hash tables, structures, instances, and lexical closures among other types native to the language.

      Lists are to Lisp what Strings are to C: a convention built upon more basic structures. In the case of C, a string is a convention built up on null terminated arrays of characters. In the case of Lisp, a list is a series of chained together cons cells.

    5. Re:What are you missing? by Anonymous Coward · · Score: 2, Insightful

      Yeah, you pretty much eliminate all tree structures, and hence all graphs structures, once you demand better than O(lg n) performance.

      The only way to improve on this in slower data structures is to use radix-style keying to cheat, so that your lookup keys tell you exactly how to find the value you're looking for. But this isn't really an "advanced" data structure, just an optimization of a basic one. (In fact, a lot of "advanced" data structures are just such application-specific optimizations; radix keying is obviously dependent on domain knowledge of your data set.)

      Almost all interesting data structures (in terms of implementation; lists are good enough for 90% of cases) are trees, or sometimes graphs, and even those are rarely needed in the majority of applications. The exceptions are probably so specialized that you'll never find a single book to cover even an interesting subset. Your best bet at that point is a focused literature search (if you have access to article databases), or perhaps a Google.

      You don't really need advanced data structures so much as advanced algorithms for using those data structures. The basic mechanisms for assembling and accessing a list, tree, graph, or hash table are basically the same for all algorithms. There's some clever work on, for example, lock-free data structures for concurrent programming that would probably be useful for a kernel programmer, but that's still not a matter of new data structures, but rather having full knowledge of the concurrency model of the multiprocessor you're working with, and optimizing for it, which is why it's mostly of interest to kernel programmers, and other people coding to the metal.

    6. Re:What are you missing? by 0xABADC0DA · · Score: 2, Interesting

      I find it fascinating that a kernel developer would be concerned with O() rather than the actual runtime. I thought kernel developers in general just put an arbitrary upper bound so their "O(n^2) && n -lt 1024" was faster than the "O(log n)" for any n.

      Now if what you are actually looking for is some fun how about embedding neko in the kernel, because while you can add some cool things like say tries (prefix trees) the real performance bottleneck is between apps and the kernel. Neko could safely call getpid() in the kernel 1000x more times than any user app could. This opens a lot of possibilites such as user code safely reading kernel structures directly with nearly zero overhead, functioning as event callbacks, etc.

      As an example, take something like beagle where it ideally gets notified of every file change and then, at some later time re-index the files. Do you really want every file modification doing a kernel-user-kernel switch? Or some hideous complicated caching API to specifically send these events all in a batch? (inotify I am looking at you...). Think a generic BPF.

    7. Re:What are you missing? by Captain+Segfault · · Score: 1

      Common Lisp does not even have lists as an intrinsic type. What it does have are cons cells...

      A list is typically just a value and another list. A cons cell *is* a list that just happens to support some extra operations.

    8. Re:What are you missing? by thsths · · Score: 3, Informative

      > As much as people keep saying it, this is totally false... Common Lisp does not even have lists as an intrinsic type.

      Funny how LISP stands for LISt Processing. And this thread is about data structures, not data types. The cons cell might be the central data type in LISP, but the nested list is the central data structure.

      Just think about it. '(a b c) will be recognised as a 3 element list by any LISP programmer, and not as 2 cons cells plus 3 atoms (which would be equally correct). Now you can also construct binary trees with cons cells, but that is more complicated and therefore a bit rare.

      Thomas

    9. Re:What are you missing? by mschaef · · Score: 3, Informative

      "Just think about it. '(a b c) will be recognised as a 3 element list by any LISP programmer, and not as 2 cons cells plus 3 atoms (which would be equally correct). "

      Actually no... it's 3 cons cells. The syntax (a b c) is shorthand for (a . (b . ( c . ()))). This kind of misunderstanding is precisely why any competent (key word) LISP programmer understands the difference between lists and cons cells I was referring to in my original post. The closest structure with only two cons cells is this (a b . c).

      Now, As long as we're being pedantic, what you actually wrote, '(a b c), is shorthand for (quote (a b c)). The numbers of cons cells and atoms in that case is a 'exercise for the reader', but suffice it to say that both your numbers are wrong.

    10. Re:What are you missing? by try_anything · · Score: 1
      In cases where O(lg n) is unacceptable, aren't you pretty much stuck with either an array or a hash-based structure?

      It depends on which operations have to be O(lg n). Operations that don't traverse the entire structure can be more efficient.

  7. Lewis & Denenberg by pedantic+bore · · Score: 1
    "Data Structures and Their Algorithms" by Lewis and Denenberg.

    Not an encyclopedia, like CLR(S) or Knuth, but rather a tutorial of many useful data structures and algorithms. Doesn't have the breadth of the "encyclopedic" books but what it covers, it covers very well.

    The drawback of this book, from your perspective, is that it isn't C-specific. It's usually transparent how to translate the code into C (or anything similar) but you can't just paste it into your code.

    --
    Am I part of the core demographic for Swedish Fish?
  8. Red-Black Trees Not Good Enough? by tecnopa · · Score: 1

    What type of "advanced data structures" are you alluding to? I cant imagine needing anything more complex than say, red-black trees , in kernel development.
    And as someone already pointed out, use the predefined macros. Failing that you can always check out
    http://lxr.linux.no/
    And to who ever made the comment about using lists in kernel source... *sigh* probably not worth it.

    1. Re:Red-Black Trees Not Good Enough? by mdf356 · · Score: 1

      For example, someone earlier reminded me of the Trie data structure. I haven't see it in 5 years so I'd forgotten about it. The existence and my forgetting of the Trie means there's other things I've forgotten or never learned that could be useful to solve some future problem.

      There have been times when red-black trees are too expensive, because they have 2 pointers per node and I can't afford the memory overhead. It's amazing how much memory gets wasted when you add an 8 byte pointer to a 0x10 byte structure that can have over 2^35 instances.

      Thanks,
      Matt

      --
      Terrorist, bomb, al Qaeda, nuclear, yellowcake, kill, assassinate. Carnivore is dead... long live Echelon.
    2. Re:Red-Black Trees Not Good Enough? by Anonymous Coward · · Score: 0

      This isn't going to solve all your algorithm needs, but your red-black tree remark reminded me of it. It just one specific, fairly obscure, but very nifty trick for creating a doubly-linked list using only one pointer per node.

      I'm late for work so I don't have time to type it all up nicely, but it comes from Byte Magazine, issue #10 (October?), 1980, page 278. (Try a public or college library.) The jist of it is to store the XOR of the "previous" and "next" pointers in one pointer instead. Then as you traverse the list in either direction you can always know which node you just came from, which together with the stored XOR pointer, allows you to calculate the pointer for the other direction.

      Oh how I miss Byte Magazine!

    3. Re:Red-Black Trees Not Good Enough? by thsths · · Score: 1

      > There have been times when red-black trees are too expensive, because they have 2 pointers per node and I can't afford the memory overhead. It's amazing how much memory gets wasted when you add an 8 byte pointer to a 0x10 byte structure that can have over 2^35 instances.

      Too expensive is relative. You can optimise most of the overhead away, but you still have to store 0x10 byte per structure. Investing a lot of work just to reduce the memory usage by 30% is *usually* not worth it, although there are certainly exceptions.

      And this is exactly what the Trie is for. It can offer some marginal advantages in general performance over B-trees, and it can offer more significant advantages in a few obscure areas (such as creation and locality). But for most purposes the B-tree is just good enough.

      Thomas

    4. Re:Red-Black Trees Not Good Enough? by Anonymous Coward · · Score: 0

      You'd save a lot more memory by ditching pointers (assuming some form of memory reference is needed), and using integer indices into an array for any pointer-like structure. You can only do this if you preallocate memory in a compact region, although you can have more than one region. (It's basically the old segmentation you had to do when computers had smaller pointers.) As long as you make the region is small enough, you can then use 16-bit or even 8-bit integers instead of 32-bit or (especially!) 64-bit pointers.

      I used this optimization a couple times to keep the packet size in a network protocol down, and optimize memory usage for some computer graphics structures (which tend to make a lot of references from vertex lists, etc.), but it's become somewhat more widely relevant lately with common 64-bit computers.

      The trie is a nice data structure in some respects, but the benefits aren't dramatic, and it's certainly something you could have invented on your own in the course of optimizing your application, provided you're reasonably familiar with ideas like Huffman coding. As someone who's been in an undergraduate program, let alone a graduate program, you've already got a big leg up. If you want dramatic improvements, you're going to have to look through research papers for an application-specific solution, if one exists. If you're not involved in cutting edge research, chances are the problem's been solved better already by some Ph.D. for who it's their life work; you simply need to code it up.

    5. Re:Red-Black Trees Not Good Enough? by ThosLives · · Score: 1

      Eh, that only works if you're traversing the list, not if you can possibly jump into the tree from a direct pointer to the object.

      Of course, for things where you really only always just traverse the list, this would be fine...an interesting concept actually. Guess it's another instance of "use the correct tool for the task at hand."

      --
      "There are a dozen opinions on a matter until you know the truth. Then there is only one." - CS Lewis (paraprhase)
  9. Computer Algorithms / C++ by gregor_jk · · Score: 2, Informative

    I was taught Computer Algorithms / C++ by Horowitz, Sahni and Rajasekaran( I believe they have a pseudocode version) and it was great. The seemed to be a perfect balance between the implementation and the ideas behind them.

  10. "patterns" by peter303 · · Score: 1

    "Patterns" is a taxonomy of class types which frequently recur in object-oriented programming such a C#, Java, and C++. Classes which capture data state are pretty straight forward to work out. But its less clear how to organize classes which are more functional or control in nature and components of large software systems. Thats where the identification and study of class patterns is useful. There have been a dozen books on the subject.

  11. advanced real life algorithms by Anonymous Coward · · Score: 0
  12. Data Structures and Algorithms by kjhambrick · · Score: 5, Informative

    Data Structures and Algorithms (ISBN 0201000237) by Aho, Ullman and Hopcroft is a classic that belongs on every programmer's bookshelf (hell, keep it on your desk!).

    1. Re:Data Structures and Algorithms by myatmpinis1234 · · Score: 1

      We used this book in my data structures class. Not surprising since the prof was Aho. In one of our exams he asked us to design an algorithm to determine the longest path between two points in a graph. You have to be a real SOB to assign an NP-complete problem as your exam. He is quite a character. Anyway, I guess this is not relevant, but it brings me back to the good old days before corporate slavery.

    2. Re:Data Structures and Algorithms by MarkusQ · · Score: 1
      You have to be a real SOB to assign an NP-complete problem as your exam.

      Be grateful he was asking you to design it and not execute it.

      --MarkusQ

      P.S. For that matter, it should be pretty easy to design an algorithm that does this, based around a wave front (work out from one end, kill all paths when they reach the other end, unless there is only one, which is the longest).

    3. Re:Data Structures and Algorithms by HuguesT · · Score: 1

      Your longest path algorithm won't work, you may have a cycle in your graph and your remaining path will never reach the endpoint. The algorithm will not terminate.

    4. Re:Data Structures and Algorithms by MarkusQ · · Score: 1
      Your longest path algorithm won't work, you may have a cycle in your graph and your remaining path will never reach the endpoint. The algorithm will not terminate.

      My parenthetical comment was just a sketch; obviously (by the usual meaning of "longest path") you wouldn't ever use the same arc twice, so cycles don't matter.

      --MarkusQ

  13. Lecture notes by Anonymous Coward · · Score: 0

    Well, like another poster said, don't dismiss CLR too soon--in my experience, most problems could be solved by clever applications of one or more simpler data structures, rather than a really advanced one. Regardless, take a look at the lecture notes (scribe notes are decent quality) for 6.897 at MIT: http://theory.lcs.mit.edu/classes/6.897/spring05/l ec.html
    They cover a good sampling of recent and important results, at least theoretically important (some data structures that achieve a log log n speed up over basic ones you'd obviously never want to implement)

  14. Network algorithms by coyote-san · · Score: 2, Informative

    Network algorithms are useful in an astoundishing number of places, especially in those cases where all flows are either 0 or 1. You just need to expand you idea about what the networks and flows represent.

    E.g., my professor used network algorithms when writing the software that matches medical schools and students. Each school prioritizes it's candidate students, each student prioritizes his schools. The program finds the best matches. He said it had taken many hours (12 hours?) to do originally, but with the network flow it was a few minutes on an old kaypro.

    Another example was determining when teams are mathematically eliminated from playoffs. It sounds like a simple problem, but it isn't since a team could lose a game yet remain in the running because a different team lost its own game.

    A decade ago these algorithms would be overkill for a kernel. Today... I can definitely see how these algorithms could make a difference in some places.

    --
    For every complex problem there is an answer that is clear, simple, and wrong. -- H L Mencken
    1. Re:Network algorithms by Anonymous Coward · · Score: 0

      E.g., my professor used network algorithms when writing the software that matches medical schools and students. Each school prioritizes it's candidate students, each student prioritizes his schools. The program finds the best matches.

      For an interesting mathematical discussion of this problem, see the American Mathematical Society article, "Mathematical Marriages", and scroll down to section 5 ("Hospitals and Residents"). By coincidence, I just happened to run across that article today...

    2. Re:Network algorithms by edwdig · · Score: 1

      Another example was determining when teams are mathematically eliminated from playoffs. It sounds like a simple problem, but it isn't since a team could lose a game yet remain in the running because a different team lost its own game.

      Why is that hard? I was wondering how baseball magic numbers were calculated recently, and it only took me about 2 minutes to figure it out.

      Magic Number = Games in Season - Wins by First Place team - Losses by 2nd place team + 1

      As long as that is above zero, the 2nd place team can still pass the first place team. It doesn't necessarily have to be the 1st and 2nd place teams, just substitute in the teams you care about. Use the lowest ranked qualifying team, and anyone ranked lower than them for a more general case.

    3. Re:Network algorithms by Miniluv · · Score: 1

      That only addresses a simple case where the higher ranked team of the two you're comparing goes. Now imagine you've got three divisions of which the winner advances. Then imagine those three divisions are in a league where the best record that didn't win a divisional title advances. It gets even more complicated when advancement isn't strictly based on record but instead a point system (like the NHL) where ties and certain types of losses still generate points.

      We'll not even mention tie breaker rules that might be necessary.

      Granted its not likely to end up looking like a scene of out Baseketball but it is still more complex than your simple algorithm would lead people to think.

  15. algorithm design manual by Anonymous Coward · · Score: 0

    Skiena's "Algorithm Design Manual" is a useful compendium of algorithms and data structures. It's organized as a dictionary of design problems, with a survey of solution methods, hints about which ones work best under which circumstances, and pointers to source code.


    While it doesn't go into detail about the algorithms and data structures, it lets you figure out which ones are best candidates to spend more time learning about.

  16. Wikipedia by Anonymous Coward · · Score: 0

    Im suprized no one suggested wikipedia yet. To start try http://en.wikipedia.org/wiki/List_of_data_structur es

  17. Amazon referer by Beached · · Score: 1

    I wonder how much he is making from refering the books on amazon (4% of X sales from slashdotting) ?

    Good idea, wish I thought of it first.

    --
    ---- aut viam inveniam aut faciam
  18. Really advanced data structures... by Bender0x7D1 · · Score: 1

    If you are looking for the best/craziest/most efficient data structures out there then you need to go through some of the computer science journals. It can be a royal pain to crawl through them looking for what you want, but that's where you will find all the "advanced" data structures. They also provide all of the information on how to use them, behavior, best uses and performance information on those structures, (including proofs if you care).

    If you are just looking to refresh your memory, or learn a few more data structures, then the web is a good place to start. Just make sure to copy/save/take notes on what you find so you don't have to search when you need that cool data structure you read about 2 months ago that gave you O(1) performance in your situation. Reference books are also good, but most cover the same 80% so after 1 or 2 books you are spending a lot for just a few new pages.

    --
    Reading code is like reading the dictionary - you have to read half of it before you can go back and understand it.
  19. Okasaki book by philgross · · Score: 2, Informative

    A few years ago, I took Chris Okasaki's "Advanced Data Structures" course at Columbia. Looking at the Wikipedia Data Structures article others have mentioned, it's pretty good, but doesn't include, e.g. Pairing Heaps, which have excellent real-world performance. You might want to check out Chris's book Purely Functional Data Structures (ISBN 0521663504). Even though you're not working with a functional language, it's a good catalog of some recent data structures, and from what I saw in the class, he understands them at a very deep level.

  20. Algorithms and Data Structures in C++ by tedgyz · · Score: 1

    "Algorithms and Data Structures in C++", by Leendert Ammeraal, Wiley, 1996. It is the only book I found that has good coverage of Tries.

    --
    "No matter where you go, there you are." -- Buckaroo Banzai
  21. Judy Arrays by r00t · · Score: 1

    They aren't really arrays, but rather trees. They are really nice. They are cache-friendly without needing to be tuned for a particular size of cache.

    If you make a few macros or inline functions for them, then using them everywhere becomes practical.

  22. A complete book online for free by exp(pi*sqrt(163)) · · Score: 3, Informative
    --
    Doesn't it make you feel good to know that our freedoms are protected by politicans, lawyers and journalists.
  23. Tomes of delphi by abradsn · · Score: 1

    I've read many (around 15) data structures and algorythms books. Here is the best one that you will still be able to get in print: Tomes of delphi: algorithms and data structures Julian M Bucknall It covers advanced structures and walks you through improvements on algorythms. Basically it teaches you why and how some algorythms are most suited to various situations. Also, since it is in Pascal it is usually easier to port the code to more modern languages than C. The only drawback in this book is its binary tree algorythm, which I don't like and don't understand (his version anyway). Though I have several other books that cover that well, and since you are looking for more advanced stuff then you won't need that particular tree algorythm either.

    1. Re:Tomes of delphi by Anonymous Coward · · Score: 0

      After (around 15) books you still can't manage to spell "algorithms" correctly and didn't understand an important part of the book which you say is "best"? :) Sorry, not too inspired to get it.

  24. The Handbook of Algorithms and Data Structures by scc · · Score: 1

    "The Handbook of Algorithms and Data Structures" (in Pascal and C) Second Edition, by G.H. Gonnet and R. Baeza-Yates, ISBN 0-201-41607. It's a compact reference and analysis of a pretty broad range of algorithms. I also strongly second some of the other suggestions above such as Sedgewick, and Aho, Hopcroft, and Ullman. "The Stanford GraphBase" by Knuth, ISBN 0-201-54275-7 is great, though focused obviously. Beyond the basics, you'll end up looking in very specific books, such as "Text Compression" by Bell, Cleary, and Witten, ISBN 0-13-911991-4 or similar works applicable to the problem at hand. Some of the most interesting data structures I've seen I first encountered in journals. I can't seem to find it now, but it was in Journal of the ACM, if I recall correctly, I first learned a scheme to manage small sets that made membership-test, insertion, deletion, and finding the next member of the set all constant-time operations.

    Where possible, of course, you don't want to implement these from scratch. You want to understand them so you know which apply to your problem, but then get code from, e.g. for C++, the Standard Library and Boost, both of which can also be a shopping list to spark further investigations.

  25. The Algorithm Design Manual by cjitlal · · Score: 1

    'The Algorithm Design Manual' by Steven Skiena at Stony Brook is a very pragamatic book for intermediate data structures and algorithms. This is a definitely aimed at the practitioner who must get something up and running, without having to worry about big-Oh notation etc. There's an online version of the book but it's just so good, I'd recommend that anyone who needs this information, snap up a copy. Skiena also maintains The Stony Brook Algorithm Repository It's a treasure, as it includes implementations of some of these algorithms in a variety of programming languages. The web page does look somewhat dated, but as a good first step into intermediate data structures and algorithms.

  26. Goodrich and Tamassia by NNland · · Score: 1

    Goodrich and Tamassia have a good general algorithms book. It's much shorter than CLRS, but it is also significantly more readable. They also have an "Algorithms in C++" and "Algorithms in Java" variants coauthored with others that have fairly substantial code samples.

  27. Algorithm Design Manual by psykocrime · · Score: 1

    The Algorithm Design Manual is pretty good.

    --
    // TODO: Insert Cool Sig
  28. byte-order independence by fortunatus · · Score: 2, Interesting
    On a couple of them the programmer passed data around as char data and used offsets to get at the data in them.

    Although mentioned in a negative light,

    This technique is important when you have to move data between big-endian and little-endian processors. It lets you write portable I/O routines.

  29. Different patterns for different machinery by korpique · · Score: 1

    Anyway, the Design Patterns book contains patterns for problems imminent in the class of languages it concentrates in. In different language classes different problems arise. Higher patterns than those in that book would be more poignant to a larger set of languages.

    --
    I was the real korpiq until I woke up clowned.
  30. dude by Anonymous Coward · · Score: 0

    you just made yourself look like an ass.

    1. Re:dude by mschaef · · Score: 2, Funny

      "you just made yourself look like an ass."

      Dude, I was arguing on Slashdot about the number and proper usage of data types in Lisp, of all things... I think looking like an ass was pretty much a part of the deal from the get go.

    2. Re:dude by HalWasRight · · Score: 1
      I think looking like an ass was pretty much a part of the deal from the get go.

      But you wear it so well!


      Based on your argument C doesn't have arrays, just pointers with some syntactic sugar.

      --
      "This mission is too important to allow you to jeopardize it." -- HAL
    3. Re:dude by mschaef · · Score: 2, Insightful

      "But you wear it so well! "

      Well, we're all 'special' in our own unique ways. :-)

      To be frank, I wouldn't have been quite so harsh (ass-like, if you wish) if he hadn't just happened to make one of mistakes that proved exactly my point about the difference between cons cells and lists.

      "Based on your argument C doesn't have arrays, just pointers with some syntactic sugar."

      I'd actually agree with that.... A bit of trivia: in C, what's the difference between a[b] and b[a]? ...... Nothing, they are semantically equivalent to *(a + b) and *(b + a).

      Keep in mind that I'm not saying any of this is a bad thing: in the case of Lisp lists, the added flexibilty that comes from their representation can be tremendously useful. However, it does complicate things. Just as an example, consider what happens when you define a function that traverses a list. Since Lisp lists can't be identified as being finite until you traverse them, you need to either be willing to tolerate functions that don't end when passed certain kinds of 'lists' or include extra baggage to detect when they're in an infinite list. Lisp also doesn't make the guarantee that the last 'next list' in a list is even a list at all: another edge case that's introduced by the fact that Lisp doesn't have first class lists.

      Something else to consider is that Lisp doesn't even have to have cons cells at all. There's nothing to keep them from being represented internally as structures, arrays, or even closures. In other words, not only does the LISt Processing language not have lists as a first class type, it doesn't even have to have their component cons cells as a first class type. Lists can entirely be implemented using types the original poster seems to believe Lisp doesn't even have at all. Which brings me to the second reason I was an ass in my response... my experience has been that blanket statements tend to oversimplify things and can ultimately lead to bad decisions. If this guy has really reduced Lisp to nested lists, Perl to hash tables, Embedded programming to arrays, and Databases to B-trees, I question his ability to think critically in any amount of depth about software engineering problems. Of course, he could also be the best developer on the planet... After all, this is Slashdot, so you do have allow for the possibility of incompletely thought through 'pissing contest' posts. Which is the third and final reason I was somewhat an ass. :-)

      At the very least the original poster has shown the presence of mind not to keep posting in this thread..

    4. Re:dude by Anonymous Coward · · Score: 0

      At the very least the original poster has shown the presence of mind not to keep posting in this thread..

      But you haven't let that stop you.

    5. Re:dude by mschaef · · Score: 1

      "But you haven't let that stop you."

      So you posted to let me know that I was posting in spite of the fact that, as I posted, the original poster was no longer posting. Does that about sum it up?

  31. Handbook of Algorithms and Data Structures by functor0 · · Score: 1
  32. Lock free data structures by aybiss · · Score: 0

    If you're doing kernel development, you may want to look into (or indeed focus on) lock free and wait free data structures. I'm not sure if there are any books out on this, but there are some great resources on the web such as

    http://works.music.columbia.edu/LFDS

    as well as a mailing list at

    http://tech.groups.yahoo.com/group/liblf-dev/

    The group is developing an open source lock free data structures library - I'm just a lurker waiting for the library to become available ;-)

    The posts so far at the Yahoo site are a gold mine of links to sites and papers.

    --
    It's OK Bender, there's no such thing as 2.
  33. quit trying to be clever by NateTech · · Score: 1

    If you barely understand it and have to look it up in a book, you're doing the next guy to work on your code (and your organization) no favors.

    Make stuff ONLY as complex as it NEEDS to be. That's the job of a good engineer.

    If you're bored, perhaps you're struggling with the fact that 80% of what is done with computers today ONLY requires linked lists, hashes, and that dull "generic" stuff to get the job done.

    No need to build the Golden Gate Bridge to span the 10 foot wide creek in your back yard. In fact, it's downright bad design.

    Your boredom with those data structures isn't cause enough to abandon them, no more than we're all going to stop welding steel plates together when building large structures.

    Engineering is engineering. Computer engineers need MORE structure and standards, not less by any means.

    The truly outstanding algorythm geniuses also know WHEN to apply them, and then they have to see MASSIVE performance gains to make them worthwhile -- because they know their code is highly disruptive technology to those who don't understand it and might have to maintain it someday.

    And the really amazing ones always mentor/teach a few people to understand it later to take over maintenance.

    --
    +++OK ATH
  34. MOD PARENT UP by Traf-O-Data-Hater · · Score: 1

    Agree entirely. Most of the code you'll encounter in your working career _will_ require the same "boring" structures, certainly in the business and financial sector. That's been my experience in 18 years of coding C, C++, C# and others. Yes I think Design Patterns are neat like everyone else and have used a few myself, but as the parent says you are not doing anyone else a favour if you've just included them for the sake of it, especially if you are retrofitting them into the bulk of existing code that happens to function just fine using 'boring' structures.

  35. Judy Arrays - Very interesting by Anonymous Coward · · Score: 0

    any thoughts on Judy arrays http://judy.sourceforge.net/

    I think it is an interesting concept.. There are some concerns about it at http://www.nothings.org/computer/judy/

    I think the concept is good.. Do you think it is a feasible solution for a highly scalable data structure?

  36. Book reviews by alexo · · Score: 1


    Look at the ACCU book reviews, preferably by subject for books on Algorithms and Data structures (there's a lot of overlap).

  37. Judy Arrays by sgowkanapalli · · Score: 1

    I have had enough of the hashes and B-trees.. Any thoughts on Judy arrays http://judy.sourceforge.net/ I think it is an interesting concept.. There are some concerns about it at http://www.nothings.org/computer/judy/ . I think the concept it good.. Do you think it is a feasible solution for a highly scalable data structure?

  38. Flamebait or fact by passionplay · · Score: 1

    At the risk of sounding like I'm trying to start a flame war, let me be the first to say how stupid it sounds for an intelligent person that has not READ a book to call it TOO basic for something like kernel programming.

    Sounds to me like you're looking for a cookbook. Not to learn. Programming is an art and a science. You have to learn how to walk before you run and run before you fly. You cannot become a kernel programmer just by learning only those things you THINK are needed to program a kernel.

    That's like saying you can build an airplane by learning to fly one. Get a grip, and do a little light reading.

    Having had to teach a Lotus Notes developer how to do a simple sort, I can honestly say there is nothing more basically flawed than a lack of basic understanding.

    Computer Science has been around a long time, as has kernel programming. Those things you are dismissing as basic are the very fundamentals of your trade.

    Ante up, or move on. Or as Yoda put it, do or do not. There is no try.

  39. Algorithm Design by dyamkovoy · · Score: 1

    I have the Kleinberg/Tardos book for one of my classes. You're right, it is pretty basic -- it does not really go into implementation, it is more about the theory behind certain algorithms and proving that they work. If you are looking more for different approaches to certain problems, and suggestions about implementing them, I would not suggest this book.