Linked Lists - Info Flashcards

1
Q

Linked Lists

A linked list is, along with a________, a way of storing a list in memory.
Linked lists and arrays are data structures that store objects in a linear order.

The order in a linked list is determined by a p__________.

A

arrays
pointer

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

Singly Linked Lists

The elements of a singly linked list are not c___________ like array elements.
They are linked together, and therefore as well as holding some data, they also have a ‘next’ section which holds the address of the next element in the list.
This is the link.

A

contiguous

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

Singly Linked Lists - Direction

You can only move in a f__________ direction in a singly linked list.

A

forward

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

Singly Linked Lists - Composition

The elements in a linked list are called n____________.
Each node contains two parts:

D________
L_________

A

Nodes
Data
Link (next)

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

Singly-linked list - Pointer

In order to access the first node in a singly linked list, we need a pointer that contains the address of that first node.
We call this pointer the ‘h_______’,

A

head

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

Singly Linked list

The last item in a singly linked list will have N______ as its address.

A

NULL

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

Inserting and Deleting Elements to Single linked lists

It is easy to insert and delete nodes in a singly linked list, as all we have to do is change the p__________ (addresses).

In arrays, we have to shuffle elements along the list which can take a lot of time if you have a large array.

Both take O(1)

A

pointers

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

Singly Linked Lists - Searching

It is difficult to search a singly linked list as the elements do not have indices like array elements.

To locate an element we need to begin at the h_______ and work our way towards the t___________ until we find the one that we want.

This takes O(n) time.

A

head
tail

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

Doubly Linked Lists - Nodes

The nodes of a doubly linked list have three sections;

D________
N________
P_________

A

DATA
NEXT
PREV

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

The previous section has the address of the p________ node, so we can move in both directions in doubly linked lists.

A

previous

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

Doubly Linked Lists - Search, Insert and Delete

It takes O( ) time to search a doubly linked list.
Insert = O(1)
Delete = O(1)

A

O(n)

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

Sentinels

See YouTube Video

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