Computer programming
Instructor: Marius Minea, marius@cs.upt.ro (Office: B531. Phone: +40-256-403284)
Lab assistant: ing. Alexandru Iovanovici
Course: Tue 10-13, A115
Lab: Thu 16-20, B418
Office hours: Wed 12-14 B528, Fri 8-10, B418
Lab grades
Midterm results For short comments send e-mail.
Midterm solutions: prefix expression (see lab 3), reading terms (concise), bit segments (see lab 5), float mantissa (see last program for lect. 5), ints in string (version with indices)
Exam results (1, 2 and 3) To discuss your exam, set up an appointment.
Exam 1 solutions: change with coins, hexadecimal float, 3 reals per line,
sort words in file (alternate version)
Exam 2 solutions: replace letters, unsigned to float, numeric expression (simplified), last n lines
Exam 3 solutions: n choose k letters, hexa string to num, string chars in order, extract HTML headings
set 2: balanced parantheses, rotate bits left, matrix multiply, image URLs
Course materials
An excellent pledge on how to be a student in a course (CS @ U. of Virginia)
last year's course
- Introduction. Recursion.
Sample program: box fractal
- Recursion. Character input.
3n+1 problem, read fractional part
- Tail recursion. Decision. Assignment. Iteration
HTML tag filtering (version 2), integer calculator
- Iterative processing
LaTeX commands, prefix to postfix, count words in line (one inner loop, two inner loops, in-word flag), balanced parantheses
- Internal representation. Bitwise operators
bitwise addition, stream bits, bitmap processing, float structure
- Arrays. Matrices. Strings
add numbers represented as strings
- Input/Output
add numbers on each line, find full word or substring, find URLs
Additional reading: Aleph One, Smashing The Stack For Fun And Profit, Phrack Magazine, vol. 7(49), 1996. A classic introduction to the danger of buffer overflows.
- Pointers. String processing
cutting a string, building a format string, parsing floats/ints
- Pointer arithmetic. Function pointers
Examples: string concatenation, sorting strings, vectors and matrices
- Dynamic allocation. Files
Examples: write number in binary, info from bitmap
- Structures
Example: Date with bits and bitfields, function terms
- Abstract data types:
intlist.h, intlist.c, listprog.c, fiblist.c
- Implementing abstract data types. Review
listfun.h, listfun.c,
using pointers to links,
queue.c, myalloc.c (more here),
s-expressions
- Timing. Randomization. Hashing
random numbers, hashing for word frequencies
Laboratory
- Lab 1: Introduction. Recursion
Exercise: Write a program, similar to the one done in class, that draws
the Koch curve, as described here.
- Lab 2: Recursion. Character input
- Lab 3: Character processing (recursive and iterative)
- Lab 4: Character processing (recursive and iterative)
Solved problems: Comments and strings, read real number, extract phone numbers
- Lab 5: Bitwise operators
- Lab 6: Arrays
Solved problems: n choose k, reverse each word, words in opposite order
- Lab 7: Input/output
Solved problems: numbers with commas. Intermediate stages: 00, 0, 1; filter sub/superscript tags
- Lab 8: Pointers
Solved problem: reorder cmdline args
- Lab 9: Pointers
Solved problems: paste strings, combine array elements
- Lab 10: Dynamic allocation
- Lab 11: Files
- Lab 12: Structures. Abstract datatypes.
Solved problems: remove list duplicates, number as prime factors
- Lab 13: Abstract datatypes. Review
Solved problems: read integer list, reconstruct tree
Office hours (review)
print bits, swap groups of 4 bits, string to pointer array, read array of lines, Fibonacci words
read int, replace string, find string in matrix (variant)
bitwise addition;
alternatives to sorting words: fixed length,
with length byte
structures with variants (union)
Training exercises
- Recursion: fractals and grammars
- Recursion: rewriting, combinatorics.
sequences with sum of digits 10
Resources
Marius Minea
Last modified: Wed Jun 24 10:20:00 EEST 2015