CS 241: Data Organization using C
Computer Science Department
University of New Mexico
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:
- Read and apply the C syntax covered in the textbook (The C Programming Language by Kernighan and Ritchie).
- 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.
- 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.
- 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.
However, what you really need is:
The most likely path to success with the first few CS courses at UNM is: CS-105 -> CS-152 -> CS-251 -> CS-241.
- A solid grasp of basic control flow (if, else if, for, while, ... or equitant) in any programming language:
Java, Matlab, Fortran, Basic, Python....
- 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.
Lab Schedule, Lab Instructor e-mail, and Office hours
Lecture Notes, Labs, Source Code and Other Resources:
- Notes: Introduction
Hello World in Linux
Introduction to C, ASCII ART & the Linux Command Line
Printf and some Primitive Types
CS-241 coding standard
Variables and Loops
- Lab 2
Adding Character Digits
- Data: lineSum.in Input data file for lab 2.
- Data: lineSum.out
Required ouput data file for lab 2.
Your result must match every character of this file.
Math is Fun: binary Number System. Understanding of binary will be needed for Lab 3.
Binary and Bit Operators
- Data: crossover.in Input data file for lab 3.
- Data: crossover.out Required output for lab 3 from crossover.in. There will also be unknown input and output.
- Data: crossover.unknown.in
- Data: crossover.unknown.out
Identifying the Rank of a Poker Hand and an Empirical Calculation of Probabilities
- Data: poker.in The known input data file for project 1.
- Data: poker.out Required output for poker.in. There will also be unknown input and output.
- Data: pokerUnknown.in
- Data: pokerUnknown.out
- src: crossover_joel.c
Solution code for Bitwise Crossover lab.
Counting Characters, Lines and Words
Generating Random Numbers
- Lab: Code Review Form (right click to save)
Week 7 & 8:
- Lab: Postfix Calculator
- Data: postfix.in The known input data
file for postfix calculator lab.
- Data: postfix.out Required output for postfix.in
- Notes: Pointers
- Lab: Using Pointers: Command Line Arguments
- Data: binary.cmd Note: must be set to "executable".
- Data: binary.out Required output for binary.cmd
Week 10 & 11:
- Memory Management
- Maze Generation
- src mazegen.h
- src mazetest.c
Week 12 & 13:
- File I/O
- data Sword_8x8.bmp
- src BitmapReader.c
- src BMP_ImageWriter.c
Week 14 - 16:
- Final Project: Tron (with branching)
- 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
- src tron.h
- src classDummy.c
- Midterm exam from Spring 2015
- Final exam from Spring 2012