In java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed. Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated. Develop a function that returns true if the elements are in decreasing order and false otherwise.  A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks.  Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing.  Develop a function that takes a string and a single character, then returns a list of the indexes in the string where the character occurs. For example, given the string “bookkeeper” and ‘e’, the function would return {5, 6, 8} since ‘e’ occurs at those positions. Return an empty list if the character does not appear in the string even once.  Develop a function that takes two lists of integers and returns a list containing any value that appears in both parameter lists.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question

In java there must be at least two calls to the function with different arguments and the output must clearly show the task being performed.

  1. Develop a function that accepts an array and returns true if the array contains any duplicate values or false if none of the values are repeated.

  2. Develop a function that returns true if the elements are in decreasing order and false otherwise.

  3.  A “peak” is a value in an array that is preceded and followed by a strictly lower value. For example, in the array {2, 12, 9, 8, 5, 7, 3, 9} the values 12 and 7 are peaks. Develop a function that returns the number of peaks in an array of integers. Note that the first element does not have a preceding element and the last element is not followed by anything, so neither the first nor last elements can be peaks.

  4.  Develop a function that finds the starting index of the longest subsequence of values that is strictly increasing. For example, given the array {12, 3, 7, 5, 9, 8, 1, 4, 6}, the function would return 6, since the subsequence {1, 4, 6} is the longest that is strictly increasing.

  5.  Develop a function that takes a string and a single character, then returns a list of the indexes in the string where the character occurs. For example, given the string “bookkeeper” and ‘e’, the function would return {5, 6, 8} since ‘e’ occurs at those positions. Return an empty list if the character does not appear in the string even once.

  6.  Develop a function that takes two lists of integers and returns a list containing any value that appears in both parameter lists.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Arrays
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning