a) Define token attributes of the following, Z = 2x * y + x
b) Define token attributes of the following (i.e show Identifiers, keywords,
numbers etc. )
i) If (A+3<400) A = 0;
Else B = AA
Lexical Analysis(Finite Automata)
A finite automaton (FA) is a simple idealized machine used to
recognize patterns within input taken from some character set
(or alphabet) C.
The job of an FA is to accept or reject an input depending on
Issues in the Design of a Code
Input to the code generator
Choice of evaluation order
Input to the code generator
Intermediate representation of t
Compiler; it is a program that translates source program to target program.
Interpreter; a program that reads the source program and produces the results of executing the
Qualities of a compiler
Works well with the debugger
Computer Science 2620, CRN 31005 Fundamentals of Programming II
Course Outline Fall 2014
Time of Lectures:
TuTh 12:15 13:30
Dr. S. Hossain
C+ From the Beginning
When the list elements are ordered
Given a list A
Ordered means it can be non decreasing order, a0 >= a1 >= an-1
How many times is the while loop iterated?
The while loop is exited when left > right , left and right are moving toward
Homework 3 (Solutions)
(1) We get
22 3 7
846 = 2 3 141
111 = 3 37.
(2) Let n be a number with exactly three divisors. Let n = p1 p2 pk be
its prime factorization. Then we get
(i + 1).
Since 3 is prime we get that i + 1 = 1 for all but one of
(Due: Thursday Feb 9th)
(1) Calculate (n 1)! mod n for n cfw_2, 3, 4, 5, 6, 7, 8, 9, 10, 11.
(2) Find the remainder of
1! + 2! + 3! + + 100!
when it is divided by
(Hint: Most of the terms are congruent
Show that there is no positive integer n such that (n) = 14.
Find all positive integers n such that (n)|n.
Show that if m and n are positive integers with m|n, then (m)|(n).
An integer n is perfect if (n) = n. For example
Homework 10 Solutions
(1) Note that x is a primitive root if it has order 6 modulo 7. To make sure
x has order 6, it suces to check that does not have order dividing 3 or
2. So, we need to check if x3 and x2 are equivalent to 1 modulo 7. The
(Due: Thursday Jan 19th)
(1) Assume that there is a surjective map : N S. Show that the map
: S N given by (s) = min 1 (s) is injective.
(2) Assume that : S N is injective. Show that there is a surjective map
: N S. Conclude that subset of a
(Due: Thursday Jan 26th)
Recall that we say a and b are coprime to each other if their greatest common
divisor is 1.
(1) For a given prime p, how many positive integers less than p are coprime to
(2) For a given odd prime p, how many positiv
This is a quick example of Hensels lemma.
Say we want to solve the equation f (x) = x3 + 8x 5 0 (mod p3 ) where p = 5.
We can check that f (0) 0 (mod p). Also f (0) 3 (mod p).
Here is one way of doing this: Let x1 = 0. Let x2 = 0 + pt (since we know
Homework 5 - Solutions
(1) Given a, c, and m, the linear congruence ax c (mod m) is satised if and
only if there is an integer y such that ax + my = c.
Note that the solutions to ax + my = c can be solved using Euclids
algorithm. In some of the easier cas
(1) Find the last digit of the decimal expansion of 71000 .
(2) Show that if a is an integer such that a is not divisible by 3 or such that a
is divisible by 9, then a7 a (mod 63).
(3) Show that a(b) +b(a) 1 (mod ab), if a and b are relatively
Homework 6 - Solutions
(1) Let f (x) = x3 + 8x2 x 1.
(a) Checking all congruences we get that x 4, 5 (mod 11).
(b) We apply Hensels lemma to the two roots x 4 and 5 (mod 11).
x 4 (mod 11) First note that f (4) = 111 1 (mod 11). Therefore, a = 1 is
Homework 5: Due Nov 29th (Thursday)
(1) Evaluate the limits (note i, j, and k are the three basis vectors in R3 ):
(a) lim (t2 , 4t, 1/t)
(b) lim (e2t i + ln(t + 1)j + 4k).
where r(t) = (sin(t), 1 cos(t), 2t).
Compute the following:
(a) r (t)
(1) (a) Let
Sample midterm 1
an = n n. What is a5 ?
br = 2ar . What is b2 ?
ck = ak ak+1 . Find a formula for ck .
that lim an = 4 and lim bn = 2. Determine
(a) lim an /bn
(b) lim sin(b2 )
(c) lim an2
(3) Let a0 =
(1) True or False
(a) There are convergent sequences that are not monotonic.
(b) If lim an = 10 then there is an integer N such that 9.9 < aN < 10.1.
(c) There is a sequence an so that a1 = a2 = a3 = = a10 = 1, but
lim an = 0.
(d) If 0 < li
Sample midterm 2
(1) The following sequences are convergent. Find their limits.
(a) an = nn+1 .
(b) an = n1/n .
(c) a1 = 1, and an+1 = 2 + an for n > 1.
(2) Which of these series converge and why.
n(log n + 1)
Homework 5: Due Nov 20th (Tuesday)
Show that F (x) has innite radius of convergence.
(2) Find the power series for f (x) = x log(1 + x ).
(3) Find the rst three terms of the Taylor series of f (x) = 1+tan x around 0.