Professional Documents
Culture Documents
a b c d e
0 1 2 3 4 5 6
L = (a, b, c, d, e)
Store element i of list in element[i].
Right To Left Mapping
e d c b a
Mapping That Skips Every Other
Position
a b c d e
Wrap Around Mapping
d e a b c
Representation Used In Text
a b c d e
0 1 2 3 4 5 6 listSize = 5
insert(1,g)
listSize = 6
a g b c d e
Data Type Of Array element[]
Data type of list elements is unknown.
a b c d e f
a b c d e f
#include <algorithm>
a b c d e f
template<class T>
void changeLength1D(T*& a, int oldLength,
int newLength)
{
1 if (newLength < 0)
throw illegalParameterValue();
element[6]
a b c d e f
arrayList of text … c = 2
To-do
Practice:
– https://www.hackerrank.com/
challenges/cpp-input-and-
output
More on insertion sort:
– https://en.wikipedia.org/wiki/I
nsertion_sort