Homework 11 Solution
Exercise R-13.1
Professor Amongus reduced a problem in P to a problem in NP. To show P= NP, he
would have to reduce a problem in NP to a problem in P. We already know that every
problem in P is already in NP.
Exercise R-13.7
To show t
Homework 10 Solution
Exercise R-11.1
Many solutions exist, such as the below from a student in the class:
Exercise R-11.10
400
Exercise C-11.2
In step1, every processor decides, with probability 4/n, whether to send a leader-election
message to its neighb
Homework 9 Solution
Exercise R-9.11
The longest prex that is also a sufx of this string is "cgtacg".
Exercise C-9.4
Modify the KMPMatch algorithm to maintain a variable maxIndex which is the index of
the longest prex found, maxLen which is the length of t
Homework 8 Solution
Exercise R-8.2
Answer the following questions on the flow network N and flow f shown in Figure 8.6a:
What are the forward edges of augmenting path? What are the backward edges?
The forward edges are: (s,v2), (v2, v3), (v1, v4), (v4, t
Homework 7 Solution
Exercise R-7.7
Answers vary. For example, the following is correct.
Exercise C-7.3
The greedy algorithm presented in this exercise is not guaranteed to find the shortest path
between vertices in graph. This can be seen by a counterexam
Homework 6 Solution
Exercise R-6.5
Inserting a vertex runs in O(1) time since it is simply inserting an element into a doubly
linked list. To remove a vertex, on the other hand, we must inspect all edges. Clearly this
will take O(m) time.
Exercise R-6.7
1
Homework 5 Solution
Exercise R-5.4
1. T(n) is O(n) (case 1).
2. T(n) is O(n3) (case 1).
3. T(n) is O(n4 log5 n) (case 2).
4. T(n) is O(n*log37) (case 1).
5. T(n) is O(n3 logn) (case 3).
Exercise R-5.12
This is a knapsack problem, where the weight of the s
Homework 4 Solution
Exercise R-4.9
O(nlogn) time
Exercise R-4.14
The bubble-sort and merge-sort algorithms are stable.
Exercise R-4.16
No. Bucket-sort does not use a constant amount of additional storage. It uses O(n+N)
space.
Exercise C-4.1
This can be d
Homework 3 Solution
Exercise R-3.3
There are several solutions. One is to draw the AVL tree created by the input sequence:
9;5;12;7;13. Now draw the tree created when you switch the 5 and the 7 in the input
sequence: 9;7;12;5; 13.
Exercise R-3.6
The AVL t
Homework 2 Solution
Exercise R-2.10
A worst-case sequence for insertion sort would be one that is in descending order of keys,
e.g., 44 36 29 25 22 15 13 10 9 3. With this sequence, each element will first be moved to
the front and then moved back in the
1
MODULE V
MORE ALGEBRA POLYNOMIAL RINGS
To prepare for a study of finite fields (considered in Module VI) we begin with the notion of a ring of
polynomials with coefficients from an arbitrary field.
Definition 1. Let F be any field and x be a variable (s
1
Module VI
Finite Fields This module deals with the existence and the structure of finite fields.
Remarks 1. F x (f(x) is a finite field when F is finite and f(x) is irreducible.
Proposition 1. If F is a finite field then a smallest number p, which is ne
1
MODULE II
More Number Theory and Some Algebra; n ( mod n)
As we already know (, +, o has "algebraic" structure.
)
Indeed. both + and o are binary operations on that are associative and
commutative; 0 is the identity of (, +), 1 is the identity of (,o an
1
MODULE I
Elements of Number Theory We begin with a basic study of the multiplicative structure of
and we introduce the Euler phi function, which plays an important role in the study of residue
systems.
Definition 1 If a, b we say a divides b, denoted b
1
Module IV
Quadratic Residues: The Legendre and Jacobi Symbols The apparent difficulty of determining
quadratic residues (the Quadratic Residuosity Problem) is the basis for believing the
Goldwassor-Micali probabilistic public-key encryption scheme to be
1
Module III
Finite Cyclic Groups and Conditions on n for n to be Cyclic
In Module II we determined that is a finite group of order (n) and
n
that if a then ord (a)
n
(n). Of course, if ord (a) = (n) then
= 1, a, a 2 ,., a (n)-1
n
and we say that is cyc
Part 1
"Tic-tac-toe, also called noughts and crosses (in the British
Commonwealth countries), X's and O's (in Ireland) and X and 0 (in
India) is a pencil-and-paper game for two players, X and O, who
take turns marking the spaces in a 33 grid. The X player
Control Structures - Selection Statements
1
Control Structures: Selection Statements
Any C+ program can be written using only the following three control structures.
(1) sequence
(2) selection
(3) repetition
Sequential statements: These statements are exe
Predefined Functions
1
Predefined Functions
The programs that we have seen so far are very simple ones. In larger and more
complicated programs, we have to divide the problem into smaller subtasks and then
implement each subtask as a function.
Instead of
C+ Basics
1
Basic data types
In our first program the data type of the variables we have used is int. Thus we can store
whole numbers in these variables.
In this part, we will discuss:
more about the int type for storing integer numbers
double type for
Computer Systems & Program Design Process
1
Computer Systems
We begin with a description of the basic parts of a computer system.
program is a set of instructions for a computer to execute.
software for a computer is the set of programs used by the com
Lecture 26:
Primitive Roots
and the
Die-Hellman-(Merkle) Protocol
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 26 c 2015 Stevens Institute of Technology
1/12
Primitive Roots
Lecture 24:
The Chinese Remainder Theorem
and
A Little Fermat
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 24 c 2015 Stevens Institute of Technology
1/1
There are certain thi
Lecture 25:
A Little Fermat
and
RSA
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 25 c 2015 Stevens Institute of Technology
1/22
Fermats Little Theorem
If p is prime and a is
Lecture 22: Integer Algorithms
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 22 c 2015 Stevens Institute of Technology
1/20
Introduction
Were going to do things we already kno
Lecture 23: Chinese Premainder Theorem
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 23 c 2015 Stevens Institute of Technology
1/19
There are certain things whose number is
un
Lecture 21: Partial Orderings and Posets
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Spring 2015
Lecture 21 c 2015 Stevens Institute of Technology
1/24
Equivalence Relations on a 4-Element Set
Lecture 20: Equivalence Relations
Michael Engling
Department of Computer Science
Stevens Institute of Technology
CS 135 Discrete Structures
Fall 2015
Lecture 20 c 2015 Stevens Institute of Technology
1/43
Equivalence Relations
Denition: A relation on a se