Goal: Learn how to use recursive functions. General requirement: Use cout to fully demonstrate your works....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Goal: Learn how to use recursive functions. General requirement: Use cout to fully demonstrate your works. The output must clearly show how each of these tasks work. If no output is displayed for a task below, 0 point will be given to the task. If the output is not clear, some points may be deducted. Task 1 - Reverse array (5 pts) Given an integer array like: const int SIZE =9; int arrint[SIZE]=(1,2,3,4,5,6,7,8,9): Use a recursive function to reverse the array. Task 2 - Array sum: for loop verslon (5 pts) Use a for loop to add the integers of the array in Task 1 and display the sum. Task 3 - Array sum: Linear recursive version (5 pts) Use a linear recursive function to add the integers of the array in Task 1 and display the sum. Task 4 - Array sum: Binary recursive version (5 pts) Use a binary recursive function to add the integers of the array in Task 1 and display the sum. Write recursive function in c++ of following functions 1. Write a recursive function int binarySearch(int[] a, int start, int end, int x) that uses the binary search algorithm to check whether the sorted array a contains the element x anywhere between indices start and end, inclusive. Function should return index of element 'x' if it exists in the array and return -1 otherwise. 2. Write a recursive function of MergeSort to sort an array in ascending order 3. Write a recursive function Sum that takes a two-dimensional array and returns sum of its all elements. Goal: Learn how to use recursive functions. General requirement: Use cout to fully demonstrate your works. The output must clearly show how each of these tasks work. If no output is displayed for a task below, 0 point will be given to the task. If the output is not clear, some points may be deducted. Task 1 - Reverse array (5 pts) Given an integer array like: const int SIZE =9; int arrint[SIZE]=(1,2,3,4,5,6,7,8,9): Use a recursive function to reverse the array. Task 2 - Array sum: for loop verslon (5 pts) Use a for loop to add the integers of the array in Task 1 and display the sum. Task 3 - Array sum: Linear recursive version (5 pts) Use a linear recursive function to add the integers of the array in Task 1 and display the sum. Task 4 - Array sum: Binary recursive version (5 pts) Use a binary recursive function to add the integers of the array in Task 1 and display the sum. Write recursive function in c++ of following functions 1. Write a recursive function int binarySearch(int[] a, int start, int end, int x) that uses the binary search algorithm to check whether the sorted array a contains the element x anywhere between indices start and end, inclusive. Function should return index of element 'x' if it exists in the array and return -1 otherwise. 2. Write a recursive function of MergeSort to sort an array in ascending order 3. Write a recursive function Sum that takes a two-dimensional array and returns sum of its all elements.
Expert Answer:
Related Book For
Organizational Behaviour Concepts Controversies Applications
ISBN: 978-0132310314
6th Canadian Edition
Authors: Nancy Langton, Stephen P. Robbins, Timothy A. Judge, Katherine Breward
Posted Date:
Students also viewed these computer network questions
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
can someone solve this Modern workstations typically have memory systems that incorporate two or three levels of caching. Explain why they are designed like this. [4 marks] In order to investigate...
-
What does it mean that flame is non-luminous it is yellow it is invisible It has a very bright blue inner cone it is dark
-
The basic concepts in this problem are presented in Multiple - Concept Example 9. A 225-kg crate rests on a surface that is inclined above the horizontal at an angle of 20.0o. A horizontal force...
-
Define investigative psychology.
-
The financial statements and industry norms are shown below for the Congo Mining Company: a. Compute the financial ratios for Congo to compare both for 2017 and 2018 against the industry norms. b....
-
Munoz Sporting Equipment manufactures baseball bats and tennis rackets. Department B produces the baseball bats, and Department T produces the tennis rackets. Munoz currently uses plant wide...
-
a) Explain the following terms as used in real estate appraisals i. Value in use ii. iii. Liquidation value Insurable value b) Describe the cost approach of real estate valuation c) Explain the...
-
Which graphs represent an object that is slowing down? A. 2 and3 B. 2 and 4 C. 1 and 4 D. 1 and 2 E. 1 and 3 F. 3 and 4 1.0 Velocity (m/s) Velocity (m/s) 0.0 0 1.0 0.5 0.0 0 2 2 4 (1) (3) 6 Time (s)...
-
Suppose Illini Company prepaid $6,000 in rent for the next three years ($2,000 per year) on 12/31/2022. Illini's annual pre-tax GAAP income for 2022-2025 was $20,000. The applicable tax rate was 30%....
-
What is the purpose of the healthcare quality improvement act? Explain
-
In a context of a for-profit company manufacturing a tangible product, operating expenses include the following: Promotion costs, administrative salaries, overhead costs, along with expensed research...
-
My boss would like this quarter's contribution to come from our department and cover a current topic in financial accounting and reporting
-
A measurement alternative may be elected for an investment in equity securities if the Listed prices of the investment are available and the investment does not result in control or significant...
-
Cost assignment and cost allocation are used to support and explain the relationship between cost drivers and cost objects in assigning product costs. The relationship of direct materials, direct...
-
Make an argument that Williams had a right to delay the closing until after August 1.
-
Herman Miller is a Michigan-based furniture company that is known for its innovative design products. The company, which is publicly owned and over 75 years old, operates in over 110 countries on...
-
What are the pros and cons of variable-pay programs from an employees viewpoint? From managements viewpoint?
-
"The cognitive evaluation theory is contradictory to reinforcement and expectancy theories." To you agree or disagree? Explain.
-
What is the Standard Industrial Classification (SIC)? In what ways might such a classification system be useful? Can you think of any limitations or problems such a system might have over time?
-
1. In what ways did the defence industries respond to the ending of the Cold War? 2. Using an Internet search, find out how the defence and security industries have responded to the threat of...
-
Explain why the business objectives of owners and managers are likely to diverge. How might owners attempt to ensure that managers act in their interests and not in the managers own interests?
Study smarter with the SolutionInn App