//returns all data that is currently there in a sorted String array.
Insertion into an ordered linked list is O(n), binary search assumes random access.An linked list would be the way to go; time complexities for your operations backed by a linked list would be either:
(unordered)
depositData: O(1) since we would just insert new daa at end of list
getStoredData: O(n + n lg n) since we must sort prior to returing a copy of the data in array form
or
(ordered)
depositData: O(lg n) since we must use binary search to find proper insert location
getStoredData: O(n) since all we have to do is return a copy of the data in array form
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |