Computer programming - Review

Recursion

Sample problem
A prefix expression is either an unsigned integer or an operator + - * / followed by two prefix expressions, preceded by arbitrary whitespace. Write a program that reads a prefix expression from input and computes its value.

Iteration

Sample problems

Write a program that uses readnat / readint to compute the sum of unsigned/integer numbers on each line / until end of input.

Write a program that identifies all numbers in an arbitrary text (separated or not by whitespace from the rest of the text) and prints their sum.

Bit operators

Sample problem
Write a function that takes two unsigned integers n and k and returns the value obtained rotating n by k bits to the left (bits removed on the left are inserted at right).

Arrays

Sample problem
Write a function that takes as argument an array of n integers and its length and checks if the array is a permutation of the numbers 0 through n-1. If so, return the number of cycles of the permutation; else return 0.

Marius Minea
Last modified: Sat Nov 7 17:00:00 EET 2015