I need help starting (finishing) this c programming homework. Write a program in
ID: 3649412 • Letter: I
Question
I need help starting (finishing) this c programming homework.Write a program in C containing the following:
The definition of a data structure for a binary tree that stores an integer at each node.
(This is not necessarily a binary search tree, so you don
Explanation / Answer
struct node { int data; node * next; }; class LinkedList { public: LinkedList(); void add(int A); bool empty(); // return true if the list is empty, otherwise return false void InsertInOrder(int x);//insert a value x in numerical order in the list void Delete(int x); //if value x is in the list, remove x void Display();// Display the data values in the list private: node * first;//pointer to the first node in the list }; LinkedList::LinkedList() { first=NULL; } void LinkedList::add(int A) { if (first==NULL) { first=new node; first->data=A; first->next=NULL; } else { node *curr=first; node *prev=NULL; while (curr!=NULL) { prev=curr; curr=curr->next; } curr=new node; curr->data=A; curr->next=NULL; prev->next=curr; } } bool LinkedList::empty() { if (first==NULL) return true; else return false; } void LinkedList::Delete(int A) { node *curr=first; node *prev=NULL; bool flag=true; if (first->data==A) { first=first->next; delete first; flag=false; } else { while (flag && curr!=NULL) { if (curr->data==A) { prev->next=curr->next; delete curr; flag=false; } prev=curr; curr=curr->next; } if (flag==true) coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.