• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 3 out of 20 pages
Exam (elaborations)

C212 Comprehensive Exams Updated Questions And Answers Sure A.pdf

Document preview thumbnail
Preview 3 out of 20 pages

C212 COMPREHENSIVE EXAMS UPDATED QUESTIONS AND ANSWERS SURE A.pdf

Content preview

C212 COMPREHENSIVE EXAMS UPDATED
QUESTIONS AND ANSWERS SURE A+
✔✔What is a hash function? What is a good hash function? - ✔✔A hash function
computes an integer value from an object. A good hash function minimizes collisions --
identical hash codes for different objects.

✔✔Define: stack - ✔✔A stack is a collection of elements with LIFO ("last-in, first-out")
retrieval.

✔✔Define: queue - ✔✔A queue is a collection of elements with FIFO ("first-in, first-out")
retrieval.

✔✔Define: priority queue. - ✔✔A priority queue collects elements, each of which has a
priority (e.g., collection of work requests, some of which may be more urgent than
others). In a priority queue elements can be added in any order, but when an item is
retrieved it is the one with the most urgent priority.

✔✔Why would you want to declare a variable as Queue<String> q = new LinkedList<>()
instead of simply declaring it as a linked list? - ✔✔This way, we can ensure that only
queue operations can be invoked on the q object.

,✔✔Why wouldn't you want to use an array list for implementing a queue? -
✔✔Depending on whether you consider the 0 position the head or tail of the queue, you
would either add or remove elements at that position. Both are
inefficient operations because all other elements need to be moved

✔✔Why wouldn't you want to use a stack to manage print jobs? - ✔✔Stacks use a LIFO
discipline. If you are the first one to submit a print job and lots of people add print jobs
before the printer has a chance to deal
with your job, they get their printouts first, and you have to wait until all other jobs are
completed.

✔✔What does this code print?

Queue<String> q = new LinkedList<>(); // FIFO!
q.add("A");
q.add("B");
q.add("C");
while (q.size() > 0) { System.out.print (q.remove() + " " ); } - ✔✔ABC

✔✔What is the value of the reverse Polish notation expression 2 3 4 + 5 * *? - ✔✔(2, 3,
4, +) -> (2, 7, 5 *) -> (2 35 *) -> (70)

✔✔What steps does the selection sort algorithm go through to sort the sequence 6 5 4
3 2 1 ? - ✔✔1 | 5 4 3 2 6
12|4356
123456

✔✔Define: selection sort algorithm. - ✔✔A sorting algorithm rearranges the elements of
a collection so that they are stored in sorted order.

✔✔Define: big-Oh notation. - ✔✔Computer scientists use the big-Oh notation to
describe the growth rate of a function.

✔✔Define: binary search. - ✔✔A binary search locates a value in a sorted array by
determining whether the value occurs in the first or second half, then repeating the
search
in that half, until we either find the value or we determine it's not there at all.

✔✔Suppose you need to look through 1,000,000 records to find a telephone number.
How many records do you expect to search before finding the number? - ✔✔On
average, you'd make 500,000 comparisons

✔✔Suppose you need to look through a sorted array of 1,000,000 records to find a
telephone number. Using the binary search algorithm how many records do you expect

, to search before finding the number? - ✔✔You would search about 20 times (The binary
log of 1024 is 10)

✔✔Why can't the Arrays.sort method sort an array of Rectangle objects? - ✔✔The
Rectangle class does not implement the Comparable interface.

✔✔When designing a program how do you decide what classes you will need in your
program? - ✔✔To discover classes, look for nouns in the problem description. Concepts
from the problem domain are good candidates for classes.

✔✔Define: inheritance - ✔✔Inheritance (is-a) is a relationship between a more general
class (the superclass) and a more specialized class (the subclass). Inheritance
is sometimes abused.

✔✔Define: aggregation (also called composition). - ✔✔Aggregation (the has-a
relationship) often can be used with better results. It denotes that objects of one class
contain
references to objects of another class.

✔✔Why should coupling be minimized between classes? - ✔✔It is a good practice to
minimize the coupling (i.e., dependency) between classes. If the change to a class is
drastic, all the classes that
depend on it (the coupled classes) must be updated. Furthermore if we want to use a
class in another program all the classes on which it depends
need to be taken as well. Therefore we always want to remove unnecessary coupling
between classes.

✔✔You are implementing a system to manage a library, keeping track of which books
are checked out by whom. Should the Book class aggregate Patron or the other way
around? - ✔✔Patron aggregate Book

✔✔What is javadoc? Where should you use javadoc comments? - ✔✔Comments with
method bodies left blank that record behavior of the class. Source file for methods that
are found.

✔✔What is UML? - ✔✔To visualize relationships between classes, such as
dependence, programmers draw class diagrams. In the textbook we use the UML
("Unified Modeling
Language") notation for objects and classes. UML is a notation for object-oriented
analysis and design invented by Grady Booch, Ivar Jacobson, and
James Rumbaugh

✔✔Define: CRC cards. - ✔✔CRC stands for "classes", "responsibilities" and
"collaborators". Use an index card for each class. As you think about about verbs in the
task

Document information

Uploaded on
July 14, 2026
Number of pages
20
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$16.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
BOARDWALKer
3.4
(19)
Sold
162
Followers
6
Items
26749
Last sold
16 hours ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions