- Dictionaries Complete Test Bank Chapter 20 5th Edition - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.
Chapter 20 - Dictionaries
True/False (17)
- In the ADT dictionary, search keys and values are paired.
- The ADT dictionary organizes and identifies its entries by position.
- Every entry in a dictionary has a search key.
- Each entry in a dictionary may only have one key.
- The ADT dictionary requires sorted entries.
- Whether a dictionary has sorted or unsorted search keys is an implementation detail.
- You can traverse the dictionary by search keys but not by values.
- Restricting the ADT dictionary to distinct search keys simplifies the implementation of the remove method.
- The ADT dictionary does not permit key-null pairs.
- A key that has no value associated with it does not appear in the dictionary.
- You cannot traverse a dictionary by both the keys and values in parallel.
- You can traverse all the keys in a dictionary without traversing the values.
- You cannot traverse all the values in a dictionary without traversing the keys.
- A sorted dictionary must use search keys that belong to a class that implements the interface Comparable.
- The default delimiter for the class Scanner is a white-space character.
- Duplicate search keys are not permitted in a dictionary that conforms to the Java Class Library Map interface.
- When using a Scanner object to process text, you can specify any character as a delimiter.
Short Answer (8)
- Write a statement to create an instance of a class Dictionary that implements DictionaryInterface. Your dictionary contains Word objects that are lists of synonyms for words. The key value is a String representing the word to look up. Call your dictionary thesaurus.
- Write a statement to create a key iterator for a dictionary called thesaurus that is an instance of the class Dictionary and implements DictionaryInterface. The search keys are strings and the values stored are Word objects.
- Write a statement to create a value iterator for a dictionary called thesaurus that is an instance of the class Dictionary and implements DictionaryInterface. The search keys are strings and the values stored are Word objects.
- Malware files are often identified by hash values to uniquely identify the files. Create an instance of an empty dictionary called malware that is a class Dictionary that implements DictionaryInterface. Your dictionary will contain strings for the name of the malware. It will use MDHash objects that contain the hash value as search keys for the malware names.
- Malware files are often identified by hash values to uniquely identify the files. Given a dictionary called malware that is an instance of the class Dictionary and implements DictionaryInterface with key-value pairs of type String for the filename and MDHash objects for the search key, write a Java statement that adds a malware name that is the string “TrojanDropper” that has an MDHash search-key “55ad340609f4b30”.
- Malware files are often identified by hash values to uniquely identify the files. Given a dictionary called malware that is an instance of the class Dictionary and implements DictionaryInterface with key-value pairs of type String for the filename and MDHash objects for the search key, write a Java statement that prints the malware associated with the MDHash value “ce54b67080280d1e”. You may assume that the search key is in the dictionary.
System.out.println(“Malware name is “ + malware.getValue(hash));
- Malware files are often identified by hash values to uniquely identify the files. Given a dictionary called malware that is an instance of the class Dictionary and implements DictionaryInterface with key-value pairs of type String for the filename and MDHash objects for the search key, write a Java statement that prints the malware associated with the MDHash value “ce54b67080280d1e”. You may not assume that the search key is in the dictionary.
if (malware.contains(hash))
System.out.println(“Malware name is “ + malware.getValue(hash));
else
System.out.println(“Malware is not present in the dictionary.”);
- Malware files are often identified by hash values to uniquely identify the files. Given a dictionary called malware that is an instance of the class Dictionary and implements DictionaryInterface with key-value pairs of type String for the filename and MDHash objects for the search key, write a Java statement that removes and prints an entry from the dictionary given an MDHash object called trojan.
Multiple Choice (22) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.
- The ADT dictionary is also known as a(n)
- map
- table
- associative array
- all of the above
- The ADT dictionary has a keyword that is commonly called a(n)
- search key
- master key
- value
- all of the above
- The ADT dictionary contains entries that have a(n)
- search key
- value
- both a & b
- none of the above
- In an ADT dictionary, you use a(n) _____ to locate values.
- search key
- search value
- both a & b
- none of the above
- The ADT dictionary is organized
- by key-value pairs
- by position
- in ascending order
- randomly
- A typical operation of an ADT dictionary is
- add a new entry given a search key and value
- remove an entry given a search key
- retrieve a value associated with a search key
- all of the above
- A typical operation of an ADT dictionary is
- determining if the dictionary contains a specific search key
- traversing the dictionary by search keys
- traversing the dictionary by values
- all of the above
- A typical operation of an ADT dictionary is
- traversing the dictionary by values
- removing an entry given a value
- both a & b
- none of the above
- A useful operation that might be added to the ADT dictionary is
- detecting if the dictionary is empty
- retrieving the number of dictionary entries
- removing all entries from the dictionary
- all of the above
- What ADT dictionary method creates an iterator that traverses all search keys in the dictionary?
- getKeyIterator
- keyIterator
- getKeys
- getIterator
- What ADT dictionary method creates an iterator that traverses all the values in the dictionary?
- getValueIterator
- getValue
- valueIterator
- getIterator
- In the ADT dictionary, a key-null pair
- is not stored
- is inserted at the beginning of the dictionary
- is inserted at the end of the dictionary as a reserve entry
- is stored by key-value
- In the ADT dictionary, you can traverse
- all of the search keys without traversing the values
- all of the values without traversing the search keys
- all of the search keys and all of the values in parallel
- all of the above
- If you create a keyIterator and a valueIterator for the same dictionary, the keyIterator is _____ the valueIterator.
- the same length as
- larger than
- shorter than
- none of the above
- A sorted dictionary must use search keys that belong to a class that implements the interface
- Comparable
- Sortable
- Equals
- Searchable
- The class Scanner can break a string into substrings called
- tokens
- characters
- delimiters
- scanbits
- The class Scanner can break a string into substrings that are separated by
- delimiters
- separators
- tokens
- parsers
- Which method in the class Scanner extracts the tokens from any string?
- next
- tokenize
- split
- extract
- In an ADT dictionary that implements DictionaryInterface, what is returned by the getValue method if the associated search key is not found?
- it returns null
- it returns 0
- it returns false
- it throws a KeyNotFoundException
- A(n) _____ provides the line numbers in a document for each occurrence of a given word.
- concordance
- index
- word counter
- line counter
- In a concordance, the search keys are
- words
- line numbers
- word counts
- character counts
- In a concordance, the values associated with the search keys are
- a list of line numbers where a word appears
- the number of occurrence of a word in the document
- the definition of the word
- all of the above
Document Information
Connected Book
Data Structures with Java 5e Complete Test Bank
By Frank M. Carrano
Test Bank
General
View Product →
Explore recommendations drawn directly from what you're reading
Quick Navigation
Benefits
Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party