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

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
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-105 -> CS-152 -> CS-251 -> CS-241.


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

Lecture Notes, Labs, Source Code and Other Resources:

Week 1:

  1. Notes: Introduction
  2. Notes: Hello World in Linux
  3. Lab: Introduction to C, ASCII ART & the Linux Command Line
  4. Notes: Printf and some Primitive Types

Week 2:

  1. Notes: CS-241 coding standard
  2. Notes: Variables and Loops
  3. Lab 2 Adding Character Digits
  4. Data: lineSum.in Input data file for lab 2.
  5. Data: lineSum.out Required ouput data file for lab 2. Your result must match every character of this file.
  6. Notes: If Statements

Week 3:

  1. Notes: Functions
  2. Read: Math is Fun: binary Number System. Understanding of binary will be needed for Lab 3.
  3. Notes: Binary and Bit Operators
  4. Lab: Bitwise Crossover
  5. Data: crossover.in Input data file for lab 3.
  6. Data: crossover.out Required output for lab 3 from crossover.in. There will also be unknown input and output.
  7. Data: crossover.unknown.in
  8. Data: crossover.unknown.out

Week 4:

  1. Project: Identifying the Rank of a Poker Hand and an Empirical Calculation of Probabilities
  2. Data: poker.in The known input data file for project 1.
  3. Data: poker.out Required output for poker.in. There will also be unknown input and output.
  4. Data: pokerUnknown.in
  5. Data: pokerUnknown.out

Week 5:

  1. src: crossover_joel.c Solution code for Bitwise Crossover lab.
  2. Notes: Counting Characters, Lines and Words

Week 6:

  1. Notes: Character Arrays
  2. Notes: Generating Random Numbers
  3. Notes: Bubble Sort
  4. Notes: Postfix
  5. Lab: Code Review Form (right click to save)

Week 7 & 8:

  1. Notes: Recursion
  2. Lab: Postfix Calculator
  3. Data: postfix.in The known input data file for postfix calculator lab.
  4. Data: postfix.out Required output for postfix.in
  • Data: postfix.unknown.in
  • Data: postfix.unknown.out
  • Week 8:

    1. Notes: Pointers
    2. Lab: Using Pointers: Command Line Arguments
    3. Data: binary.cmd Note: must be set to "executable".
    4. Data: binary.out Required output for binary.cmd

    Week 10 & 11:

    1. Memory Management
    2. Maze Generation
    3. src mazegen.h
    4. src mazetest.c

    Week 12 & 13:

    1. Structures
    2. File I/O
    3. data Sword_8x8.bmp
    4. src BitmapReader.c
    5. src BMP_ImageWriter.c

    Week 14 - 16:

    1. Final Project: Tron (with branching)
    2. lib libmcp.a MCP (64-bit, ubuntu library) Compile and link with:
      gcc *.c -L. -lmcp -lm -lpthread `sdl-config --libs` -lSDL_ttf -o tron
    3. src tron.h
    4. src classDummy.c

    Past Exams:
    1. Midterm exam from Spring 2015
    2. Final exam from Spring 2012