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 -

dataset - MPAndroidchart returning no chart Data available -

post - imageshack API cURL -