Course software
We use 7zip as default zip/unzip tool (only for Windows OS). Download and install 7zip, and add its installation path to user's environment Path variable.
We use Visual Studio Code (VS Code) as default IDE for all programming tasks. Download and install VS Code to your computer. Start VS code, add C/C++ IntelliSense and Code Runner extensions.
We use GNU C/C++ compiler as default C compiler. If you use Windows OS, you can install the MinGW (Minimalist GNU for Windows) by downloading this cp264 software package (cp264_software_mingw64.zip) and follow the instructions in the included README.md file to install and configure the MinGW compiler and included utility programs.
For Mac or Linux users, there are equivalent C compilers. The quick solution is to open a terminal, and issue command gcc, that will prompt you to install the developer package with GNU compiler.
Code examples
The following code examples are for illustrating features of C programming language and data structures, not for production programming. Some of these examples are used in lessons.
- C program structure and organization
- Basic program structgure example addsubtest.c
- header file addsub.h
- implementation file addsub.c
- main program file addsub_main.c
- header file muldiv.h
- implementation file muldiv.c
- main program file arithmetic_main.c, using addsub and muldiv, build and use static and shared libraries
- Data type, variables and constants:
- Basic operations:
- Bitwise operations:
- Flow controls:
- Functions
- function concept
- function concept in assembly
- function concept at runtime,
- function - pass by values
- function - pass by references
- swap function
- recursive function (recursive algorithm vs iterative algorithm
- Specifiers and scope
- Pointers:
- Arrays
- global array and local array
- array by pointer
- pass array to function
- issue of array index range
- read to array
- Array sort:
- 2D arrays
- String
- simple string
- array of string pointers
- command line arguments
- string copy by string.h functions
- string comparison
- print all fixed length string of given symbols
- Structure
- structure structure pointer
- structure as function parameter
- function return structure
- array of structure and function
- Union
- Enumeration
- File read
- File write
- file write
- file copy
- file write by fwrite
- fread/fwrite/fseek
- file write binary (structure)
- file read binary (structure)
- csv file read and write
- Linked lists
- Linked list with separated files
- Queues
- array queue
- circular array queue
- singly linked list queue
- deques by array
- priority queue by linked list
- Josephus Problem
- Stacks
- Stack applications:
- backtracking and reverse order by stack
- parenthesis check
- infix to postfix conversion
- postfix evaluation
- Hanoi tower by recursive function
- play tic-tac-toe with AI
- play nim with AI
- Trees
- Tree applications
- expression tree to infix/postfix/prefix
- infix to expression tree
- Huffman coding with compressing and decompressing
- AVL trees
- AVL tree rotation/insertion/deletion with recursive algorithms
- AVL tree insertion/deletion with iterative algorithms
- Bidirectioal AVL tree insertion/deletion with iterative algorithms
- Red-Black-tree and others
- red black tree and insert/delete operations by iterative algorithms
- splay tree search/insert/delete operations
- B-tree
- Hash tables
- Heaps
- Graph representations and operations
- graph by adjacent matrix representation
- graph by adjacency list representation
- graph by linked node representation
- graph by adjacency matrix with topology sort
- Application algorithms on graphs
- weighted graph by adjacency matrix with minimum spanning tree Kruskal's algorithm
- weighted graph by adjacency matrix with minimum spanning tree Prim's algorithm
- weighted undirected graph by adjacency matrix with Dijkstra's shortest path algorithm
- weighted undirected graph by adjacency matrix with Floyd-Warshall algorithm for all-pair shortest path
- Solving 8-puzzle game by graph BFS