Introduction to Linked Structures Flashcards

1
Q

Problems with arrays

A

Insertions and deletions require shifting elements, and O(n) operation

Length is fixed at instantiation, resizing requires new memory and transfer of element

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

Why do we have these problems with arrays?

A

Array cells map to adjacent cells in memory, to support constant-time access

There is a one-to-one correspondence between the logical structure of the sequence of elements and the underlying memory storage

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

How can we solve the problems we have with arrays?

A

Decoupling the logical sequence and the memory representation

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

What does a linked structure allow us to do?

A

A linked structure allows us to represent a sequence of elements independently of their positions in memory

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

What do and do not linked structures support?

A

Linked structures support insertions, deletions, and traversals

Linked structures do not support random access

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

How is storage allocated in linked structures?

A

Storage is allocated for each new element, as needed, from an area of memory called the system help

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

Of what does a linked structure consist?

A

A linked structure consists of a unique external link which is either empty or points to a node

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

What does a node contain?

A

A data element and a link to the next node

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

What does the last node in a linked structure contain?

A

An empty link

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

What does the variable representing a linked structure contain?

A

The address of the first node in the linked structure

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

What is None?

A

The memory address 0

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

What are links also sometimes called?

A

Pointers or references

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

What are some of the benefits of linked structures?

A

The logical size and the physical size of the structures are always the same

Memory is allocated for new nodes only when needed

Storage for deleted nodes is reclaimed by the system

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

Array tradeoffs

A

Contant-time access is good for binary search, implementing a dictionary, etc.

Uses less memory if the array is close to full

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

Linked structure tradeoffs

A

Uses memory only as needed, never have to resize

Insertions and removals need no extra overhead to shift data elements

But accesses, replacements, insertions, and removals at arbitrary positions are O(n) in time

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