Core Networking

Core Networking

Analysis (Insertion and deletion operation)

The best possible case in insertion operation is when the item is inserted at the last position. In this case, no movement of elements is required. The worst case occurs when the element has to be inserted at the beginning of the list. In this case, we have to move all the elements down the list. Therefore, the while loop executes n times, each moving one element down. Thus complexity of insertin operation is O(n), i.e linear time.

.The best case in deletion occurs when the element to be deleted is the last element of the array. In this case, no element is moved up. The worst case occurs when element is deleted from the first position. In this case, all (n-1) elements are moved up. The while loop executes n-1 times, each time moving one element down. Thus complexity of deletion operation is also O(n) i.e linear time.

0 comments:

Subscribe Core Networking