Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ please, thank you! Assume you get a job with a starting salary of $50 k/year. Every year, your salary increases by 10%, plus

In C++ please, thank you!

  1. Assume you get a job with a starting salary of $50 k/year. Every year, your salary increases by 10%, plus a 5 k linear increase. So your salary for the second year will be 50*1.1 + 5 = 60 k. In this problem, you will write a recursive function to compute your salary for year n. The answers to part a and b will help you write your recursive function
    1. What is your salary at time 0?
    2. If your salary for year n-1 is sn-1 then what is your salary for year n?
    3. Write a recursive function int salary(int n) to compute your salary for year n. Only recursive solutions allowed.
    4. Test your function in your main().

2. In this problem, you will be asked questions to help you write a recursive function

bool isSorted(int a[], int n)

to determine whether an array a is in sorted order. An array is in sorted order if a[0] a[1] a[2] a[n-1].

  1. How do you tell if an array with two elements is sorted?
  2. Assume that the first n-1 elements in the array are sorted. How do you tell if the array is still sorted when you add the nth element?
  3. Write a recursive function bool isSorted(int a[], int n) that returns true if the first n elements of the array a are in sorted order, and false otherwise. Your function must be recursive.
  4. Test your function in your main().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Object Oriented Deductive Hypermedia Technologies

Authors: Kamran Parsaye, Mark Chignell, Setrag Khoshafian, Harry Wong

1st Edition

0471503452, 978-0471503453

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago