Linked Lists - Programming Fundamentals III COSC-2336

Ace your homework & exams now with Quizwiz!

A method int size( ) in a linked list class returns the number of elements stored in the list by executing the single statement return count; For this to work correctly,

It is not possible for size to just return the count value: the size method must set count to 0 and then increment count once for each element in the list.

A Node class for a linked list that can hold elements of type Object can be declared to have fields

Object element; Node next;

In a typical circular doubly linked list, a node has

a field to store the element, and two references to keep track of successor and predecessor nodes

A list in which each stored element is associated with a reference to its successor is called

a linked list

A systematic procedure for starting at the first node in a list, and visiting all nodes in the list by going from each node to its successor is called

a traversal

The tail of a list

is what you get when take a list and remove its head

A circularly linked list makes it easy to

jump from the last node to the first

To allocate storage for their elements, linked lists use

linked allocation

A doubly linked list makes it easy to

move from any node to its successor, and from any node to its predecessor

To remove the first node in a nonempty linked list,

move the head reference one node forward: head = head.next;

The objects that form the units of memory allocation in a linked lists are called

nodes

A linked list class keeps its elements in the order in which they are added, with the index of an element X being greater than the index of any element added to the list before X. Addition of new elements to such a list can be made more efficient

none of the above

In a linked list implementation using a reference first to point to the first node of the list, a method isEmpty() can test to see if the list is empty by executing the statement(s)

return first == null;

To allocate storage for its elements, an array-based list such as ArrayList uses

contiguous allocation

A list can be considered a recursive data structure because

if you remove the head of the list, what remains is also a list

In a linked list, the predecessor of a node X

is undefined if X is the first node, otherwise it is the node whose index is one less than the index of X

A linked list is represented by a reference to

the first node in the list, unless the list is empty, in which case the reference is set to null

A list method void add(int index, E x) seeking to add an element x that is an object of a class E to a list, should throw an IndexOutOfBoundsException when

the index is negative, or greater than the size of the list

A list method E remove(int index) designed to remove and return the element at the given index should throw IndexOutOfBoundsException when

the index is negative, or is greater than, or equal to, the size of the list

When using recursion on linked lists

the recursive method should be made private, and should be called by a public non-recursive method


Related study sets

Health - Alcohol, Nicotine, and Sidestream Smoking

View Set

Principles and Applications of Biology Test 1

View Set

Unit 8.7 Insider Trading & Securities Fraud Enforcement Act of 1988 (Series 65)

View Set

Adult Nursing - Chapter 6: Individual and Family Homeostasis, Stress, and Adaptation - PrepU

View Set

Construction Materials ARCH 3323 Final Exam multiple choice questions.

View Set

Health Chapter 20 Study Guide~Maci Cagle

View Set

17. 1. - Can I park here? (Unit 8A)

View Set

ACE U. S. History- Industrial Movement

View Set