CMPS 101 Exam Questions on Algorithms and Abstract Data Types, Exams of Computer Science

A collection of exam questions from a university course on algorithms and abstract data types. The questions cover various topics such as time complexity analysis, recurrence equations, sorting algorithms, and red-black trees. Students are expected to answer multiple-choice questions based on the provided information.

Typology: Exams

Pre 2010

Uploaded on 08/19/2009

koofers-user-bx0
koofers-user-bx0 🇺🇸

9 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
1. CMPS 101 Algorithms and Abstract Data Types
References:
1. Baase and Van Gelder: Computer Algorithms, 3rd Ed. Addison Wesley, 2000.
2. Cormen, Leiserson, Rivest: Introduction to Algorithms, 2nd Ed.. McGraw-Hill, 2001.
Scoring: Each question will have four choices for the answer,
(
a
)
(
d
)
. You will earn two (2) points for each correct
answer. A blank answer counts zero; a wrong answer counts –1. You will have one–two “grace” questions that you can
leave blank and still earn a perfect score.
The example problems here are indicative of the topics and format for the exam. The actual questions will be
variations with slightly different problem instances, numbers, and mathematical expressions. However, the concepts
that are tested by these questions will not change on the exam.
Problems:
1. [2] 6n2logn
+
2n
+
5isin:
(a) Θ
(
n2
)
.
(b) O
(
n2
)
.
(c) O
(
n3
)
.
(d)
(
n3
)
.
2. [2] O
(
p
n
)
includes the functions:
(a) 1
2
p
nand 0
:
001n.
(b) 2
p
nlognand 2
p
n.
(c) 1
2
p
nlognand 1
2
p
n.
(d) 2
p
nand 10logn.
3. [2] If f
(
n
)
is in Θ
(
nE
)
, then:
(a) f
(
n
)
is in O
(
nE
)
but not in
(
nE
)
.
(b) f
(
n
)
is in
(
nE
)
but not in O
(
nE
)
.
(c) f
(
n
)
is in O
(
nE
)
andalsoin
(
nE
)
.
(d) All of the above are possible, depending on fand E.
4. [2] If f
(
n
)
is in Θ
(
g
(
n
))
and lim
n
!
f
(
n
)
g
(
n
)
exists, then some possible values for this limit are:
(a) 10 and 100.
(b) 0 and 100.
(c) 10 and .
(d) 0, 1 and .
5. [2] n
k
=
1klog2
(
k
)
is in:
(a) Θ
(
nlog
(
n
))
.
(b) Θ
(
klog2
(
k
))
.
(c) Θ
(
n2log
(
n
))
.
(d) Θ
(
k2log2
(
k
))
.
pf3
pf4
pf5

Partial preview of the text

Download CMPS 101 Exam Questions on Algorithms and Abstract Data Types and more Exams Computer Science in PDF only on Docsity!

1. CMPS 101 — Algorithms and Abstract Data Types

References:

  1. Baase and Van Gelder: Computer Algorithms , 3rd Ed. Addison Wesley, 2000.
  2. Cormen, Leiserson, Rivest: Introduction to Algorithms, 2nd Ed.. McGraw-Hill, 2001.

Scoring: Each question will have four choices for the answer, ( a )–( d ). You will earn two (2) points for each correct answer. A blank answer counts zero; a wrong answer counts –1. You will have one–two “grace” questions that you can leave blank and still earn a perfect score. The example problems here are indicative of the topics and format for the exam. The actual questions will be variations with slightly different problem instances, numbers, and mathematical expressions. However, the concepts that are tested by these questions will not change on the exam.

Problems:

  1. [2] 6 n^2 log n + 2 n + 5 is in: (a) Θ( n^2 ). (b) O ( n^2 ). (c) O ( n^3 ). (d) Ω( n^3 ).
  2. [2] O (

p

n ) includes the functions: (a) (^12)

p

n and 0: 001 n. (b) 2

p

n log n and 2

p

n. (c) (^12)

p

n log n and (^12)

p

n. (d) 2

p

n and 10 log n.

  1. [2] If f ( n ) is in Θ( nE^ ), then: (a) f ( n ) is in O ( nE^ ) but not in Ω( nE^ ). (b) f ( n ) is in Ω( nE^ ) but not in O ( nE^ ). (c) f ( n ) is in O ( nE^ ) and also in Ω( nE^ ). (d) All of the above are possible, depending on f and E.
  2. [2] If f ( n ) is in Θ( g ( n )) and lim n !∞ f ( n ) g ( n ) exists, then^ some possible^ values for this limit are: (a) 10 and 100. (b) 0 and 100.

(c) 10 and ∞.

(d) 0, 1 and ∞.

5. [2]

n

k = 1

k log 2 ( k ) is in: (a) Θ( n log( n )). (b) Θ( k log 2 ( k )). (c) Θ( n^2 log( n )). (d) Θ( k^2 log 2 ( k )).

6. [2]

n

i = 0

i^2 is in: (a) Θ( n^4 ). (b) Θ( n^3 ). (c) Θ( n^2 log n ). (d) Θ( n^2 ).

  1. [2]

K

j = 1

3 j^ is in

(a) Θ( 14 K^4 ) (b) Θ( 12 K^2 )

(c) Θ( 2  3 K^ )

(d) Θ( 3  2 K^ )

  1. [2] 2 n log n + 2 n + 5 is in: (a) Ω( n^2 ). (b) O ( n^2 ). (c) O ( n ). (d) Θ( n ).
  2. [2] If f ( n ) is in Θ( nE^ ), then: (a) f ( n ) is in O ( nE^ ) and also in Ω( nE^ ). (b) f ( n ) is in Ω( nE^ ) but not in O ( nE^ ). (c) f ( n ) is in O ( nE^ ) but not in Ω( nE^ ). (d) All of the above are possible, depending on f and E.
  3. [2] O (

p

n ) includes the functions: (a) 2

p

n and 10 log n.

(b) 2p n log n and 2p n.

(c) 12 p n log n and 12 p n.

(d) (^12)

p

n and 0: 001 n.

  1. [2]

2 n

i = 2

i is in: (a) Θ( n ). (b) Θ( n^2 ). (c) Θ( n^2 log n ). (d) Θ( n^3 ).

  1. [2]

2log 2 ( n )

j = 1

2 j^ is in (a) Θ( 2 j^ ) (b) Θ( 2 n ) (c) Θ( n^2 ) (d) Θ((log 2 ( n ))^3 )

The following questions are based on the Red-Black tree shown below, using the standard Red-Black tree insertion algorithm and the standard binary search tree deletion algorithm.

23

11

7

6 9 14

17 25

27

black

red

red

red

black

black

red red

black

  1. [2] After inserting 8 into the tree, what node is at the root? (a) 25 (b) 23 (c) 17 (d) 11
  2. [2] After inserting 8 into the tree, which nodes are black? (a) 11, 6, 9, 17, 27. (b) 7, 8, 11, 9, 14, 23. (c) 7, 8, 14, 23, 25. (d) 11, 6, 9, 7, 27, 25.
  3. [2] What is the worst-case time complexity for an insert operation on a red-black tree with n nodes? (a) Θ( 1 ) (b) Θ(log n ) (c) Θ( n log n ) (d) Θ( n^2 )
  4. [2] What is the worst-case time complexity for a delete operation on a red-black tree with n nodes? (a) Θ( 1 ) (b) Θ( n ) (c) Θ(log n ) (d) Θ( n log n )

The following questions are based on the binary search tree tree shown below, using the standard binary search tree deletion algorithm. 23

11

7

6 9 14

17 25

27

  1. [2] After deleting 23 with the standard binary-search-tree algorithm, what node is at the root? (a) 11 (b) 25 (c) 27 (d) 14

25. [2] After deleting 23 with the standard binary-search-tree algorithm, what parent! child node pair does not

occur in the tree?

(a) 25! 27

(b) 27! 11

(c) 11! 7

(d) 7! 9