Question
2.2 Printing Long Integers [10 points] Write two recursive C++ functions with the following prototypes that print the decimal digits of the passed argument forward
2.2 Printing Long Integers [10 points] Write two recursive C++ functions with the following prototypes that print the decimal digits of the passed argument forward (most-to least-significant digit) and backward (least-to most-significant digit), respectively, with a space after each digit. Each recursive call should print one digit and space. Leading zeros are not printed. void print_long_fwd(unsigned long long val); void print_long_bwd(unsigned long long val);Example:Input: 1234567890fwd Output: 1 2 3 4 5 6 7 8 9 0 bwd output: 0 9 8 7 6 5 4 3 2 1 2.3Matching Index [20 points]Matching index in an array A[1. .. n-1] is defined to be an index such that A[i] = i. Given a sorted array of distinct integers, write a recursive method to find a matching index, if one exists, in array A if not return -1. Your algorithm should run in 0(log n). Hint: Use binary search to solve this problem. Example: Input: A = { -1, 0, 1, 2, 4, 10} Output: 4 2.4 Subset [25 points] Given a set of distinct integers, write a recursive function that return all possible subsets (the power set). Note: The number of sets is 2n where n is the number of elements in the given set. The solution set must not contain duplicate subsets. You can use vectors to print the sets with no duplicates. Example: Input: nums = [1,2,3]Output: [[3], [1], [2], [1,2,3], [1,3], [2,3], [1,2], []] 2.5 Recursive Multiply [25 points] Write a recursive function to multiply two positive integers without using the * operator (or / operator). You can use addition, subtraction, and bit shifting, but you should minimize the number of those operations. All the functions from 2.2 to 2.5 along with your test code should go into a file called Assign2_Q2.cpp. Make sure your code works correctly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started