LinkedList Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What interface does LinkedList implement?

A

LinkedList implements List, which extends from Collection

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

What are the LinkedList methods?

A

add(x) = adds item x to the

listset(x,y) = set location x to the value y

get(x) = get the item at location x

size() = returns the # of items in the list

remove() = removes an item from the list

clear() = removes all items from the list

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

What is a LinkedList when implementing ListNode

?

A

A linked list is a group of nodes. Each node contains a value and a refence to the next node in the list.

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

What is a Node?

A

A node typically has a data component and a reference to the next node.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
What would be the output of:
ListNode x = new ListNode("10",     new ListNode("11",     new ListNode("12",null)));
out.println(x.getValue());
out.println(x.getNext().getNext().getValue());
out.println(x.getNext().getValue());
A

10
12
11

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

How do you remove the first node?

A

front = front.getNext();

this shifts the list to the next node

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

What is a DoubleNode?

A

A doubly node typically has a data component and a reference to the next node and the previous node.

Each node can go both ways

Doubly nodes can be used to make a circular linked list where the front points at the back and vice versa.

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

What is the Big-O Notation?

A

Big-O notation is an assessment of an algorithm’s efficiency. Big-O notation helps gauge the amount of work that is taking place.

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

List all the Big-O Notations to the LL commands:

A

traverse all nodes = O(N)

search for an item = O(N)

remove any item = O(N)

location unknown get any item = O(N)

location unknown add item at the end = O(N)

add item at the front = O(1)

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