Docsity

Linked Structrue and OOP Basic-General Computer Science-Exam Solution, Exams of Computer Science

Toggle sidebar
bg1
COS 126 Written Exam 2 Solution, Spring 2008
1. Binary Search. The statements below explain why using binary search makes sense.
A. It is typically much faster than sequential search.
C. When data is sorted, it is easy to cut the amount of data to search in half.
2. Postfix. 6 5 4 * 3 2 1 + * + +
6 20 3 2 1 + * + +
6 20 3 3 * + +
6 20 9 + +
6 29 +
35
3. Regular expressions. The strings below are in the language described by the regular
expression:
a*bb(ab|ba)*
A. abb
D. bbbaab
4. Linked structures.
a) does not match any of the methods. Note that a call with the number "7" would infinite
loop for method f().
b) f()
c) g()
d) h()
May 1, 2008
docsity.com
pf3

Partial preview of the text

Download Linked Structrue and OOP Basic-General Computer Science-Exam Solution and more Exams Computer Science in PDF only on Docsity!

COS 126 Written Exam 2 Solution, Spring 2008

  1. Binary Search. The statements below explain why using binary search makes sense.

A. It is typically much faster than sequential search.

C. When data is sorted, it is easy to cut the amount of data to search in half.

  1. Postfix. 6 5 4 * 3 2 1 + * + +

6 20 3 2 1 + * + +

6 20 3 3 * + +

6 20 9 + +

6 29 +

35

  1. Regular expressions. The strings below are in the language described by the regular expression:

abb(ab|ba)

A. abb

D. bbbaab

  1. Linked structures.

a) does not match any of the methods. Note that a call with the number "7" would infinite loop for method f().

b) f()

c) g()

d) h()

May 1, 2008

  1. OOP terminology.

a) 3 instance variable declaration

b) 4 constructor signature

c) 19, 20 object creation

d) 6, 11 overloaded method signature

e) 21, 22 method invocation or call

f) 3, 18 primitive type variable declaration

g) 19, 20 reference type variable declaration

  1. Circuits.

a) The truth table.

a b c x 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0

b) Boolean Expressions equivalent to the circuit.

b. ab' + bc'

e. a'bc' + ab'c' + ab'c + abc'