Day 3
Day 3
• Time Complexity :
• Best Case : Ω(n log n)
• Worst Case : O(n log n)
• Average Case : θ(n log n)
• Time Complexity :
• Best Case : Ω(n log n)
• Worst Case : O(n2) – worst case rarely occurs
• Average Case : θ(n log n)
• Else, Traverse the list till the last node and add the address of new node to the next part of the last
node.
Trav* 55 NULL
400 500
• To add a new node at the first position always create a new connection first between the new node
and the already existing first node. Then change the address inside head pointer to point to the new
node. So the Rule is MAKE BEFORE BREAK.