|
1. Do we need to initialize every entry to 0 before inserting values?Somehow, you need to distinguish between the meaningful and meaningless entries in the array. I suggest that you do so by a counter or pointer that keeps track of how many there are. Then the initialization of individual entries is pointless. There are several reasons to prefer this method: it's more logical and more efficient. 2. Upon the first insert, since there's no entry put in before it, would it be the first entry? Or is the index of the array entry that based on the "index" value?I'm not sure I understand this question. If you insert into an empty table, the item you insert becomes the first one. 3. On insert, if the entry is found, do we change the "value" variable, or just put it in the next open array entry?Strictly speaking, I only assigned insertion in the case where the entry is not found. But if you like to extend to the general update function, changing an item if present, inserting if not, that's fine too. The insertion case is the one that's interesting for comparing the two datatypes. Mike O'D. |
to: