There seems to be some confusion as to whether “information hiding” and “encapsulation” mean the same thing. There is no definitive answer, but for an accurate survey, you might want to read http://www.itmweb.com/essay550.htm
In this module, we take the view that encapsulation is about the conceptual idea of grouping data and operations into a single entity.
Like abstraction, the word “encapsulation” can be used to describe either a process or an entity. As a process, encapsulation means the act of enclosing one or more items within a (physical or logical) container. Encapsulation, as an entity, refers to a package or an enclosure that holds (contains, encloses) one or more items. It is extremely important to note that nothing is said about “the walls of the enclosure.” Specifically, they may be “transparent”,”translucent”, or even “opaque”.
– extracted from http://www.itmweb.com/essay550.htm
It is useful to think about a solution at several levels of abstraction. In this case, the fact that duplicate contacts are not allowed should remind you of a set. We can model the contact list as a set of contacts, where each contact is a pair consisting of name and phone number, i.e. `\{ (name_1, pnum_1), (name_2, pnum_2), \ldots, (name_n, pnum_n) \}`.
Many of your correctly suggested that we should create a new array that is twice as large and copy the contacts over. The reason for doubling the size (or more generally increasing the size by a certain factor `f`, e.g. `size = size \times f`) instead of only adding a constant number of slots slots, e.g. `size = size + c`, is that it results in less copying, but possibly more unused slots.
Don't worry if you have trouble following the analysis discussed below, analysis of algorithms will be covered later in this module.
As I've illustrated in class, the total number of copy operations is `p/2 + p/4 + \ldots + 1 \le p \le 2n` where `n` is the number of elements we are going to store in the array and `p` is the smallest power of 2 larger than or equal to `n`.
Suppose we add 10 slots each time, then the number of copy operation is `10 + 20 + \ldots + 10(k-1) = 10k(k-1)/2` where `k` is the smallest number such that `10k \ge n`.