Link Lists Java Chapter 5

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

3. When you create a reference to a link in a linked list, it a. must refer to the first link. b. must refer to the link pointed to by current. c. must refer to the link pointed to by next. d. can refer to any link you want.

D

15. Which do you think would be a better choice to implement a stack: a singly linked list or an array?

Usually, the list. They both do push() and pop() in O(1) time, but the list uses memory more efficiently

12. How many times would you need to traverse a singly linked list to delete the item with the largest key?

once, if the links include a previous reference

5. How many references must you change to insert a link at the end of a singly linked list?

1

4. How many references must you change to insert a link in the middle of a singly linked list?

2

9. A double-ended list a. can be accessed from either end. b. is a different name for a doubly linked list. c. has pointers running both forward and backward between links. d. has its first link connected to its last link.

A

13. Of the lists discussed in this chapter, which one would be best for implementing a queue?

A Double-ended list

1. Which of the following is not true? A reference to a class object a. can be used to access public methods in the object. b. has a size dependant on its class. c. has the data type of the class. d. does not hold the object itself.

B

14. Which of the following is not true? Iterators would be useful if you wanted to a. do an insertion sort on a linked list. b. insert a new link at the beginning of a list. c. swap two links at arbitrary locations. d. delete all links with a certain key value.

B

6. In the insertFirst() method in the linkList.java program (Listing 5.1), the statement newLink.next=first; means that a. the next new link to be inserted will refer to first. b. first will refer to the new link. c. the next field of the new link will refer to the old first link. d. newLink.next will refer to the new first link in the list.

C

8. When all references to a link are changed to refer to something else, what happens to the link?

Java's garbage collection process destroys it

11. Assuming a copy takes longer than a comparison, is it faster to delete an item with a certain key from a linked list or from an unsorted array?

a linked list

7. Assuming current points to the next-to-last link in a singly linked list, what statement will delete the last link from the list?

current.next = null;

10. A special case often occurs for insertion and deletion routines when a list is ________.

empty

2. Access to the links in a linked list is usually through the _________ link.

first


Kaugnay na mga set ng pag-aaral

Jean-Paul Sartre: Existentialist Ethics Quiz

View Set

questions from question sets -- Intro to Disability Studies

View Set

Chapter 9 and 10 Race and Ethnic Relations

View Set