Linked List Flashcards

1
Q

What are the operations of a linked list and complexity analysis of each one?

A

Push Front O(1)
Top Front O(1)
Pop Front O(1)
Push Back O(N) when there is no tail pointer
Top Back O(N) when there is no tail pointer
Pop Back O(N) when there is no tail pointer
Find O(N)
Erase O(N)
Empty O(1)
Add Before O(N)
Add After O(1) because the method itself takes the node we want to add after it

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

what is the purpose of abstract data type?

A

it’s to specify the behavior not the implementation

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

what are sentinel nodes?

A

they are nodes that don’t hold any data and will always be there in the list even when it’s empty they are used as guidelines as the head and tail point to them

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

difference between list and array in read and write

A

arrays are faster to read while lists are faster to write

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

what makes u decide between a list and an array

A

the algorithm as using merge sort on an array means that u will copy the elements from the two arrays and then sort the large array which will take alot of time and memory but with a list u can just change the reference and then u have one big list to sort

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

what is bad about a list?

A

the indirection and the pointers that go from somewhere to another not like arrays that are contiguous and that indirection the modern computers don’t like

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

what is a doubly linked list and how can it improve out operations?

A

a list is a doubly list when it has a next pointer and a prev pointer and that makes addBefore O(1) and push

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

what is the difference in access between list and array

A

array has direct access (Random Access) while list has sequential access

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

what is a circular linked list?

A

it’s when the head pointer points to the last node and the tail pointer points to the last node

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