Chapter 19 Linked List

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

12. True or False: A linked list is a looping data structure.

False

13. True or False: The head of a linked list is also a linked list.

False

16. True or False: The index of an element to be removed from a list can be the same as the size of the list.

False

17. True or False: The statement myList = new Node("Zoe", myList); adds "Zoe" to the end of the linked list myList;

False

18. True or False: There is a natural way to write a recursive method to check whether a linked list is empty.

False

19. True or False: The last item in a doubly linked list can sometimes have a successor.

False

6. To easily move from any node to its successor, and from any node to its predecessor, and from the first to the last node and from the last to the first node, you need . 1. a singly linked list 2. a singly and circularly linked list 3. a doubly linked list 4. a doubly and circularly linked list

a doubly and circulary linked list

7. A systematic method that starts at the beginning of the list and processes every node is called . 1. a walk down the list 2. a list processing function 3. a travesty of list processing 4. a traversal

a traversal

9. A method for adding an element at an index k in a list throws an exception unless . 1. k is negative 2. k is nonnegative and less than the size of the list 3. k is nonnegative and less than or equal to the size of the list 4. k is positive and less than or equal to the size of the list

k is nonnegative and less than or equal to the size of the list

8. A method for removing the element at an index k in a list throws an exception unless . 1. k is negative 2. k is nonnegative and less than the size of the list 3. k is nonnegative and less than or equal to the size of the list 4. k is positive and less than or equal to the size of the list

k is nonnegative and less than the size of the list

A ___ _____ is an implementation of a list in which elements are stored in nodes, and each node contains a link to its successor.

linked list

In Java, a linked list is implemented as a sequence of ______, where each node stores a list element and a reference to the next node in the list.

nodes

An empty linked list is indicated by setting its head reference to ______

null

Before you attempt to access the value stored in a node, or the next or prev references, make sure the reference is not _____.

null

The first element in the list has no ______

predecessor

3. To add an element e just after a node referenced by ref, you should use the statement . 1. add(ref); 2. ref.next = new Node(e); 3. ref.next = new Node(e, ref.next); 4. ref = new Node(e, ref.next);

ref.next = new Node(e, ref.next);

Method remove and return the element at the position given by index.

String remove(int indexZ)

14. True or False: The tail of a linked list is also a linked list.

True

15. True or False: The index of an element to be added to a list can be the same as the size of the list.

True

20. True or False: The first item in a doubly linked list can sometimes have a successor.

True

10. A method that determines if a list is empty in a consistently written linked list class that uses a reference first to point to the first element, and a reference last to point to the last element, can return the value . 1. first == null 2. last == null; 3. first == null || last == null 4. all of the above

all of the above.

1. A list is a collection that . 1. associates keys with elements 2. assigns an index to each of its elements 3. is implemented by the JList class 4. none of the above

assign an index to each of its elements

Method check if the list is empty.

boolean isEmpty()

Method remove the specified element e and return true if the item was successfully removed

boolean remove(String e)

4. In general, adding an element e in one step to a singly linked list just before a node referenced by ref . 1. cannot be done 2. can be done if you use a loop 3. can only be done when ref is the last node in the list 4. can be done if you check for exceptions

cannot be done

Array-based lists use ______ allocation, which allocates storage for successive list elements in consecutive memory locations.

contiguous

There are two ways to allocate storage for the elements of a list: _______ allocation, and ______ allocation.

contiguous, linked

2. In Java, the first (head) element of a list . 1. has a predecessor but no successor 2. has both a predecessor and a successor 3. has index 0 4. has index 1

has index 0

The first element of the list is called the head of the list, so this reference is often called the ____ _______.

head reference

Method return the number of elements in the list.

int size()

the last element in the list has no ________.

successor

5. To remove a node that is not the head of a singly linked list conveniently, you need to have a reference to . 1. the node that precedes it 2. the node that comes after it 3. the node itself 4. none of the above

the node that precedes it

The most basic operations on linked lists are _______the list, moving to a position determined by an index, adding an element, removing an element, and searching for an element.

traversing

11. True or False: A linked list is a recursive data structure.

true

Method add an element e to the end of the list

void add(String e)

Method add the specified element e to the list at the position given by index.

void add(int index, String e)


Kaugnay na mga set ng pag-aaral

6.13: Using Reference Variables as Parameters

View Set

Section 3.4 Part 1: Multiplying and Dividing Integers and Variable Expressions with Integers

View Set

Chapter 15 - Aggregate Demand and Aggregate Supply

View Set

Environmental Design 100: Final Exam

View Set

Multilingual, Hybrid, Planken, Multiple, Codes, Bilingualism, Multilingualism, Mixing, Practices, Contact, Variation, World_Englishes_English, Genre_Variety, Global, Code-switching, Function, Symbol, Norm_Approach, Advertising, Contact, Identity: 18-42

View Set

Oklahoma State Physiology BIOL 3204 Exam 1 Questions

View Set