CMSC 204 Midterm 2 Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Iterator

an object that provides functionality to iterate over all elements of a collection (ex. linear list)

The classes that implement Serializable but require special handling during serialization and deserialization, must give definitions to...

readObject and writeObject methods

How to remove an entry from a sorted array-based dictionary?

1. Locate the entry that is to be removed 2. Shift the contents of subsequent array locations toward the beginning of the array

Algorithm for Binary Search

1. Visit one element (middle element) 2. If not equal, then search the left or right sub-array If less than middle, search left. If greater than middle, search right. 3. Repeat until no more elements to search in left or right sub-array. This algorithm takes O(log2n).

Binary search vs. Sequential search

Binary search is faster than a sequential search on sorted array of data

What does it mean to "serialize" an object?

Copy an object to an output stream in a way that when deserialized, it maintains its structure (ex. binary tree)

HashSet vs. TreeSet (in terms of ordering)

One is ordered by the hash code, the other is ordered by the natural ordering of the objects being placed into the set.

Why does adding an element to an unsorted linked dictionary have an efficiency of O(n) when additions occur after the last node?

Preventing duplicate search keys requires a sequential traversal of the entire chain.

The advantage of storing data in binary format?

Records are all the same size so they are easy to access randomly and update.

Why can't I use the Comparable Interface with the Java Library Rectangle class. What would I need to use instead?

Rectangle class doesn't implement Comparable, and its definition cannot be changed as a Java library class. The Comparator interface should be used instead.

Why is the inner class iterator faster than separate class iterator?

The inner class has direct access to the list class private variables. The separate iterator must make ADT calls to the variables to access.

A sorted dictionary must use search keys that belong to a class that implements the interface Comparable

True

Most hash tables are not full

True

The implementation of the ADT list method "contains()" is dependent on how the entries in the list are stored.

True

The two ways to represent a set

explicitly - uses a bit vector implicitly - uses a List, usually sorted, to improve Big-O notation

The two categories for collision resolution

linear probing and buckets

external iterator

node and iterator classes are independent; iterators are created by calling the iterator method of the data structure

internal iterator

node and iterator classes are inner classes; iterators are created within the constructor of the data structure


संबंधित स्टडी सेट्स

Government Unit 1 Lesson 3 Part 1

View Set

group 1 insurance exam ch14 TX Health State Laws

View Set

Science & Engineering: 8.3 & 8.4: Solutions, Acids & Bases

View Set

finals sentences level 1 analysis

View Set

MARKETING MANAGEMENT EXAM 1 CH. 1-5

View Set