Question: need help with a computer science lab in C++ language the lab is over recursion and we can not use any conditional statements in our
need help with a computer science lab in C++ language
the lab is over recursion and we can not use any conditional statements in our coding
here is the lab assignment:
Lab: Recursion Fun - TEST YOUR MIGHT! No loops allowed for this lab: -no for loops -no while loops -no do-while's -no while-do's -no for-while's -no while-for-do's #5: Write a recursive function 'void reverseArray(doulbe * numbers, int start, int end)' which reverses the order of elements in the given array from index start to index end (inclusive). #6: Write a function 'int threeSum(int n)' which returns the value 1+2+3+4+...+ 3n. #7: Write recursive "printForward(node *p)" and "printBackward(node * p)" methods for the linked list class provided below so that the following test code words as specified in the comments: linkedList list; list.push_front(8); list.push_front(7); list.push_front(6); list.push_front(5); list.push_front(4); list.push_front(3); list.push_front(2); list.push_front(1); list.printForwards(); //1,2,3,4,5,6,7,8, cout << endl; list.printBackwards(); //8,7,6,5,4,3,2,1, cout << endl; class linkedList { private: class node { public: double data; node * next; node(double x) { data = x; next = NULL; } }; node * head; //print the contents of the list from p to the end (no loops!) void printForwards(node * p) { } //print the contents of the list from p to the end but in reverse order! void printBackwards(node * p) { } public: linkedList() { head = NULL; } void push_front(double x) { node * babyNode = new node(x); babyNode->next = head; head = babyNode; } void printForwards() { printForwards(head); } void printBackwards() { printBackwards(head); } };
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
