0% found this document useful (0 votes)
35 views

MAD101 Assignment 2

This document outlines 13 math and computer science problems to be completed for Assignment 2 by June 21, 2023. The problems cover topics like algorithms for determining palindromes, determining if a function is onto, analyzing asymptotic complexity of functions, modular arithmetic, recursion, and sets of integers.

Uploaded by

Phúc Hồng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

MAD101 Assignment 2

This document outlines 13 math and computer science problems to be completed for Assignment 2 by June 21, 2023. The problems cover topics like algorithms for determining palindromes, determining if a function is onto, analyzing asymptotic complexity of functions, modular arithmetic, recursion, and sets of integers.

Uploaded by

Phúc Hồng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

MAD101 - Assignment 2

Deadline: June 21, 2023

1. A palindrome is a string that reads the same forward and backward. De-
scribe an algorithm for determining string of n characters is a palindrome.
2. Describe an algorithm that determines whether a function from a finite
set of integers to another finite set of integers is onto.
3. Determine whether each of the functions 2n+1 and 22n is O(2n ).
4. Find the least integer n such that f (x) is O(xn ) for each of these functions.
(a) f (x) = 2x2 + x3 log x
(b) f (x) = 3x5 + (log x)4
(c) f (x) = (x4 + x2 + 1)/(x4 + 1)
(d) f (x) = (x3 + 5 log x)/(x4 + 1)
5. Show that for all real numbers a and b with a > 1 and b > 1, if f (x) is
O(logb x), then f (x) is O(loga x).
6. Evaluate these quantities.
(a) 13 mod 3
(b) −97 mod 11
(c) 155 mod 19
(d) −221 mod 23
7. Show that if a, b, c, and m are integers such that m ≥ 2, c > 0, and a ≡ b(
mod m), then ac ≡ bc( mod mc).
8. Find each of these values.
(a) (192 mod 41) mod 9
(b) (323 mod 13)2 mod 11
(c) (73 mod 23)2 mod 31
(d) (212 mod 15)3 mod 22
9. Use the Euclidean algorithm to find

1
(a) gcd(1, 5)
(b) gcd(100, 101)
(c) gcd(111, 201)

10. Prove that if n is a positive integer such that the sum of the divisors of n
is n + 1, then n is prime
11. Find the output of the recursive algorithm if input n = 5.

procedure f(n: integer):


If n = 1 then return 2
else return f (n − 1) · n;
12. How many positive integers not exceeding 100 and divisible by exactly one
of 6 or 9?

13. Find a recursive definition for the set of positive integers NOT divisible
by 3.

You might also like