Prep for Data Structures

Data structures is a challenging course.  I routinely receive requests for information about how to prepare for the course or what material to review.  Generally speaking, the most important thing to do is review and get comfortable with C++ and problem solving using C++.  Some of the topics that are of particular importance are:

  • Developing algorithms using fundamental control structures
  • Problem decomposition (breaking a problem down into steps to solve it)
  • Object oriented programming in C++ (classes, inheritance, and polymorphism in c++)
  • Pointers (what they are, how to use them, etc.) including pointers to pointers and arrays of pointers
  • Relationship between pointers and arrays
  • Memory management is a biggie, so I’ll break it down into finer points
    • Dynamic Memory Allocation and deallocation (new, new[], delete, and delete[])
    • What methods you should explicitly include in a class that contains dynamic memory (copy c’tor, overloaded operator =, destructor)
    • Difference between stack and heap (free store)

I don’t expect you to be an expert in all of the topics above, but I would expect that you’ve heard of all of them.  And, at least for some of them, you’ve got a firm understanding of what they are/mean/are used for.

Here are some links to materials from the last time I taught CSE 1342 that you might find useful:

If you’d like any more info on a particular topic, feel free to drop me an email.

Command Line Args in C++

As you’re already familiar with, when you call some functions, you need to pass arguments to them.  So, what about main?  There are two different function headers for he main method in C++ that we can use:

int main (); //header 1

and

int main(int argc, char* argv[]); //header 2

Now, you should ask yourself, “What’s the difference?”  Remember that when you execute a program (either from the command line or by double-clicking on an icon or something similar), you’re really asking the OS to load the executable and begin execution.  When the OS is starting your program, you can use command line arguments to send arguments into the main method.  Consider this program execution:

./myFunGame input.txt output.txt

[Read more…]

Data Structures Intro

The first few weeks of the semester, we’ll take a deep(er) dive into pointers and dynamic memory management using C++.  To get started, I wanted to provide you some links to useful information.

Regarding our first topic, pointers and memory management, here are some links to some other blog posts I did over the summer that might be helpful: