Building a List ADT

A list is a sequence of items with similar data types, where the order of the item's position matters. There are several common operations that are available in a List ADT, and they are:

  • Get(i), which will return the value of selected index, i. If the i index is out of bounds, it will simply return -1.
  • Insert(i, v), which will insert the v value at the position of index i.
  • Search(v), which will return the index of the first occurrence of v (if the v value doesn't exist, the return value is -1).
  • Remove(i), which will remove the item in the i index. 
For simplicity, we are going to build a List ADT that accepts int data only, from zero (0) and higher. 

Now, by using the array data type we discussed earlier, let's build ...

Get C++ Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.