Question: This were the instruction and now here is the source code for linked list #include using namespace std; //our node struct node { node*next; char

 This were the instruction and now here is the source codefor linked list #include using namespace std; //our node struct node {

This were the instruction and now here is the source code for linked list

#include using namespace std;

//our node struct node { node*next; char d;

};

node*head = 0; node*tail = 0;

//function declarations char remove(void); void append(char); int find(char); void traverse(void); int isempty(void);

//main for testing the access functions void main(void) { append('A'); append('B'); append('C'); append('D'); append('E'); append('F'); traverse();

find('X'); find('X'); traverse();

cout

cout

void append(char d) { node*p = new node; p->next = 0; p->d = d;

if (!(head)) { head = tail = p; } else { tail->next = p; tail = p; } } void traverse(void) { node*p = head;

cout d next; } cout

char remove(void) { node*p; char temp;

//return null if list is empty if (!(head)) return -1;

if (head == tail) { temp = head->d; delete head; head = tail = 0; return temp; } //more than one node //remove and destroy head node p = head; head = head->next; temp = p->d; delete p; return temp; }

//searces the list for a char element //if the char is found, removes the char elemet and return 1 otherwise return 0 int find(char d) { node*c; node*pc;

//empty? if (!head) { cout

if (head == tail) { if (head->d == d) { delete head; head = tail = 0; cout

pc = head; c = head->next; if (pc->d == d)//fount it at the head { head = head->next; delete pc; cout d == d)//found it after the head { pc->next = c->next; //take care of tail if (c == tail) tail = pc; //destroy node delete c; cout next; } cout

Basic Containers Implementations See the posted file "LinkedList.pdf" and "CircList.pdf" which contain source code to mplement a simple "list" container using 2 different implementations. Input and debug this source as given, then use that as a code base to implement the following. A) Old Programs Get LinkedList and CircList working, and include the source code and testing in your B) New Programs 1) Stack 2) Queue 3) Priority Queue Using a circular array implementation Using a circular array implementation Using a circular array implementation 4) Stack 5) Queue 6) Priority Queue 7) Double Linked List Using a linked node implementation Using a linked node implementation Using a linked node implementation Using a linked node implementation C) Analysis Analyze, state, and explain the TIME COMPLEXITY in Big Oh notation for every function. D) Interface Functions Both implementations will share the same set of interface functions below Stack must su push(data) char pop(vold) char peek void); bool isempty void): appends data to the head of the list removes the head node and returns data; returns-1 if empty returns a copy of data at the head but does not remove the head returns true if the stack is empty, returns false otherwise returns -1 if empty must the void q(char) char dq void) bool isempty void); appends data to the tail of the list removes the head node and returns data; returns-1 if empty returns true if the queue is empty, returns false otherwise void insert(data) data dq(void) data peek(void) bool isEmpty void); inserts data in sorted order removes the head node and returns data; returns-1 if empty returns a copy of data at the head but does not remove the head returns -1 if empty returns true if the Pqueue is empty, returns false otherwise Double Linked List must s void appendTal(char); void appendHead(char) char remoaod) char removeHead(void): void void traverseBWD(void): appends data to the tail of the list appends data to the head of the list removes the head node and returns data; returns -1 if the list is empty removes the head node and returns data; returns -1 if the list is empty traverses the list from the head to the tail, and prints out each data element traverses the list from the tal to the head, and prints out each data element returns true if the list is empty, returns false otherwise Testing Thoroughly test your code with a variety of data. Exercise a functionality Turn in: 1) Paper source code listings. 2) Paper output listings that demonstrate full testing of all program functionality. 3) Follow the formatting requirements for this class, as descnibed elsewhere. Basic Containers Implementations See the posted file "LinkedList.pdf" and "CircList.pdf" which contain source code to mplement a simple "list" container using 2 different implementations. Input and debug this source as given, then use that as a code base to implement the following. A) Old Programs Get LinkedList and CircList working, and include the source code and testing in your B) New Programs 1) Stack 2) Queue 3) Priority Queue Using a circular array implementation Using a circular array implementation Using a circular array implementation 4) Stack 5) Queue 6) Priority Queue 7) Double Linked List Using a linked node implementation Using a linked node implementation Using a linked node implementation Using a linked node implementation C) Analysis Analyze, state, and explain the TIME COMPLEXITY in Big Oh notation for every function. D) Interface Functions Both implementations will share the same set of interface functions below Stack must su push(data) char pop(vold) char peek void); bool isempty void): appends data to the head of the list removes the head node and returns data; returns-1 if empty returns a copy of data at the head but does not remove the head returns true if the stack is empty, returns false otherwise returns -1 if empty must the void q(char) char dq void) bool isempty void); appends data to the tail of the list removes the head node and returns data; returns-1 if empty returns true if the queue is empty, returns false otherwise void insert(data) data dq(void) data peek(void) bool isEmpty void); inserts data in sorted order removes the head node and returns data; returns-1 if empty returns a copy of data at the head but does not remove the head returns -1 if empty returns true if the Pqueue is empty, returns false otherwise Double Linked List must s void appendTal(char); void appendHead(char) char remoaod) char removeHead(void): void void traverseBWD(void): appends data to the tail of the list appends data to the head of the list removes the head node and returns data; returns -1 if the list is empty removes the head node and returns data; returns -1 if the list is empty traverses the list from the head to the tail, and prints out each data element traverses the list from the tal to the head, and prints out each data element returns true if the list is empty, returns false otherwise Testing Thoroughly test your code with a variety of data. Exercise a functionality Turn in: 1) Paper source code listings. 2) Paper output listings that demonstrate full testing of all program functionality. 3) Follow the formatting requirements for this class, as descnibed elsewhere

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!