SE307 - Computational Complexity Theory
Department of Computer Science
National University of Ireland, Maynooth
T Naughton, NUIM
Back to SE307 home
Lab 1
This lab tests your basic programming skills. I am expecting each of you to get 100%.
You have two hours to answer all eight questions. Write your solutions as pseudocode algorithms (or in a programming language of your choice - C/C++/Java) using only while loops for iteration. If you use any high-level functions such as is_a_substring() or is_prime() you must also produce their code. Help from books/notes/fellow students not allowed. Ask a demonstrator to check an algorithm as soon as you are finished.
Firstly, solve these three problems from Lab 1 of the second year data structures course CS210.
Next, the following five problems. Given character arrays A, B, and integer variable X, write functions for the following tasks:
1.4 Write a function to test if A is a palindrome.
1.5 Write a function to test if positive integer X is prime.
1.6 Write a function to check if A is a substring of B.
1.7 Write a function to check if A is of the format anbnan, where n>=0.
1.8 Write a function to write out all possible unique strings of length 2 that can be formed with the characters from A.