/* THIS CODE HAS BEEN TESTED AND IS FULLY OPERATIONAL. Problem Statement: A book consists of chapters, chapters consist of sections and sections consist of subsections. Construct a tree and print the nodes. Find the time and space requirements of your method. Code from DataStructuresAndAlgorithms (SPPU - Second Year - Computer Engineering - Content) repository on KSKA Git: https://git.kska.io/sppu-se-comp-content/DataStructuresAndAlgorithms/ */ // BEGINNING OF CODE #include #include using namespace std; struct node{ string label; int ch_count; struct node* child[10]; }*root; class GT{ public: GT(){ root = NULL; } string lbel; int count; void create(){ root = new node; cout<<"Name of the book:\t"; cin>>root->label; cout<<"Number of chapters:\t"; cin>>root->ch_count; for(int i=0;ich_count;i++){ root->child[i] = new node; cout<<"Name of chapter "<< i+1 <<":\t"; cin>>root->child[i]->label; cout<<"Number of sections:\t"; cin>>root->child[i]->ch_count; for(int j=0;jchild[i]->ch_count;j++){ root->child[i]->child[j] = new node; cout<<"Name of section "<< i+1 <<" - "<< j+1<< ":\t"; cin>>root->child[i]->child[j]->label; cout<<"Number of sub-sections:\t"; cin>>root->child[i]->child[j]->ch_count; for(int k=0;kchild[i]->child[j]->ch_count;k++){ root->child[i]->child[j]->child[k] = new node; cout<<"Name of sub-section "<< i+1 <<" - "<< j+1<< " - "<< k+1<< ":\t"; cin>>root->child[i]->child[j]->label; } } } } void display(node * r){ cout<label<ch_count<ch_count;i++){ cout<child[i]->label<child[i]->ch_count<child[i]->ch_count;j++){ cout<<"\t\t"<< i+1 <<" - "<< j+1<< " Name of sections: "; cout<child[i]->child[j]->label<child[i]->child[j]->ch_count<child[i]->child[j]->ch_count;k++){ cout<<"\t\t\t"<< i+1 <<" - "<< j+1<< " - "<< k+1<< " Name of sub-section: "; cout<child[i]->child[j]->label< Add book info"< Display info"<Exit"<>ch; switch(ch){ case 1: g.create(); break; case 2: g.display(root); break; case 3: cout<