Design a function in a sequence (part 2)
  • Posted: 4 years ago
  • Updated: 3 years ago
  • Edit
  • answers (1)
  • views (1681)

In Design a function in a sequence (part 1) , can you perform invert() without using last() ?


Posted Answers

We can perform invert() by keeping two temporary sequence without using last() .


invert_w/o_last(){
/* Two temporary sequence */
S temp1, temp2;
/* using invert() from above */
reverse original sequence into temp1;
reverse temp1 into temp2;
reverse temp2 into original sequence;

}

You need to Sign In to post your solution.