Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In a typical computer science algorithms course, much attention is given to the discussion of queues vs. stacks as a data structure programmers need to consciously choose from to achieve algorithmic performance. What's a good Mathematica program example that also involves (explicitly) choosing data structures? Most of these "implementation details" or algorithmic design tactics is automated in a black box fashion by Mathematica's Automatic idiosyncrasy.

share|improve this question
M is a high level language (4th generation if you will), so most of the time, you do not need to implement these data structures since they are not needed, Mathematica commands already there to do pretty much anything you want. But if you want to implement them you can. Here is a link that shows how to – Nasser Jul 1 '14 at 0:11
I also do not think Mathematica is the right choice for computer science algorithms course, since it is a high level language. Same as Matlab is not a good choice, and neither is Maple. We used Pascal for this at school where one can 'see' things. In higher level languages, the need to implement such data structures is not needed as much as in low level and system programming. – Nasser Jul 1 '14 at 0:33
Search for "Data Structures" here – Dr. belisarius Jul 1 '14 at 1:12
The example of a trie used to implement prefix word search here, and particularly its application to the Boggle problem are I think good examples where the right choice of data structures was crucial. The first one also uses a stack to collect letters for words, while the last one also uses linked lists to store partial results. – Leonid Shifrin Jul 1 '14 at 9:08
A stack is a good mechanism for doing a depth-first traversal. Also it is useful for branch-and-bound integer programming e.g. as indicated here or here. A queue might be useful for a breadth-first traversal. A priority queue (which is not the same as a queue) can be used for sorting, or for branch-and-prune types of programming. – Daniel Lichtblau Jul 1 '14 at 16:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.