Question: write a method Copy (see signature below) to copy the data of a linked list to another. The destination linked list data has been initialized as empty char arrays.
Class Buffer
{
BufferNext;
int Length;
char[] Data;
}
bool Copy(
Buffer source,
Buffer destination)
}Source example:
Node1:
point to Node2 in Next
Length = 2
Data = "abc"
Node2:
point to null in Next
Length = 5
Data = "defghi"Destination before the call:
Node8:
point to Node9
Length = 1
Data = "\0"
Node9:
point to null
Length = 4
Data = "\0\0\0\0"Destination after the call:
Node8:
point to Node9
Length = 1
Data = "a"
Node9:
point to null
Length = 4
Data = "bcde"