I want to store 50000 or more strings and I need to perform several operations like retrieval of a specific string, deletion of a specific string, etc. I have been given only two options to select from and these are array list and array to store them. From a performance point of view which one is better?
Share
Neither. If you want retrieval of specific strings (e.g. get the string “Foo”) and deleting specific strings (e.g. delete “Foo”), I would consider using a
Set.An array list or an array will give you O(N) retrieval (unless you keep it sorted). A
Setwill typically give you at least O(lg N) time for finding a specific item.