CS 241: Data Organization using C
Computer Science Department
University of New Mexico

Instructor:
Joel Castellanos
Department of Computer Science

Course Description
CS-241 is an introduction to the C Programming language, an introduction to using a command-line interface i n the Linux operating system, and an introduction to machine level data organization and memory allocation. Students taking this course should already be familiar with basic concepts of computer programming such as variables, conditional control flow and loops. Developing mastery of these fundamental concepts is one of the goals of CS-241. Students in CS-241 author many C programs: Lab assignments will be short and relatively simple. Projects will be more interesting and touch on a wide range of computer applications including encryption, numerical analysis, databases, artificial intelligence, genetic algorithms and games.

Many examples used in this course involve standard data structures such as linked lists and trees. However, mastery of such data structures is not within the course’s domain. The primary goals of CS-241 are for the student to be able to:

  1. Read and apply the C syntax covered in the textbook (The C Programming Language by Kernighan and Ritchie).
  2. Without a computer, determine the output of C language source code involving triply nested loops, conditional control flow, function calls, pointers, arrays, arithmetic, logical and bit operators, tructures and memory allocation.
  3. Use a Linux command-line environment to manipulate files, and directories, and to edit, compile, run and debug C programs. This includes the use of simple makefiles and a low level debugger such as valgrind.
  4. Implement, in C, any given algorithm with a complexity level equivalent to that of quicksort or a doubly linked list with accuracy, efficiently and clarity.
Prerequisite Skills
The formal prerequisite is any one of CS-151 (intro Matlab) or CS-152 (intro Java) or CS-251 (Java) or CS-259 (honors Java).

However, what you really need is:

  1. A solid grasp of basic control flow (if, else if, for, while, ... or equitant) in any programming language: Java, Matlab, Fortran, Basic, Python....
  2. A solid base in Algebra I. If solving linear equations with one or two variables on paper has you scratching your head, then you need more math before attempting this course. You can sign up, but you will just be donating tuition dollars to UNM. I have never seen anyone pass who started the course while struggling with linear equations.
The most likely path to success with the first few CS courses at UNM is: CS-131 -> CS-152 -> CS-251 -> CS-241.


Syllabus

Lab Schedule, Lab Instructor e-mail, and Office hours


Obtaining a cs.unm.edu account:
Instructions for obtaining a CS account and its Terms of Service (TOS)

Supplemental Reading:

  1. IBM's Best practices for programming in C
  2. Pointers
  3. Math is Fun: binary Number System


Lecture Notes:

  1. Introduction
  2. Hello World in Linux
  3. Printf and some Primitive Types
  4. Variables and Loops
  5. If Statements
  6. The hallowed CS-241 Coding Standard
  7. Defining and Using Function
  8. Binary
  9. Character Arrays
  10. Bubble Sort
  11. Pointers
  12. Lab 2 Solution: Counting Characters, Lines and Words
  13. Lab 3 Solution: getbits
  14. Structures
  15. Memory Management
  16. Standard C Libraries
  17. Recursion
  18. Source code quicksort.c
Labs and Projects:
  1. Lab 1: Linux and ASCII Art
  2. Lab 2: Counting Characters, Words and Lines
  3. Project 1: Stock Price Prediction using Markov Chains
  4. Lab 3: getbits
  5. Lab 4: Command Line Arguments
  6. Lab 5: Linked Lists
  7. Project 2: The Maze Generator
  8. Lab 6: Working With PNG Files
  9. Project 3: Tron: Spring 2012
Past Exams:
  1. Midterm exam from Fall 2010
  2. Midterm exam from Spring 2011
  3. Final exam from Fall 2010
  4. Final exam from Spring 2011
  5. Final exam from Spring 2012