Please describe in a few sentences the procedure for inserti

Please describe in a few sentences the procedure for inserting an element at a specified index into an array list and a linked list. What is the worst-case time complexity for both procedures? Please justify why the time complexity is the one you state

Solution

array list takes O(1) for identifying index but it takes O(n) for inserting element at specified location because of moving elements from that specified location without lossing our data.

There is no data in arraylist then it takes O(1) time itself.

Linked list:Here inserting element takes O(1) time but inserting element at that specified location takes O(n) time.

because we have to traversal upto that specified index.so,worst case time complexity O(n) time.

Please describe in a few sentences the procedure for inserting an element at a specified index into an array list and a linked list. What is the worst-case time

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site