CSCI 142: Final Exam

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Serializable is the interface to implement to allow for serialization. Serialization is best describes as...

A technique for representing an object as a stream of binary digits, which allows objects to be read an written from files with their state maintained.

Match the following Queue operations with their descriptions. enqueue() dequeue() first()/peek() isEmpty() size() A. adds an element to the rear (tail) of the queue B. determines the number of elements in the queue C. removes an element from the front (head) of the queue D. determines if the queue is empty E. examines the element at the front (head) of the queue

A. adds an element to the rear (tail) of the queue C. removes an element from the front (head) of the queue E. examines the element at the front (head) of the queue D. determines if the queue is empty B. determines the number of elements in the queue

What is the purpose of Javadoc comments?

To prepare Java code for a tool that parses the code and generates web documentation automatically.

True or False: A Tree ADT is a nonlinear structure whose elements are organized into a hierarchy. The Tree can be implemented as a linked structure or array based.

True

An in-order traversal of a binary tree involves...

Visiting (or processing) each node's left child first, then the node itself, then its right child.

A stack is an example of a(n) ___

abstract data type

If you were to write your own abstract data type (ADT), it would be best to implement it as an _______________ , to ensure that it doesn't commit the methods to any particular implementation.

interface

An ___ is an object that allows the programmer to access and use elements of a collection one at a time.

iterator

The following arithmetic expression is an example of ___ notation.

postfix

A ___ is a unique collection of objects generally used to determine whether a particular element is a member of it, while a ___ is a collection of objects that can be retrieved using a unique key.

set map

Match the following terms with the most appropriate definition. complete tree balanced tree full tree general tree 1. An n-ary tree where all the leaves are at the same level and every node is either a leaf or has exactly n children. 2. A tree where all of the leaves of the tree are on the same level or at least within one level of each other. 3. A tree that has no limit on the number of children a node may have. 4. A balanced tree and all of the leaves at the bottom level are on the left side of the tree.

4. A balanced tree and all of the leaves at the bottom level are on the left side of the tree. 2. A tree where all of the leaves of the tree are on the same level or at least within one level of each other. 1. An n-ary tree where all the leaves are at the same level and every node is either a leaf or has exactly n children. 3. A tree that has no limit on the number of children a node may have.

What is an n-ary tree?

A tree that limits each node to no more than n children

Below are some methods of the java.util.List ADT interface. Match the method name with its description. add(E element) add(int index, E element) get(int index) remove(int index) remove(E object) size() A. Removes the element at the specified index. B. Returns the element at the specified index. C. Appends an element to the end of the list. D. Removes the first occurrence of the specified object. E. Returns the number of elements in the list. F. Inserts an element at the specified index.

C. Appends an element to the end of the list. F. Inserts an element at the specified index. B. Returns the element at the specified index. A. Removes the element at the specified index. D. Removes the first occurrence of the specified object. E. Returns the number of elements in the list.

Which of the following example use cases for Sets and Maps were demonstrated in the required reading of Chapter 22?

Domain Blocker: A program that checks to see which web site domains are blocked Product Sales: A program that keeps track of which products (and how many) were sold

A popular example of recursion and algorithm complexity is highlighted by a puzzle called the Towers of _____________ , published by mathematician Edouard Lucas in the 1880s, and believed to be adapted from ancient religious lore. It consists of three upright pegs (towers) and a set of disks with holes in the middle so that they slide onto the pegs. Each disk has a different diameter. The goal of the puzzle is to move all disks from one peg to another by moving only one disk at a time and never placing a larger disk on top of a smaller disk.

Hanoi

Regarding abstract data types and data structures, complete the following relationship. ArrayList is to List, as _____________ is to Map.

HashMap

___ is an interface used to define an object that can be used as an iterator. ___ is an interface used to define a collection from which an iterator can be extracted.

Iterator Iterable

___ are the primary alternative to an array-based implementation of a collection. They are composed of a linear collection of objects that each point to the next object. Often these individual objects in the collection are referred to as ___. And because each one of these objects points to an object of the same type, they are often referred to as being ___.

Linked Lists nodes self-referential

Which of the following topics are discussed in the required reading of Chapter 15?

List implementations The List ADT

Lists are linear collections where elements can be added to and removed from any point in the list. There are generally three types of lists. ___ lists keep elements sorted by some inherent characteristic of the elements, such as an ascending list of integers. ___ lists have no inherent characteristics to keep the elements sorted, but rather are ordered only by their placement in the list. ___ lists can be referenced using a numeric index.

Ordered unordered indexed

The Java Collections Framework provides two data structure implementations of the __________ abstract data type: TreeSet and HashSet.

Set

Which of the following management algorithms are mentioned / discussed in the required reading of Chapter 13?

inserting elements into a list removing elements from a list accessing elements of a list

FIFO = first in, first out LIFO = last in, first out A stack is a ___ whose elements are added to, and removed from, the same end, and in general if processed in a ___ manner.

linear collection LIFO

Which of the following problems can be solved recursively? Recursion may or may not be the best solution, but if a recursive solution is possible for a problem below, then select it. Select all that apply.

Traversing a maze Printing a string backwards Computing the Fibonacci sequence Summing the integers between 1 and N Computing a factorial

True or False: Each recursive call to a method creates new local variables and parameters that exist in the scope of that method invocation.

True

True or False: Elements in a Java collection are typically organized in terms of the order of their addition to the collection or in terms of some inherent relationship among the elements.

True

True or False: Tree height can be described as: "the length of the longest path from the root to a leaf".

True

Any recursive definition must have a non-recursive part, called the _______________, that permits the recursion to eventually end.

base case

The Java Collections Framework does not provide a data structure class that implements an ordered list. Instead, the programmer is responsible for ordering the elements if desired. One way to accomplish this is to have the objects in the list implement the _____________ interface, so that when adding an element to an ordered list, it can be compared with existing elements and then placed in the appropriate spot.

comparable

A(n) ___ is an object that defines an unusual or erroneous situation. It is ___ by a program or the run-time environment, and can be ___ and handled appropriately.

exception thrown caught

True or False: A Map is a collection that establishes a one-to-one mapping between unique keys and values. In other words, each key must map to a single value, and no two keys can map to the same value.

false

Suppose we want to formally define a list of one or more numbers separated by commas. Such a list can be defined recursively. Complete the formal recursive list definition formula below. A list consists of the following two possibilities: Base case part: ___ // for any list of 1 elementRecursive part: ___ // for any list longer than 1 element Here are examples of such lists that meet the recursive definition above:1, 2, 342128, 256, 512, 10241, 1, 2, 3, 5, 8, 139001

number number comma list

Recall that an object ___ type variable holds the address (or ID) of an object in memory. Usually the specific address (or ID) that the variable holds is irrelevant. In other words, even though it is important to be able to use this variable to access an object, the specific memory address (or ID) of where the object is stored in memory is unimportant. Thus, this variable is just an identifier that "points to" an object in memory, and therefore is sometimes referred to as a ___.

reference pointer

A linked implementation of a ___ adds elements to, and removes elements from, one end of a linked-list.

stack

A ___ is the ideal abstract data type to use when evaluating a ___ expression.

stack postfix


Ensembles d'études connexes

Neonate assessment - Integumentary/skin - Normal findings

View Set

CH. 17 Maternal Newborn Transitioning PREP U

View Set

цивілочка модуль 2

View Set

Chapter 9 - Other Health Insurance Concepts

View Set