Sample Questions for CT/100 Exam #2
For Exercises 1 - 13 place the letter corresponding to the best answer to the left.
1. Which one of the following is an advantage of an indexed form of data organization by comparison to a
linked list organization?
a) It is easier to insert in the middle of an indexed organization than the middle of linked list.
b) Indexing doesn't require knowing a number in order to retrieve the content of a chunk of data.
c) Indexed organizations need not be fixed in overall size, while lists are fixed in size.
d) Indexed organizations don't require storage for links so they can make more efficient use of space.
2. Which of the following techniques and algorithms can be classified as divide and conquer
a)
b)
c)
d)
e)
3.
binary search
an algorithm distributed among many processors of a multi-core computer
a greedy algorithm
none of the above
all of a through c above
Computer files systems are organized using folders and files in which folders can contain files and/or other folders, but
no file or folder may exist directly within more than one other folder. This kind of organization is best described as
which of the following?
a) an indexed organization
b) a linked list
c) a tree
d) a graph other than a tree
e) a greedy
4. Arrange the following four algorithms by worst case performance, from the algorithm taking the shortest
time to execute to the one taking the longest time?
I. using a binary search to find your exam in a stack of 1000 alphabetized exams
II. using a linear search to find your exam in a stack of 500 exams
III. alphabetizing 500 exams
IV. an algorithm to crack a password of length 20 characters
5. What are the two different ways that computer programs can be analyzed for speed (performance)?
6. In the worst possible cases adding another item to the collection of items to be searched by linear search adds one more
probe to the count of probes required. (In other words using the example from class, a linear search of transcripts can
require one more transcript to be examined when one more transcript is added to the stack.) How many items
(transcripts) can be added and still be able to perform a binary search using just one additional probe?
7. Consider the sorting algorithm discussed in class that makes use of repeatedly finding the maximum. (Note that this
algorithm was compared to using single elimination tournaments to order teams from first to last.) Exactly how
many comparisons are used by this algorithm for alphabetizing (sorting) six items? (Please show how you
determined this number.)
Use the image of a spreadsheet above to complete Exercises 8 through 11.
8. What appears in the cell from Row 4 and Column C when you type the following formula in this cell?
=SUM(A1:B2)
9. What appears in the cell from Row 4 and Column A when you type the following formula in this cell?
=2 + 10 * (5 - 3)
10. What appears in the cell from Row 5 and Column B when you type the following formula in this cell?
=OR(A2+B2=74, B1>0)
11. What appears in the cell from Row 4 and Column D when you type the following formula in this cell?
=IF(B3<A3, A2, A2-B2)
12. Assume that in a particular spreadsheet each cell of row 8 from column B through column T contains the mileage
you have traveled for one of your driving trips. Further assume that each cell of row 9 from column B through
column T contains that amount of gasoline consumed for the trip in the cell directly above. Write the formula you
could type into the cell in row 10, column Z so that it displays the average miles per gallon for all of these driving
trips.
whale = "gray";
moby = "white whale";
orca = "killer";
keiko = "famous actor";
freeWilly = "orca[1]";
Assume that the four Javascript instructions above have just been executed in order to complete
Exercises 13 through 15.
13. List all of the variables that are present in the above five instructions.
154 The following Javascript expression evaluates to a specific string. What is it? (Please use the following typesetting
symbol to indicate any blanks in your answer: V )
moby.substring(4,7) + orca[1] + freeWilly + "ZZ"
15. Using all three of the following: indexing and substrings and concatenation (+), but no literals (i.e. nothing in quotes
or double quotes), write a single Javascript instruction that will assign to a variable called computer, the string
"geek".
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
Above is the first verse of a song entitled "Lasagna" by Weird Al Yankovic. For Questions 16 through
18 you should assume that this single verse is being analyzed as a text file using regular expression
pattern matching, similar to the files we analyzed in the most recent two CT100 labs.
16. Suppose the following pattern is applied to this file:
(a|e)t+|(, .)
In the repeated text below circle all of the substrings that would match the pattern.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
17. Suppose the following pattern is applied to this file:
.{3}o$
In the repeated text below circle all of the substrings that would match the pattern.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
18. Suppose the following pattern is applied to this file:
a[a-z]+a
In the repeated text below circle all of the substrings that would match the pattern.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
19. Suppose that you are annoyed by the colloquialism of "he goes" and "she goes" whether these phrases are at the
beginning of a sentence (so the first letter is capitalized) or not. Write a regular expression pattern that will match
exactly these two colloquialisms either at the beginning or in the midst of any sentence in a passage of text.
20. There are two notations that are commonly used with numbers. Accountants often enclose a number within
parentheses to indicate that it is negative. Secondly, large numbers are generally written with commas every three
characters from the right. For example, (302,174) means -302174 and 1,234,567 means 1234567. Write a pattern
that matches precisely any integer that uses these notations. More specifically, the string never uses a negative sign,
but might be enclosed in a single set of parentheses. Further, the string must use commas to separate each 3-digit
group, but never begins with a comma as the first character nor has commas closer than three digits apart.
Answers for Sample Questions for CT/100 Exam #2
For Exercises 1 - 13 place the letter corresponding to the best answer to the left.
1. d
2. e
3. c
4. I, II, III, IV
5. Benchmarking and analyzing with counting formulas
6.
Doubling the number of items (transcripts) increases the count of probes by just one.
7. 5 + 4 + 3 + 2 + 1 = 15
Five comparisons are needed to determine the largest number (like a five-game single elimination tourney).
Four comparisons are required to determine the second largest (a four-team tourney).
Three comparisons determine the third largest.
Two comparisons determine the fourth largest.
One last comparison determines both the fifth and sixth largest.
8. 18 (The sum of cells A1, A2, B1, and B2.)
9. 22
10. FALSE
11. 3 (The value of the formula A2-B2, because B3<A3 is false.)
12. There are several solutions. Perhaps the best is
=sum(B8:T8) / sum(B9:T9)
13. whale, moby, orca, keiko, and freeWilly
14. eVwiorca[1]ZZ
15. There are several solutions. This is one
computer = whale[0] + moby.substring(4, 5) + orca[4] + orca[0];
16.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
17.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
18.
La-la-la-la-lasagna
You want-a some-a lasagna magnifico
Or a-maybe spaghetti
Ay, you supper's a-ready now, where you go
Mama mia bambino
Mama mia bambino, 'samatta you
'Samatta you, 'samatta you
19. There are several solutions. Below are two
((S|s)?heV goes)|HeV goes
(She|she|he|He)V goes
20. There are several solutions. Below is a compact one
([0-9]{1,3}(,[0-9]{3})*|\([0-9]{1,3}(,[0-9]{3})*\)
© Copyright 2026 Paperzz