REM 100- Midterm Exam Guide - Comprehensive Notes for the exam ( 19 pages long!)

341 views19 pages

For unlimited access to Study Guides, a Grade+ subscription is required.

SFU
REM 100
MIDTERM EXAM
STUDY GUIDE
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in
Name: - Vinay Lalwani
Student ID: - 301319204
Tutorial Section: - D102
Day and Time: - Monday, 12:30-1:20
The one environmental problem that affects me is overpopulation. Being from a
country which has population on the boom, I can relate to the effects of
overpopulation which range from not only scarcity of basic supplements like food
and water but also to their governing. Governing over such a large population and
making sure basic rights are granted to all is a very tough task to achieve and thus
I think overpopulation is one of the most important issues of the date.
Overpopulation is not an issue that can be dealt with overnight and thus it would
take a huge effort on the governments of all countries to educate the people on
the effects of overpopulation and of having massive families and n number of kids
in one family. As for how it is being resolved, in China, to take as an example, the
government has introduced a new law which states that a family can have only up
to two kids, after which if they want to have another kid, they must pay a fee to
the government. Such an strict law on one hand can be criticised to be ruthless
and harsh but on the other hand it does help bring control over the rapid
overgrowth of population in the country and hence even though it may seem
harsh, it ends up being quite an effective alternative.
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in
Answers to Homework 1
p. 13 1.2–3 “What is the smallest value of nsuch that an algorithm whose running time is 100n2runs
faster than an algorithm whose running time is 2non the same machine?”
Solution:
Find the smallest n > 0 such that 100n2< 2n.
Use a calculator and do a “binary search”. I tried n=10, 20, 15, . . ..
n100n22n
10 104103
13 1.69 ·1048.2 ·103
14 1.96 ·1041.64 ·104
15 2.25 ·1043.28 ·104
20 4·104106
At n=15 you will find that 2nexceeds 100n2.
p. 21 2.1–3 “Consider the searching problem:
Input: A sequence of nnumbers A=ha1, a2, . . . , aniand a value v.
Output: An index isuch that v=A[i]or the special value nil if vdoes not appear in A.
Write pseudocode for linear search, which scans through the sequence, looking for v.”
Solution:
Linear-Search(A, v)
1. i1
2. while i < length[A]and A[i]6=v
3. do ii+1
4. if A[i]6=v
5. then inil
We are not concerned with correctness in this course, but if you have thought of an
invariant for Linear-Search you may want to compare it against the following.
v6∈ A[1 . . . i 1]or v=A[i]
p. 27 2.2–1 “Express the function n3/1000 100n2100n +3in terms of Θ-notation.”
Solution:
n3/1000 100n2100n +3=Θ(n3)
p. 27 2.2–3 “Consider linear search again (see Exercise 2.1–3). How many elements of the input sequence
need to be checked on the average, assuming that the element being searched for is equally
likely to be any element in the array? How about in the worst case? What are the
1
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class