Unit 3 Chapter 5 Linked Lists Terms & Concepts Flashcards

1
Q

Each Link object contains references to:

A

to a data item, to next link in the list. A field in the LinkList class refers to the first link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

how is linked-list self-referential?

A

it contains a field - called next - of the same type object as itself

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

in an array each item occupies a particular position which can be accessed using an index number, what is the process for linked lists?

A

in a list, the only wat to find a particular element is to follow along the chain of elements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

where are new links added in a linked list?

A

at the beginning of the list.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

how are links removed in a linked list?

A

the reference to the preceding link is changed to point to the following link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

in the link constructor, what is next automatically set to?

A

null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is the process for inserting a new link using the insertFirst method of a linked list?

A

set the next field in the newly created link to point to the old first link, and then change first so it points to the newly created link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is the process for deleting a link using the deleteFirst method of a linked list?

A

it disconnects the first link by rerouting first to point to the second link. DeleteFirst assumes the list is not empty, verify using isEmpty.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is the process for displayList method of a linked list?

A

starts at first and follow chain of references from link to link. The variable current refers to each link in turn.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the process for finding a link using the delete( ) method of a linked list?

A

searches for link to be deleted, maintains a reference to the current link and and previous link, deletes the current link, connects the preceding link to the following link. At each cycle through the while loop, just before current is set to current.next, previous is set to current.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Double-ended list definition

A

a double-ended list is similar to an ordinary linked list, but it has an additional reference to the last link as well as the first.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the purpose of the additional reference to the last link in a double=ended list?

A

The reference to the last link permits you to insert a new link directly at the end of the list as well as the beginning.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what is the process for the method insertLast in a double-ended list?

A

modify last.next to point to the new link and then change last to point to the new link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

what consideration must be made in the special case when the double-ended list is empty prior to insertion?

A

if isEmpty is true, then insertFirst must set last to the new link and insertLast must set first to the new link.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

what is linked list efficiency for insertion, deletion and deleting inserting next to a specific item

A
insert first and delete first takes O(1) time.
requires O(N) comparisons for insert and delete of specific item.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define: Abstraction

A

considered apart from detailed specifications or implementation.

17
Q

Define: Abstract Data Type

A

a class considered without regard to its implementation. A description of the data in the class (fields), a list of operations (methods) that can be carried out on the data, and instructions on how to use these operations.

18
Q

Define: interface

A

An ADT specification. What the class user sees - usually its public methods - such as push and pop.

19
Q

Define: Sorted List

A

items are arranged by key value.

20
Q

Efficiency of Sorted Linked Lists

A

insertion/deletion at sorted location: O(N)

insertion/deletion of minimum key value:O(1)

21
Q

Define: Doubly Linked Lists

A

Capable of traversing backward as well as forward through the list.

22
Q

How is a doubly linked list able to traverse backwards?

A

Each link has two references to other links instead of just one to the next link, as in ordinary lists, there is a second link to the previous link.

23
Q

What are the three insertion routines of a doubly linked list?

A

insertFirst( ), insertLast( ), insertAfter( ).

24
Q

What is the process for insertFirst( ) in a doubly linked list?

A

Unless the list is empty, insertFirst changes the previous field in the old first link to point to the new link and changes the next field in the new link to point to the old first link. Finally, it sets first to point to the new link.