DUKE UNIVERSITY
Department of Computer Science
Test 1 Solutions: CompSci 100e
PROBLEM 1 :
(Short Ones (12 points)
A. Give two distinct advantages of using an ArrayList (e.g. ArrayList<String> list) ve
DUKE UNIVERSITY
Department of Computer Science
Test 1 Review Solutions: CompSci 201
PROBLEM 1 :
(Short Ones)
A. Give brief examples where one would be more appropriate that the other.
For example
Dat
DUKE UNIVERSITY
Department of Computer Science
Test 1 Review: CompSci 201
During the test, you may consult your one (1) sheet of notes and no other resources. You may not use any
computers, calculator
DUKE UNIVERSITY
Department of Computer Science
Test 1: CompSci 100e Solutions
PROBLEM 1 :
(Short Ones (18 points)
A. [4pts] For each of the following objectoriented programming terms, summarize the d
DUKE UNIVERSITY
Department of Computer Science
Test 1 Solutions: CompSci 100e
PROBLEM 1 :
(Short Ones (30 points)
A. [9pts] For each of the following statements, state whether the statement is true or
CS201 Discussion 2
TODAYS TOPIC: A GENERAL APPROACH FOR SOLVING
PROBLEMS IN CS201
Never Lose Your Work!
We are going to quickly teach you how to use Duke Box to back
up your files.
This way, you shoul
CS 201 Discussion 9
BSTS + RECURSION
BST review
A binary search tree is:
A tree (a group of nodes, where one is the root and every other node is some other nodes child)
Binary (each node has a left
CS 201 Discussion 5
BIGOH REVIEW
A step by step approach to finding BigOh
runtime
You learned about BigOh in lecture on Friday. Heres a summary of how you can find the BigOh
runtime of a snippet o
Discussion 11
APT REVIEWS AND GRAPH ALGORITHMS
Before we begin
Any questions on Autocomplete? Well have time in discussion where if you were able to
complete APT Set 6 without issue, you can work on A
Discussion 1 Getting Started
This discussion is just about getting you up to speed with the tools.
Installing eclipse and ambient
Follow all of the instructions to install eclipse with the ambient plu
CS201 Discussion 7
MARKOV AND RECURSION
Before we begin
Any questions about the midterm solutions?
Making a Markov Map
Recall that in Markov, were trying to make a map of all kgrams to all kgrams th
CS201 Discussion 8
RATROUTE + LINKEDLISTS
RatRoute continued
Last discussion, we talked about how RatRoute, and how the number of paths from any point to
the cheese is the sum of the number of paths f
CS201 Discussion 10
DRAWTREE + TRIES
DrawTree
First instinct: recursion
As a very generic structure, we could tackle this problem as follows:
draw():
Find the root
draw(root)
draw(root):
Write the lin
CS 201, Test 1 Name:
Net ID:
Discussion Time:
Place:
1. Comm Std (1) 2. Callback (3) 3. Big Oh (15) 4. Analysis (20) 5. Maps (16) 6. Sorting (20) Total (75)
Tip: Use the topics list above to pick topi
CompSci 201, Spring 2015: Test 2
Name:
Net ID:
Recitation Room: _ & Time: _
(1 point) Community Standard acknowledgment (signature):
1. 6
2. 5
3. 6
4. 6
5. 6
6. 5
7. 4
Write your name on each sheet an
CompSci 201 Rocks!
Data Structures
and
Algorithms
Fun before Work
Connect with your neighbors:
Which colleges did you consider?
Why did you choose Duke?
Go to the class webpage under Sakai
CompSc
CS201 Discussion 12
HUFFMAN + ERDOSNUMBERS
Huffman Compression
Today, well walk through an example of Huffman compression. In Huffman compression, there
are three steps:
1. Create a Huffman tree
2. Ge
CS201 Discussion 4
Debugger, JohnSort
1
Using the Debugger
Ambient help page on the Eclipse Debugger
Eclipse documentation on Debug View
Debugging Advice
Using the Debugger
Using the Debugger
Step Ove
DUKE UNIVERSITY
Department of Computer Science
Test 2 Solutions: CompSci 100e
PROBLEM 1 :
(Short Ones (9 points)
A. Explain briey (i.e. one sentence can be enough) why the following optimizations are
DUKE UNIVERSITY
Department of Computer Science
Test 2 Solutions: CompSci 100e
PROBLEM 1 :
(Hash (6 pts)
In the Markov assignment, the WordNgram class encapsulated N words/strings so that the group of
Control structures: if(Boolean)/else/while/dowhile/for/break
Runtime/Bigoh/Recurrence: loop n times, recurse n
times = O(n), recursion: continuously compute value (ex:
recurrence = T(n/2), for merges
Eric Tang
CS201 Midterm 2
Sorting

Selection Sort: Find minimum value in array and exchange with first entry, then repeat again
o
Uses N2/2 compares and N exchanges to sort array of length N
Insertio
CS201 Midterm 2
Sorting
Selection Sort: Find minimum value in array and exchange with first entry, then repeat again
o
Uses N2/2 compares and N exchanges to sort array of length N
Insertion Sort: Inse
DUKE UNIVERSITY
Department of Computer Science
Test 1: CompSci 201
Name (print):
Community Standard acknowledgment (signature):
Problem 1
value
14 pts.
Problem 2
22 pts.
Problem 3
6 pts.
Problem 4
11
DUKE UNIVERSITY
Department of Computer Science
Test 1 Solutions: CompSci 201
PROBLEM 1 :
(Short Ones (14 points)
A. [9pts] Give brief examples where one would be more appropriate that the other.
For e
Comp Sci 1: Sample Final
Page 1 of 15
Comp Sci 1: (Sample) Final Exam
CLOSED BOOK
90 min Final Exam
NAME_Net ID_
DISCLAIMER!
This is a sample final used previously. You can use it to see the kind
of q
Test 2
NetID:
13
Throughout this test, assume that the following classes and methods are available. These classes are taken
directly from the material used in class. There should be no methods you hav