Question

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 (13)

Chapter 14 - A List Implementation that Links Data

  1. Adding a node to an empty chain is the same as adding a node to the beginning of a chain.

  2. Adding a node at the end of a chain of n nodes is the same as adding a node at position n.

  3. You need a temporary variable to reference nodes as you traverse a list.

  4. The efficiency of the displayList method is directly related to the efficiency of the getEntry

    method.

  5. You cannot use an assert statement to determine of a list is empty.

  6. A fundamental operation of a list is a traversal.

  7. You must know how much memory to allocate before creating a linked implementation of a list.

  8. A linked implementation of a list grows and shrinks dynamically as nodes are added and deleted.

  9. In a linked implementation of a list, you only call the method getNodeAt when we remove an

    entry other than the first one.

  10. Replacing a node in a linked implementation of a list only requires locating the node and

    replacing the data portion of the node.

  11. In a linked implementation of a list, the replace method replaces the entire node.

  12. Retrieving a list entry using a linked implementation is faster than using an array representation.

  13. Replacing a list entry using an array implementation is faster than using a linked representation.

Short Answer (6)

  1. Explain why a public method should be declared to be final if it is called by a constructor.

  2. 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?

  3. Outline the basic steps to add a node to the end of a linked implementation of a list.

  4. Outline the basic steps to add a node to the beginning of an empty linked implementation of a

    list.

  5. Outline the basic steps to add a node to the beginning of a non-empty linked implementation of

    a list.

  6. Outline the basic steps to remove a node from the beginning of a list.

Multiple Choice (30)

1. A linked implementation of a list

  1. uses memory only as need for new entries

  2. returns unneeded memory to the system when an entry is removed

  3. avoids moving data when adding or removing entries

  4. all of the above

  1. In a chain of linked nodes you can

    1. add nodes from the beginning of a chain

    2. add nodes from the end of a chain

    3. add nodes that are between other nodes

    4. all of the above

  2. In a chain of linked nodes you can

    1. remove nodes from the beginning of a chain

    2. remove nodes from the end of a chain

    3. remove nodes that are between other nodes

    4. all of the above

  3. If a chain is empty, the head reference

    1. is null

    2. is an empty node with the data field not set

    3. is in an illegal state

    4. none of the above

  1. When

    1. the node before the insertion position and the node after the insertion position

    2. the first node and the node before the insertion position

    3. the first node and the node after the insertion position

    4. the last node and the node after the insertion position

  2. 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

  3. If the reference to the first node is null, this means

    1. the list is empty

    2. the list is full

    3. the garbage collector should be invoked

    4. the list is in an unstable state

  4. The last node is a list has a reference to

    1. null

    2. itself

    3. the node before it

    4. 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

  1. start at the first node and traverse the chain

  2. start at the last node and traverse the chain

  3. directly access the node

  4. none of the above

10. Moving
a. traversing

through a linked implementation of a list from one node to another is called

  1. walking

  2. hopping

  3. 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.

  1. In the a. b. c. d.

  2. 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

  1. between adjacent nodes of the list

  2. at the end of the list

  3. at the beginning of the list

  4. all of the above

  1. In the linked implementation of a list, what happens when you try to add a node at an invalid position?

    1. it throws an IndesOutOfBoundsException

    2. it throws an InvalidLinkException

    3. it returns null

    4. it returns false

  2. 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 **

  3. 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();

  1. A reference to the last node in a linked implementation of a list is commonly called the

    1. tail

    2. end

    3. final

    4. none of the above

  2. Including a tail reference to a linked implementation of a list makes which functionality more efficient?

    1. adding a node to the end of a list

    2. searching for a node on the list

    3. removing a node from the list

    4. all of the above

  3. In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if

    1. the list only contains one entry

    2. the list is empty

    3. the list is full

    4. all of the above

  1. In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if

    1. the list has multiple entries and the entry to be removed is the last one

    2. the list has multiple entries and the entry to be removed is the first one

    3. the list is empty

    4. all of the above

  2. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  3. 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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  4. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  5. 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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  6. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  2. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  3. In a linked-based implementation of the ADT list with only a head reference, which method has a time efficiency of O(1)?

    1. clear

    2. toArray

    3. contains

    4. all of the above

  4. In a linked-based implementation of the ADT list with a tail reference, which method has a time efficiency of O(1)?

    1. adding an entry to the end of the list

    2. adding an entry to the beginning of the list

    3. clear

    4. all of the above

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answers are in Bold

  1. Adding a node to an empty chain is the same as adding a node to the beginning of a chain.  True
  2. Adding a node at the end of a chain of n nodes is the same as adding a node at position n. True

  3. You need a temporary variable to reference nodes as you traverse a list. True

  4. The efficiency of the displayList method is directly related to the efficiency of the getEntry

    method. False

  5. You cannot use an assert statement to determine of a list is empty. True

  6. A fundamental operation of a list is a traversal.  True

  7. You must know how much memory to allocate before creating a linked implementation of a list. False

  8. A linked implementation of a list grows and shrinks dynamically as nodes are added and deleted.  True

  9. In a linked implementation of a list, you only call the method getNodeAt when we remove an

    entry other than the first one.  False

  10. Replacing a node in a linked implementation of a list only requires locating the node and

    replacing the data portion of the node.False

  11. In a linked implementation of a list, the replace method replaces the entire node. True

  12. Retrieving a list entry using a linked implementation is faster than using an array representation. True

  13. Replacing a list entry using an array implementation is faster than using a linked representation.  False

  1. Outline the basic steps to remove a node from the beginning of a list.

Multiple Choice (30)

1. A linked implementation of a list

  1. uses memory only as need for new entries

  2. returns unneeded memory to the system when an entry is removed

  3. avoids moving data when adding or removing entries

  4. all of the above

  1. In a chain of linked nodes you can

    1. add nodes from the beginning of a chain

    2. add nodes from the end of a chain

    3. add nodes that are between other nodes

    4. all of the above

  2. In a chain of linked nodes you can

    1. remove nodes from the beginning of a chain

    2. remove nodes from the end of a chain

    3. remove nodes that are between other nodes

    4. all of the above

  3. If a chain is empty, the head reference

    1. is null

    2. is an empty node with the data field not set

    3. is in an illegal state

    4. none of the above

  1. When

    1. the node before the insertion position and the node after the insertion position

    2. the first node and the node before the insertion position

    3. the first node and the node after the insertion position

    4. the last node and the node after the insertion position

  2. 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

  3. If the reference to the first node is null, this means

    1. the list is empty

    2. the list is full

    3. the garbage collector should be invoked

    4. the list is in an unstable state

  4. The last node is a list has a reference to

    1. null

    2. itself

    3. the node before it

    4. 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

  1. start at the first node and traverse the chain

  2. start at the last node and traverse the chain

  3. directly access the node

  4. none of the above

10. Moving
a. traversing

through a linked implementation of a list from one node to another is called

  1. walking

  2. hopping

  3. 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

  1. between adjacent nodes of the list

  2. at the end of the list

  3. at the beginning of the list

  4. all of the above

  1. In the linked implementation of a list, what happens when you try to add a node at an invalid position?

    1. it throws an IndesOutOfBoundsException

    2. it throws an InvalidLinkException

    3. it returns null

    4. it returns false

  2. 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 **

  3. 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();

  1. A reference to the last node in a linked implementation of a list is commonly called the

    1. tail

    2. end

    3. final

    4. none of the above

  2. Including a tail reference to a linked implementation of a list makes which functionality more efficient?

    1. adding a node to the end of a list

    2. searching for a node on the list

    3. removing a node from the list

    4. all of the above

  3. In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if

    1. the list only contains one entry

    2. the list is empty

    3. the list is full

    4. all of the above

  1. In a linked implementation of a list with a tail reference, removing an entry affects the tail reference if

    1. the list has multiple entries and the entry to be removed is the last one

    2. the list has multiple entries and the entry to be removed is the first one

    3. the list is empty

    4. all of the above

  2. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  3. 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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  4. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  5. 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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  6. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  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?

    1. O(1)

    2. O(log n)

    3. O(n)

    4. O(n2)

  2. 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?

    1. O(n)

    2. O(n2)

    3. O(log n)

    4. O(1)

  3. In a linked-based implementation of the ADT list with only a head reference, which method has a time efficiency of O(1)?

    1. clear

    2. toArray

    3. contains

    4. all of the above

  4. In a linked-based implementation of the ADT list with a tail reference, which method has a time efficiency of O(1)?

    1. adding an entry to the end of the list

    2. adding an entry to the beginning of the list

    3. clear

    4. all of the above

Add a comment
Know the answer?
Add Answer to:
Please help me on all the questions !!!!!!!! Really need help! Will give a thumb up...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 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...

    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,...

    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...

    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...

    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 reference...

    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...

    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...

    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> {...

    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...

    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...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT