Programming 1, 2020-21
Week 9: Exercises

1. Recursive Palindrome

Write a function is_palindrome(s, i, j) that is true if the substring s[i:j] is a palindrome. You may not use any loops or slice operations, so you will need to use recursion.

2. Random Tree

Write a function randomTree(h) that builds a complete binary tree of height h. Every value in the tree should be a random integer in the range 0 .. 999.

3. Flip a Dictionary

Write a function that takes a dictionary such as { 'green' : 'zelený', 'red' : 'červený' } and returns a corresponding dictionary in which the keys and values have been flipped, e.g. { 'zelený' : 'green', 'červený' : 'red'} .

4. Time Class

Write a class Time that represents a time of day with 1-second resolution, e.g. 11:32:07.

5. Date Class

Write a class Date representing a month and day. The class should support these operations:

6. Polynomial Class

Write a class Polynomial representing a polynomial of a single variable. The class should support these operations: