java - ArrayList vs. Queue time complexity -


if trying remove first element (index 0), more time efficient list.remove(0) <- removes index 0 or use queue , queue.dequeue(). know delete arraylist o(n), still hold true if provide index remove from? new java , algorithms, please bear me if dumb question

yes, arraylist fast adding , removing close end. takes o(n) time add or remove @ or near beginning if provide in index.

if need queue, use arraydeque. it's fast @ both ends.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -