Here’s the problem.
Write a function for merging multiple (sorted) linked lists into one sorted linked list. This
function should access the elements through Iterator interface (do not access elements
through the linked list directly). The arguments to the merge procedure are an array of
Iterators and the size of the array. The return value should be another Iterator with an
underlying List implementation.
Steps:
(1) Implement linked list with iterator interface.
Define the Element in the list as below:
typedef struct
{
int idno;
char name[25];
float marks;
} Element;
(a) List createList();
(b) List insert(List L, Element e );
(c) Void printList(List L);
(d) iterator initIterator(List L);
(e) boolean hasMoreElements(iterator I);
(f) iterator moveNext(iterator I);
(2) Implement Merge function.
iterator merge(iterator I[],int size)
This function will merge the elements in all the lists ordered by the attribute
“marks”. Merge function should access the list through the iterator functions.
(3) Implement driver function.
Populate the lists from the input files (provided as support). Call the merge
function and store the data in resultant merged list to an output file.
Support files: test1.txt, test2.txt, test3.txt, test4.txt, test5.txt, test6.txt, test7.txt, test8.txt
Deliverables: dataDef.h, mergeOps.c, mergeOps.h, main.c, output.txt
Now i dont want the solution for this, but i want to know what an iterator interface is.
I have never heard of it before.
And how do i go about implementing linked list with iterator interface.What does it mean?
Also it uses a data type of iterator what that would be?
An iterator is simply a generalized term for something that allows you to traverse a container (like an array, list, etc).
From wikipedia,
As your assignment talks about creating an iterator without access the elements directly, you can have a look at Iterator Design Pattern
More information on Iterator