Linked List Flashcards
1
Q
What is Linked List?
A
- Like Stack, Linked List also uses LIFO- Last in First out method
- nodes are added and deleted from the same end
2
Q
Can you do random searching?
A
No, we don’t have random access like an array. So, we start at the head node and iterate through each node until we find it or reach the end of the list.
3
Q
What is the time complexity?
A
In worst case scenario, the Time complexity is O(n) and n is the number of items in the list.
4
Q
two primary methods
A
push, pop
5
Q
helper methods
A
index(), remove(), false(bool)=isEmpty
6
Q
What is doubly linked list good for?
A
to remove nodes as they provide access to the previous and the next nodes.
7
Q
How to remove an item in singly linked list?
A
iterate through the list and keep track of the previous node