3
$\begingroup$

Data Structures is the second CS course taught at Columbia University and it lists Discrete Mathematics as a Co-Req.

I have a BSEE and have not taken any discrete mathematics and am having a hard time understanding why I need to take this to do things like create data structures?

Is this just so the university can cram useless info in my head and make more money, or is there a real relation to discrete math and data structures?

$\endgroup$
8
$\begingroup$

A course on data structures will not be about "creating data structures". You can expect to analyse data structures, prove various properties of them, and create your own to solve some highly nontrivial problems.

Every single data structure you intend to build must be rigorously defined. Each method on a data structure must be proven rigorously to be correct. The time and space complexity of each method must be rigorously proven to follow a particular asymptotic bound. This all involves some nontrivial discrete mathematics. You'd also need to have a solid handle on probability when randomized inputs and data structures start being used, which you should expect for a decent course on data structures. If you're still unconvinced, look up Cuckoo Hashing and show that the insert time is, on average, $O(1)$, or take a look at a van Emde Boes tree and just attempt to figure out how the hell it works in the first place. You'll quickly realise that there's far more to it than just writing code to build obvious structures.

However, if you go into this course believing it to be beneath you, I can guarantee that you'll get nothing out of it. I would be very surprised indeed if an Ivy League university is "trying to cram useless info into your head and make more money".

$\endgroup$
7
$\begingroup$

Universities are not in the business of cramming useless info. If what they were teaching wasn't useful, they wouldn't bother. I recommend taking a more accepting attitude to life. If you go to college expecting to learn nothing, this is a self-fulfilling prophecy: you will learn nothing, so college will be wasted and you might as well start flipping burgers now.


Integers are a very simple form of data structures. Many of the algebraic structures that come up when studying functions that operate on integers also arise in the study of data structures.

Taking the size of a data structure maps the algebraic constructions on data structures to the corresponding algebraic constructions on integers. For example, the length of the concatenation of two lists is the sum of the length. This applies more generally to taking the site of a slice of a data structure, for example counting the substructures of a certain shape. For this reason, discrete mathematics often come up when studying the complexity of algorithms on data structures.

For examples of discrete mathematics at work, see

I recommend the book Concrete Mathematics by Ronald Graham, Donald Knuth, and Oren Patashnik.

Mathematics of almost any kind is also a way to gently introduce important concepts of rigorous proofs and abstraction. When reasoning about computer programs, you often need to keep track both of what is mathematically true, and of what the computer knows to be true, so to speak — the data that is available at each point of the program. It helps to first train your brain to cope with the mathematical truths, and gently graduate to following both the math and the program.

$\endgroup$
5
$\begingroup$

Discrete Mathematics is pretty important for almost anything.

Direct applications of Discrete Math in DS:

  1. The Foundations of Logic and Proofs - Without being able to write good proofs, we can never claim a data structure/algorithm to be correct.
  2. Graph Theory: without the fundamental knowledge of Graph Theory, tree data structures cannot be understood. Moreover Graphs are one of the most important components in DS. Almost all good DS use graphs in some way or the other.
  3. Functions: we always write functions in a program, but what does that really mean?
  4. Algorithms and recursion: Teaches asymptotic analysis : needed to analyze programs and run times.
  5. Discrete Probability: if you look into more advanced Data Structures, many of them use randomized algorithms. Without probability, it would be difficult to argue about their correctness and efficiency.

On an informal note, Discrete Math is one of the best subjects in CS, without it, most other subjects would be really difficult to appreciate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.