The purpose of a symbol table is to store a fixed collection of symbols. The pur
ID: 3585007 • Letter: T
Question
The purpose of a symbol table is to store a fixed collection of symbols.
The purpose of a symbol table is to store a fixed collection of symbols.
True
False
Which of the following is not a method in the symbol table class?
a) void put(Key key, Value val)
b) boolean contains(Key key)
c) void sort()
d) Value get(Key key)
If a key value pair is inserted in a symbol table and the key is already in the table, what happens?
a) an exception occurs.
b) the new value replaces the old value.
c) both the old value and the new value are associated with the same key.
d) Nothing happens; the value associated with the key is unchanged.
Match the symbol table class from section 3.1 with its implementation.
BinarySearchST
SequentialSearchST
1.
unordered linked list
2.
ordered linked list
3.
unordered array
4.
ordered array
If a key k is not already in a SequentialSearchST symbol table, inserting the key value pair(k,v) has order of growth O(1) even in the worst case.
True
False
If a key k is not already in a BinarySearchST symbol table, inserting the key value pair (k, v) has order of growth O(log(N)) even in the worst case.
True
False
Which implementation of get is faster?
a) SequentialSearchST's get
b) BinarySearchST's get
Information
The purpose of a symbol table is to store a fixed collection of symbols.
True
False
Which of the following is not a method in the symbol table class?
a) void put(Key key, Value val)
b) boolean contains(Key key)
c) void sort()
d) Value get(Key key)
If a key value pair is inserted in a symbol table and the key is already in the table, what happens?
a) an exception occurs.
b) the new value replaces the old value.
c) both the old value and the new value are associated with the same key.
d) Nothing happens; the value associated with the key is unchanged.
Match the symbol table class from section 3.1 with its implementation.
BinarySearchST
SequentialSearchST
1.
unordered linked list
2.
ordered linked list
3.
unordered array
4.
ordered array
If a key k is not already in a SequentialSearchST symbol table, inserting the key value pair(k,v) has order of growth O(1) even in the worst case.
True
False
If a key k is not already in a BinarySearchST symbol table, inserting the key value pair (k, v) has order of growth O(log(N)) even in the worst case.
True
False
Which implementation of get is faster?
a) SequentialSearchST's get
b) BinarySearchST's get
Information
Explanation / Answer
1)The purpose of a symbol table not only to store a fixed collection of symbols.
Answer:False
2)Answer:void sort()
c)void sort() is not a method in the symbol table class
Explanation
----------------
We have method void put(Key key, Value val)
Example:
-------
public void put(Key key, Value val)
{
if (val == null) { //If value is null then remove key from table
delete(key);
return;
}
We have method boolean contains(Key key)
Example:
--------
public boolean contains(Key key)
{
return get(key) != null;
}
We have method Value get(Key key)
Example:
---------
public Value get(Key key)
{
for (int i = 0; i < P; i++)
if (keys[i].equals(key))
return vals[i];
return null;
}
3)If a key value pair is inserted in a symbol table and the key is already in the table, what happens?
Answer: b) the new value replaces the old value.
4)Answer:
BinarySearchST
1.
unordered linked list
2.
ordered linked list
SequentialSearchST
3.
unordered array
4.
ordered array
5)If a key k is not already in a SequentialSearchST symbol table, inserting the key value pair(k,v) has order of growth O(1) even in the worst case.
Answer: True
6)If a key k is not already in a BinarySearchST symbol table, inserting the key value pair (k, v) has order of growth O(log(N)) even in the worst case.
Answer: False
7)Answer:SequentialSearchST's get implementation is faster.
-----------------------------------------------------------------------------------------------------------------
Hope this will helps you...............
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.