Question: In c + + , help me fix this codes output as its very strange and a delete function ( prompt:Delete length characters from the
In c help me fix this codes output as its very strange and a delete functionprompt:Delete length characters from the Rope starting from start. You can do this by spliting the rope into three, divided by start and startlength characters and deleting everything in the middle. and a substring function prompt: Return the substring that starts at character position i and goes to character position j
Do this by finding the node u that contains the ith character where weightu is greater than or equal to j Then do an inorder traversal of tree starting at u
code:
#include
using namespace std;
const int LEAFLEN ;
class Rope
public:
Rope left, right, parent;
char str;
int lCount;
;
void createRopeStructureRope& node, Rope par,
char a int l int r
Rope tmp new Rope;
tmpleft tmpright NULL;
tmpparent par;
if r l LEAFLEN
tmpstr NULL;
tmplCount r l;
node tmp;
int m l r;
createRopeStructurenodeleft, node, a l m;
createRopeStructurenoderight, node, a m r;
else
node tmp;
tmplCount r l;
int j ;
tmpstr new charLEAFLEN;
for int i l; i r; i
tmpstrj ai;
void printstringRope r
if r NULL
return;
if rleft NULL && rright NULL
cout rstr;
printstringrleft;
printstringrright;
void concatenateRope& root Rope root Rope root int n
Rope tmp new Rope;
tmpparent NULL;
tmpleft root;
tmpright root;
rootparent rootparent tmp;
tmplCount n;
tmpstr NULL;
root tmp;
void deletedint i int j Rope& root
for ; i j; i
rooti;
int main
Rope root NULL;
char aHi ;
int n sizeofa sizeofa;
createRopeStructureroot NULL, a n;
Rope root NULL;
char b "How are you";
int n sizeofb sizeofb;
createRopeStructureroot NULL, b n;
Rope root NULL;
concatenateroot root root n;
printstringroot;
cout endl;
return ;
deletedn n root;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
