Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping.
True/False (13)
Chapter 14 - A List Implementation that Links Data
Adding a node to an empty chain is the same as adding a node to the beginning of a chain.
Adding a node at the end of a chain of n nodes is the same as adding a node at position n.
You need a temporary variable to reference nodes as you traverse a list.
The efficiency of the displayList method is directly related to the efficiency of the getEntry
method.
You cannot use an assert statement to determine of a list is empty.
A fundamental operation of a list is a traversal.
You must know how much memory to allocate before creating a linked implementation of a list.
A linked implementation of a list grows and shrinks dynamically as nodes are added and deleted.
In a linked implementation of a list, you only call the method getNodeAt when we remove an
entry other than the first one.
Replacing a node in a linked implementation of a list only requires locating the node and
replacing the data portion of the node.
In a linked implementation of a list, the replace method replaces the entire node.
Retrieving a list entry using a linked implementation is faster than using an array representation.
Replacing a list entry using an array implementation is faster than using a linked representation.
Short Answer (6)
Explain why a public method should be declared to be final if it is called by a constructor.
In the linked implementation of a list, why shouldn’t the constructor call the method clear even
though they do the same exact assignment statements?
Outline the basic steps to add a node to the end of a linked implementation of a list.
Outline the basic steps to add a node to the beginning of an empty linked implementation of a
list.
Outline the basic steps to add a node to the beginning of a non-empty linked implementation of
a list.
Outline the basic steps to remove a node from the beginning of a list.
Multiple Choice (30)
1. A linked implementation of a list
uses memory only as need for new entries
returns unneeded memory to the system when an entry is removed
avoids moving data when adding or removing entries
all of the above
In a chain of linked nodes you can
add nodes from the beginning of a chain
add nodes from the end of a chain
add nodes that are between other nodes
all of the above
In a chain of linked nodes you can
remove nodes from the beginning of a chain
remove nodes from the end of a chain
remove nodes that are between other nodes
all of the above
If a chain is empty, the head reference
is null
is an empty node with the data field not set
is in an illegal state
none of the above
When
the node before the insertion position and the node after the insertion position
the first node and the node before the insertion position
the first node and the node after the insertion position
the last node and the node after the insertion position
Adding a node at the end of a chain of n nodes is the same as adding a node at position a. n+1
b. n
c. n–1 d. 0
If the reference to the first node is null, this means
the list is empty
the list is full
the garbage collector should be invoked
the list is in an unstable state
The last node is a list has a reference to
null
itself
the node before it
none of the above
inserting a node between adjacent nodes in a chain you must locate
9. To locate a node within a chain that is near the end of the list, we must
start at the first node and traverse the chain
start at the last node and traverse the chain
directly access the node
none of the above
10. Moving
a. traversing
through a linked implementation of a list from one node to another is called
walking
hopping
none of the above
11. In the LList implementation of a list, when a list is empty the firstNode is _____ and the numberOfEntries is _____.
a. b. c. d.
In the a. b. c. d.
In the
null, 0
null, 1
an empty node, 0 an empty node, 1
LList implementation of a list, the constructor and the clear
method have the same functionality
do completely different things
unnecessary
none of the above
linked implementation of a list, the add method public void add(T newEntry)
inserts a new entry
a. at the end of the list
b. at the beginning of the list
c. between adjacent nodes of the list d. all of the above
14. In the linked implementation of a list, the add method public void add(int newPosition, T newEntry)
inserts a new entry
between adjacent nodes of the list
at the end of the list
at the beginning of the list
all of the above
In the linked implementation of a list, what happens when you try to add a node at an invalid position?
it throws an IndesOutOfBoundsException
it throws an InvalidLinkException
it returns null
it returns false
To determine if a list is empty you can
a. check to see if the length of the list is zero
b. check to see if the reference to firstNode is null c. use an
assertion on firstNode == null
d. all of the above **
In the LList implementation of a list, given a node called currentNode, which statement moves
the node’s reference to the next node?
a. currentNode.getNextNode(); b. currentNode.get();
c. currentNode.forward();
d. currentNode.traverse();
A reference to the last node in a linked implementation of a list is commonly called the
tail
end
final
none of the above
Including a tail reference to a linked implementation of a list makes which functionality more efficient?
adding a node to the end of a list
searching for a node on the list
removing a node from the list
all of the above
In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if
the list only contains one entry
the list is empty
the list is full
all of the above
In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if
the list has multiple entries and the entry to be removed is the last one
the list has multiple entries and the entry to be removed is the first one
the list is empty
all of the above
In a linked-based implementation of the ADT list with only a head reference, what is the performance of adding an entry at the end of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of adding an entry at the end of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of adding an entry that is not at the beginning of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with only a head reference, what is the performance of removing an entry at the beginning of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with only a head reference, what is the performance of removing an entry at the end of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of removing an entry at the beginning of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of removing an entry that is not at the beginning of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with only a head reference, which method has a time efficiency of O(1)?
clear
toArray
contains
all of the above
In a linked-based implementation of the ADT list with a tail reference, which method has a time efficiency of O(1)?
adding an entry to the end of the list
adding an entry to the beginning of the list
clear
all of the above
Answers are in Bold
Adding a node at the end of a chain of n nodes is the same as adding a node at position n. True
You need a temporary variable to reference nodes as you traverse a list. True
The efficiency of the displayList method is directly related to the efficiency of the getEntry
method. False
You cannot use an assert statement to determine of a list is empty. True
A fundamental operation of a list is a traversal. True
You must know how much memory to allocate before creating a linked implementation of a list. False
A linked implementation of a list grows and shrinks dynamically as nodes are added and deleted. True
In a linked implementation of a list, you only call the method getNodeAt when we remove an
entry other than the first one. False
Replacing a node in a linked implementation of a list only requires locating the node and
replacing the data portion of the node.False
In a linked implementation of a list, the replace method replaces the entire node. True
Retrieving a list entry using a linked implementation is faster than using an array representation. True
Replacing a list entry using an array implementation is faster than using a linked representation. False
Outline the basic steps to remove a node from the beginning of a list.
Multiple Choice (30)
1. A linked implementation of a list
uses memory only as need for new entries
returns unneeded memory to the system when an entry is removed
avoids moving data when adding or removing entries
all of the above
In a chain of linked nodes you can
add nodes from the beginning of a chain
add nodes from the end of a chain
add nodes that are between other nodes
all of the above
In a chain of linked nodes you can
remove nodes from the beginning of a chain
remove nodes from the end of a chain
remove nodes that are between other nodes
all of the above
If a chain is empty, the head reference
is null
is an empty node with the data field not set
is in an illegal state
none of the above
When
the node before the insertion position and the node after the insertion position
the first node and the node before the insertion position
the first node and the node after the insertion position
the last node and the node after the insertion position
Adding a node at the end of a chain of n nodes is the same as adding a node at position a. n+1 b. n c. n–1 d. 0
If the reference to the first node is null, this means
the list is empty
the list is full
the garbage collector should be invoked
the list is in an unstable state
The last node is a list has a reference to
null
itself
the node before it
none of the above
inserting a node between adjacent nodes in a chain you must locate
9. To locate a node within a chain that is near the end of the list, we must
start at the first node and traverse the chain
start at the last node and traverse the chain
directly access the node
none of the above
10. Moving
a. traversing
through a linked implementation of a list from one node to another is called
walking
hopping
none of the above
11.linked implementation of a list, the add method public void add(T newEntry)
inserts a new entry
a. at the end of the list
b. at the beginning of the list
c. between adjacent nodes of the list
d. all of the above
14. In the linked implementation of a list, the add method public void add(int newPosition, T newEntry)
inserts a new entry
between adjacent nodes of the list
at the end of the list
at the beginning of the list
all of the above
In the linked implementation of a list, what happens when you try to add a node at an invalid position?
it throws an IndesOutOfBoundsException
it throws an InvalidLinkException
it returns null
it returns false
To determine if a list is empty you can
a. check to see if the length of the list is zero
b. check to see if the reference to firstNode is null c. use an
assertion on firstNode == null
d. all of the above **
In the LList implementation of a list, given a node called currentNode, which statement moves
the node’s reference to the next node?
a. currentNode.getNextNode(); b.
currentNode.get();
c. currentNode.forward();
d. currentNode.traverse();
A reference to the last node in a linked implementation of a list is commonly called the
tail
end
final
none of the above
Including a tail reference to a linked implementation of a list makes which functionality more efficient?
adding a node to the end of a list
searching for a node on the list
removing a node from the list
all of the above
In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if
the list only contains one entry
the list is empty
the list is full
all of the above
In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if
the list has multiple entries and the entry to be removed is the last one
the list has multiple entries and the entry to be removed is the first one
the list is empty
all of the above
In a linked-based implementation of the ADT list with only a head reference, what is the performance of adding an entry at the end of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of adding an entry at the end of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of adding an entry that is not at the beginning of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with only a head reference, what is the performance of removing an entry at the beginning of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with only a head reference, what is the performance of removing an entry at the end of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of removing an entry at the beginning of the list?
O(1)
O(log n)
O(n)
O(n2)
In a linked-based implementation of the ADT list with a tail reference, what is the performance of removing an entry that is not at the beginning of the list?
O(n)
O(n2)
O(log n)
O(1)
In a linked-based implementation of the ADT list with only a head reference, which method has a time efficiency of O(1)?
clear
toArray
contains
all of the above
In a linked-based implementation of the ADT list with a tail reference, which method has a time efficiency of O(1)?
adding an entry to the end of the list
adding an entry to the beginning of the list
clear
all of the above
Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up...
Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up for helping. True/False (11) Chapter 12 - Lists The ADT list only works for entries that are strings. The ADT list is more general than common lists and has entries that are objects of the same type. Adding entries to the end of a list does not change the positions of entries already in the list. The first entry is a list is at...
JAVA 3 LECTURE REVIEW PLEASE NEED ANSWERS ASAP. DUE IN AN HOUR!!! Question 12 points The best-case performance for a shell sort is: --- O(1) O(n2) O(n) O(n log n) Signaler cette question Question 22 points The best-case performance for an array of n items using insertion sort is: --- O(n2) O(n) O(1) there is no best-case Signaler cette question Question 3 2 points A recursive method that processes a chain of linked nodes --- uses the first node in...
please answer all questions thanks Question 21 Not yet In a linked-node implementation of a ADT, node does not reference the data in another node answered Points out of 2.00 Select one: True P Flag question False Question 23 Not yet An array implementation of an ADT potentially wastes more space than a linked implementation answered Points out of 2.00 Select one: True P Flag question False Question 25 Should Node be a public class? Briefly explain Not yet answered...
JAVA 3 PLEASE ANSWER AS MANY QUESTIONS AS POSSIBLE! ONLY 2 QUESTIONS LEFT THIS MONTH!!! Question 12 pts Which is a valid constructor for Thread? Thread ( Runnable r, int priority ); Thread ( Runnable r, String name ); Thread ( int priority ); Thread ( Runnable r, ThreadGroup g ); Flag this Question Question 22 pts What method in the Thread class is responsible for pausing a thread for a specific amount of milliseconds? pause(). sleep(). hang(). kill(). Flag...
Here is the IntegerLinkedList_incomplete class: public class IntegerLinkedList { static class Node { /** The element stored at this node */ private int element; // reference to the element stored at this node /** A reference to the subsequent node in the list */ private Node next; // reference to the subsequent node in the list /** * Creates a node with the given element and next node. * * @param e the element to be stored * @param n...
Data Structures - Singly Linked Lists You will add a method swapNodes to SinglyLinkedList class (below). This method should swap two nodes node1 and node2 (and not just their contents) given references only to node1 and node2. The new method should check if node1 and node2 are the same node, etc. Write the main method to test the swapNodes method. You may need to traverse the list. package linkedlists; public class SinglyLinkedList<E> implements Cloneable { // ---------------- nested Node class...
Problem 3 (List Implementation) (35 points): Write a method in the DoublyLList class that deletes the first item containing a given value from a doubly linked list. The header of the method is as follows: public boolean removeValue(T aValue) where T is the general type of the objects in the list and the methods returns true if such an item is found and deleted. Include testing of the method in a main method of the DoublyLList class. ------------------------------------------------------------------------------------- /** A...
In this lab, we will implement the Linked Bag. The bag will contain a sequence of strings. First, you need to design the Node class (Node.java). It will contain an integer data and a reference to thenext Node. The constructor of Node class receives an integer and assigns it to the data field. It also has a default constructor. Data Next Node Then we will design another class named LinkedBag (LinkedBag.java). LinkedBag class has an instance variable called firstNode of...
In Java The following Java implementation of a class Node is given: private class Node<Object> { Node() { this(null, null); } Node(Object d) { this(d, null); } Node(Object d, Node n) { data = d; next = n; } Object data; Node next; } Assume that a singly linked list is implemented with a header node, but no tail node, and that it maintains only a reference to the header node. Using the class Node described above, write a MySingleLinkedList...
i need to create methods that: append_element(self, val) This method should increase the size of the list by one, adding the specified value in the new tail position. This is the only way to add a value as the tail. insert_element_at(self, val, index) If the provided index identifies a valid zero-based position within the list, then insert the specified value at that position, increasing the length by one. This method can be used to insert at the head of a...