BIGO
1. InsertFirst(target)
BigO(1)
2.InsertLast(target)
BigO(1)
3 Insert(target)
BigO(N)
*********************************************************************************************************************
= BigO(1)
************************************************************************
For InsertLast(target)--
O(1) = BigO(1)
Find(target) = N
Insert when found = O(1). target can be added between any two
nodes,
1
WE do not consider the sorted linked list because it has the same big O
as the unsorted linked list
II. Add methods - ArrayList -Unsorted
BIG(O)
1. Insert(target)
BigO(1)
2. InsertFirst(target)
BigO(N)
3. InsertLast(target)
implemented
**************************************************************************
BigO(1)
***************************************************************************
--
BigO(N
******************************************************************************
*****
1. Insert(target)
BigO(N) - For Insert(target) - You get a O(Lg N) to
find the location where to insert using a Binary Search but worse case
you have to move all of the items down to put the new value in
so :
The BigO for delete methods for Linked List is same for unsorted
and sorted
IV. Delete methods -
LinkedList : BIGO
2
RemoveFirst(target)
BigO(1)
RemoveLast(target)
BigO(N)
Remove(target) -anywhere
BigO(N)
*******************************************************************************************************************************************************************
case
Delete(target) when found = O(1).
previous to remove the node
BigO Final for Remove() =
************************************************************************
DeleteFirst(target) --
O(1) = BigO(1)
***********************************************************************
*
= O(N)
**************************************************************
IV Delete methods - ArrayList -Unsorted :
RemoveFirst(target)
BigO(1)
removeLast(target)
BigO(1)
3
Big O(N)
For removeFirst(), swap in value in last index to the first index. Set value
in last index to null
For removeLast(), set value in last index to null ( there is reference at the
end of the list)
For Delete(target) - BigO(N) to Find the target, BigO (N) to move values
up or down