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:
- 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.
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:
- 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.
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:
-
IBM's Best practices for programming in C
-
Pointers
-
Math is Fun: binary Number System
Lecture Notes:
- Introduction
-
Hello World in Linux
-
Printf and some Primitive Types
-
Variables and Loops
-
If Statements
-
The hallowed CS-241 Coding Standard
-
Defining and Using Function
-
Binary
-
Character Arrays
-
Bubble Sort
-
Pointers
-
Lab 2 Solution: Counting Characters, Lines and Words
-
Lab 3 Solution: getbits
-
Structures
-
Memory Management
-
Standard C Libraries
-
Recursion
- Source code
quicksort.c
Labs and Projects:
- Lab 1: Linux and ASCII Art
-
Lab 2: Counting Characters, Words and Lines
-
Project 1: Stock Price Prediction using Markov Chains
-
Lab 3: getbits
-
Lab 4: Command Line Arguments
-
Lab 5: Linked Lists
-
Project 2: The Maze Generator
-
Lab 6: Working With PNG Files
-
Project 3: Tron: Spring 2012
- NOTE: the best way to get these files is NOT to download them with the browser!
The best way to get the files is to:
1) login to your cs.unm.edu account
2) create a tron directory
3) within the tron directory enter:
cp ~joel/public_html/cs241/libmcp.a libmcp.a
- Header file tron.h
- Dummy implementations of each student's _getName, _init and _move functions. classDummy.c
- Example student AI that shows how to use the MCP / AI interface.
Alan_Kuntz.c
This is the example shown in the slides.
- MCP Library libmcp.a (this current version only has the blind robots, and only plays
one game at a time)
- Game Viewer tronViewer.jar
- Tron: The Executable tron
Executable version that includes all the student bots that do not segfault.
Also changed the parameters so all output except game results can be suppressed.
Finally, the game result output shows total wins for each team in the list.
Past Exams:
- Midterm exam from Fall 2010
- Midterm exam from Spring 2011
- Final exam from Fall 2010
- Final exam from Spring 2011
- Final exam from Spring 2012