1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aalyn [17]
2 years ago
6

Construct sequence using a specified number of integers within a range. The sequence must be strictly increasing at first and th

en strictly decreasing. The goal is to maximize the sequence array elements starting from the beginning. For example, [4, 5, 4, 3, 2] beats [3,4,5,4,3] because its first element is larger, and [4, 5, 6, 5, 4] beats [4,5,4,3,2] because its third element is larger. Given the length of the sequence and the range of integers, return the winning sequence. If it is not possible to construct such a sequence, return -1. Write an algorithm that returns a winning sequence and -1 if the sequence is not possible. Input The input to the function/method consists of three arguments: num : an integer representing the size of sequence to create lower End : an integer representing the lower end of integer range upperEnd : an integer representing the upper end of integer range.
Computers and Technology
1 answer:
natulia [17]2 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It first creates a function that takes in the three parameters to create the sequence, if the sequence is valid it returns the created sequence, otherwise it prints -1 and returns an empty array. The second function called compareSequences takes in to sequences as parameters and compares them, printing out the winner. A test case has been provided in the main method and the output can be seen in the image below.

import java.util.Arrays;

class Brainly {

   public static void main(String[] args) {

       int[] seq1 = createSequence(5, 4, 2);

       int[] seq2 = createSequence(5, 3, 3);

       System.out.println("Winner: " + Arrays.toString(compareSequences(seq1, seq2)));

   }

   public static int[] createSequence(int num, int upperEnd, int lowerEnd) {

       int[] myArray = new int[num];

       int middle = (int) Math.floor(num/2.0);

       myArray[0] = upperEnd;

       myArray[num-1] = lowerEnd;

       int currentValue = upperEnd;

       for (int i = 1; i < num-1; i++) {

           if (i <= middle) {

               myArray[i] = currentValue + 1;

               currentValue += 1;

           } else {

               myArray[i] = currentValue - 1;

               currentValue += 1;

           }

       }

       System.out.println(Arrays.toString(myArray));

       if (myArray[num-2] < lowerEnd) {

           System.out.println("-1");

           int[] empty = {};

           return empty;

       } else {

           return myArray;

       }

   }

   public static int[] compareSequences(int[] seq1, int[] seq2) {

       int lowestLength;

       if (seq1.length > seq2.length) {

           lowestLength = seq2.length;

       } else {

           lowestLength = seq1.length;

       }

       for (int i = 0; i < lowestLength; i++) {

           if (seq1[i] > seq2[i]) {

               return seq1;

           } else if (seq1[i] < seq2[i]) {

               return seq2;

           }

       }

       if (seq1.length > seq2.length) {

           return seq1;

       } else {

           return seq2;

       }

   }

}

You might be interested in
Define the following functions related to spreadsheet:<br> a.Consolidate<br> b.Subtotal
Vikki [24]

Answer:

B I hope I'm right sorry if I'm wrong

4 0
3 years ago
The _______ displays the data series in separate columns side-by-side so that you can compare the relative heights of the column
k0ka [10]

Answer:

Cluster Column Charts.

Explanation:

Clustered column chart:-It displays multiple data series in separate vertical columns. Each series have the same axis labels.Clustered vertical columns thus allow direct comparison of multiple data series.When having three data series you can compare their heights also.So we conclude the answer is Cluster Column Charts.

3 0
3 years ago
Read 2 more answers
Fill in the blank with the correct response.
Verizon [17]

Answer:

File structure.

Explanation:

HTML is an acronym for hypertext markup language and it is a standard programming language which is used for designing, developing and creating web pages.

Generally, all HTML documents are divided into two (2) main parts; body and head. The head contains information such as version of HTML, title of a page, metadata, link to custom favicons and CSS etc. The body of the HTML document contains the contents or informations of a web page to be displayed.

The file transfer protocol (FTP) client component of a full-featured HTML editor allows you to synchronize the entire file structure. Therefore, when you wish to share your entire html document over a network server such as a FTP client, you should use a full-featured HTML editor.

6 0
3 years ago
Social media tools allow you to connect with people anywhere in the world who share your interests evaluate your interactions wi
babymother [125]

The social media tools that you used to form these connections are:

  • Buzz Sumo.
  • Go ogle Trends.
  • Buffer Publish.
  • Can va.
  • Un splash

<h3>What are social media tools?</h3>

Social media tools are known to be key tools that are used for the running of business so as to handle important ways in their Digital Marketing routine.

The social media tools are important because it helps one to plan ahead and also  ensure that a person post the type of content needed to reach your goals and grow one's business.

Learn more about  social media from

brainly.com/question/3653791

5 0
2 years ago
Infrastructure as a Service (IaaS) replaces the _________ of the computer hierarchy with an Internet-based infrastructure.
snow_tiger [21]

Answer:

Digital level logic through machine level

Explanation:

Infrastructure as a Service can be regarded as computing cloud services that allows computation, storage, server in the cloud.it helps the user to access infrastructure in the cloud

Digital level logic which is in digital circuit that allows boolen expression, it allows signals as well as sequence to be expressed in form of numbers, it is usually view as been complicated but not.

It should be noted that Infrastructure as a Service (IaaS) replaces the Digital level logic through machine level of the computer hierarchy with an Internet-based infrastructure.

5 0
3 years ago
Other questions:
  • Torque is defined as _____.
    7·1 answer
  • While ________ is centered on creating procedures, ________ is centered on creating objects. Procedural programming, class progr
    10·1 answer
  • A customer has a new laptop with wireless WAN capabilities; however, the software does not connect to the Internet. What would y
    13·1 answer
  • How do you render and export files on blender
    6·1 answer
  • Explain set associative mapping<br>​
    10·1 answer
  • 1)What is the hydropower resources/energy?
    7·1 answer
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
  • If person A creates an image with a creative common license. Person B then uses the image on his website. Who own the image and
    7·1 answer
  • What are three coding languages that are used to build websites?
    12·1 answer
  • When methods have ____, other programs and methods may use the methods to get access to the private data.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!