Linked List Flashcards
What is linked list
Where we have a value and a node pointing to next
What is circular linked list
A circular linked list is one where the last node points to another node of the linked list
What is insertion deletion and acces time complexity of linked list
Insertion o1
Deletion o1
This given that we know the node
Access o n
Search On
How do you reverse a linked list
Take 2 pointers a curr pointing to head and previous to none now iterate on the list using while curr and inside loop take a temp pointer and
Temp = curr.next
Curr.next= prev
Prev = curr
Curr= temp
How to merge 2 sorted linked list
Use 2 pointers to create a new node name them curr and dummy now iterate on the given lists and add 2 to the new node based on the values until both lists are exhausted
Return the dummy
What is doubly linked list
This linked list has both previous and next
What are insertion at end look like for the doubly linked list
Take tail and add to tail and make new node previous to point to tail and make new node as new tail
How do you delete a node from doubly linked list
Tail = tail.previous
Tail.next = none
What is time complexity of insertion deletion access and search operation
Same as singly list
How do you design a linked list
What are edge cases for insert
Linked list designing is simple however edge cases always needs to be kept in mind
Making sure index is not out of bound
Adding to index equals length means new node at tail