### Explain the Data Structure

Hi i'm trying to read out the some code that i search in google. And i try to differentiate the code whether its using what kind of data structure.. Its using binary tree, queue, tree or vector or others?

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308`` `````` #include #include #include #include using namespace std; class studentrecord { public: studentrecord(); char fname[10]; char lname[10]; int ID; char programme[10]; int year_of_study; studentrecord *nxt; void register_student(); void display_all(); void displayStudentInformation(); void Swap(); void SearchStudent(); void DeleteStudent(); void ConditionalDisplay(); }; studentrecord::studentrecord() { } studentrecord *start_ptr=NULL; int khetho=0; void studentrecord::register_student() { studentrecord *temp,*temp2; temp=new studentrecord; cout<<"enter the student fist name:"<>temp->fname; cout<<"enter student last name:"<>temp->lname; cout<<"enter student id:"<>temp->ID; cout<<"Enter the Programme of the student:"<>temp->programme; cout<<"Enter student's year:"<>temp->year_of_study; temp->nxt=NULL; if(start_ptr==NULL) { start_ptr=temp; } else { temp2=start_ptr; while(temp2->nxt!=NULL) { temp2=temp2->nxt; } temp2->nxt=temp; } } void studentrecord::display_all() { studentrecord *temp; temp=start_ptr; if(start_ptr==NULL) { cout<<"the record is empty"<lname<ID<fname<programme<nxt; } } } void studentrecord::Swap() { studentrecord *temp,*temp2,*temp3,*temp4; temp= start_ptr; cout<>id; cout<<"enter 2nd ID u want to swap "<>id1; if (start_ptr == NULL) { cout << "The list is empty!" << endl; } while(temp!=NULL) { if(temp->ID=id1) { temp2=temp; temp=temp->nxt; } } while(temp3!=NULL) { if(temp3->ID=id1) { temp4=temp3; temp3=temp3->nxt; } } temp->nxt=temp4; temp3->nxt=temp2; temp->nxt=temp3->nxt; temp3->nxt=temp->nxt; //temp4->nxt=temp2->nxt; //temp2->nxt=temp4->nxt; //temp3->nxt=temp2; // temp2->nxt=temp->nxt; // delete temp; cout<>id; if (start_ptr == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->ID==id) { cout<<"ID :"<ID<fname<lname<programme<year_of_study<display_list(); temp = temp->nxt; } cout<>id; if (start_ptr == NULL) { cout << "The list is empty!" << endl; } if(start_ptr->ID = id) { temp=start_ptr; start_ptr=start_ptr->nxt; delete temp; } else { while(temp->ID!=id) { temp2=temp; cout<ID; count++; temp = temp->nxt; } temp2->nxt=temp->nxt; delete temp; cout<>lastname; if (temp == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->lname==lastname) { cout<lname<fname<ID<ID<year_of_study<nxt; } //temp->display_list(); temp = temp->nxt; } cout<>id; if (temp == NULL) cout << "The list is empty!" << endl; else { while(temp!=NULL ) { if(temp->ID==id) { cout<fname<lname<ID<year_of_study<display_list(); temp = temp->nxt; } cout<> khetho; switch (khetho) { case 1 : l.register_student(); cout<<" ";system("pause"); system("cls"); break; case 2 : l.SearchStudent(); break; case 3 : l.Swap(); break; case 4 : l.displayStudentInformation(); break; case 5 : l.display_all();break; case 6 : l.ConditionalDisplay();break; case 7 : l.DeleteStudent();break; } } while (khetho != 0); }``````
Last edited on
bump
That code is horrible, but the essence is here:
 ``12345678910`` ``````class studentrecord { public: studentrecord *nxt; }; // create new studentrecord X // find existing studentrecord Z, whose nxt is null. // At any given time there is at most on such Z (not counting the X). Z.nxt = X;``````

There is only one directional link from one object to other(s). That rules out trees. Queue is about adding to end and taking from start, so not a queue. "vector" is a bit oddly used term, and isn't usually used to describe a data structure anyway. Dear Watson, I trust you can narrow it down from here.
i get the concept of the queue, tree,binary tree and vector.. but once it from the code i cannt see the concept.. as u said queue FIFO.. but in code, i cannt differenciate it.. and i still cannt get ur point
Isn't this a Linked List ???
i getting confuse with the question if asking to develop using binary tree or tree data structure? whats diff?
All trees are trees, but only binary trees are binary trees. Binary == 2 == each node has at most two children. Binary tree is one special case of a tree.
Topic archived. No new replies allowed.