Prior to designing an abstract data type, we have to choose an appropriate data structure. This assignment will implement a List ADT which uses a singly linked list for implementation. The data structures are given below:

The Node structure

typedef struct node_def{
int phoneNumber;
int areaCode;
char name[20];
struct node_def *next;
}Node;

The List structure

typedef struct {
Node *head;
Node *tail;
Node *current;
int currentPosition;
int nodeCount;
}List;

The following is a set of operations:

void init(List*)
Precondition: An empty list has been created;
Postcondition: initialize the empty list
void addList(List*, int, int, char*)
Precondition: A list has been created; list, area code, phone number, and name are parameters.
Postcondition: Append a new node to the end of the List.
int checkEmpty(List*)
Precondition: A list has been created and a list object is a parameter.
Postcondition: Return 1 if the list is an empty list; otherwise return 0
void goToHead(List*)
Precondition: A list has been created and a list object is a parameter.
Postcondition: Set the current pointer to head.
void goToTail(List*)
Precondition: A list has been created and a list object is a parameter.
Postcondition: Set the current pointer to tail.
char* getList(List*)
Precondition: A list has been created and a list object is a parameter.
Postcondition: returns the content of each node of the entire list (areaCode, phone number and name)
e.g. if the list contains 3 nodes, then the returned string should be as below.
647 1234567 Jon Snow
647 2234567 Sansa Stark
647 3234567 Jamie Lannister
or
647 1234567 Jon Snow 647 2234567 Sansa Stark 647 3234567 Jamie Lannister
int searchList(List*, int, int)
Precondition: A list has been created; a list object, area code, and a phone number are parameters.
Postcondition: If the given phone number is in the list, set currentPos (e.g. currentPosition = 0, the current position is at the first node) at that node and return 1; otherwise return 0.
Precondition: A list has been created; a list object, area code, and a phone number are parameters.
Postcondition: If the phone number is found in a node, delete the node, and free the memory.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.