LabSheet1 Final
LabSheet1 Final
Linux command to download the labsheet and support files to the local machine
$scp -r <username>@blade3:\<foldername> .
Linux command to upload all the program files back to the server.
1. All inputs to the program must be either (a) command line arguments (b) or read from a file
(other than stdin). DO NOT READ anything from stdin and DO NOT USE PROMPTS like
“Please enter a number …”.
2. You are required to write the output to a file (other than stdout) and errors if any to a different
output channel (stderr or another file).
3. Use standard C coding conventions for multi-file programs. Separate the following: interfaces
of functions (use a “.h” file), data type definitions (use another “.h” file), ADT / algorithm
implementation (use a “.c” file), and driver/test code (use another ”.c” code).
Problem Statement
A Set is a collection of elements. The basic operations on sets are membership of an element, set union,
set intersection, set difference etc. Implement SetADT which represents sets as sorted linked lists where
each node of the list represents an element of the set. Various operations on sets are then performed by
traversing the corresponding linked lists. An Iterator is used as an interface to traverse the lists
representing sets. Iterator maintains the head of the list and current position as cursor, and the
number of elements yet to access.
Write the following functions to implement above ADTs in the specified files.
1. Set createSet()
This function creates an empty set and returns it.
2. boolean isMember(Set S, Element e)
This function uses the Iterator interface to traverse through the elements of the set S and
returns true if the element e is found belonging to the set S, else returns false.
1. ITERATOR initIterator(Set S)
This function initializes the Iterator to access the elements of the set S.
2. boolean hasMoreElements(ITERATOR I)
This function returns true if there are more elements to access and false if end of the list
has been reached.
3. ITERATOR moveNext(ITERATOR I)
This function returns updates the iterator I by moving to the next element.
(C)Function in main.c: