a1 - A list is a contiguous sequence of n elements...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
A list is a contiguous sequence of n elements beginning at position 1 and ending at position n. 1. Using templates, design and implement the class List both as a dynamic array and as a singly-linked list. In addition to the four basic methods, the list should also support the following methods: bool Insert ( const Etype & E, int p ); To insert element E at position p where p is correctly defined from 1 to n+1. If the element is properly inserted then true is returned; otherwise, false is returned. Once inserted, all elements after E move down one position. bool Remove ( int p ); To remove the element at position p where p is correctly defined from 1 to n. If the element is properly removed then true is returned; otherwise, false is returned. Once deleted, all elements after the removed element are moved up one position. bool Retrieve ( Etype & E, int p ) const; To retrieve the element E at position p where p is correctly defined from 1 to n. If the element is properly retrieved then true is returned (in addition to E); otherwise,
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.
Ask a homework question - tutors are online