Why does dynamic array always double by a factor of 2?

Posted by Phoenix on Stack Overflow See other posts from Stack Overflow or by Phoenix
Published on 2010-03-30T13:56:11Z Indexed on 2010/03/30 14:03 UTC
Read the original article Hit count: 225

Filed under:

I was wondering how does one decide the resizing factor by which dynamic array resizes ? On wikipedia and else where I have always seen the number of elements being increased by a factor of 2? Why 2? Why not 3? how does one decide this factor ? IF it is language dependent I would like to know this for Java.

© Stack Overflow or respective owner

Related posts about data-structures