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
yulyashka [42]
3 years ago
8

we are given an array a consisting of n distinct integers. we would like to sort array A into ascending order using a simple alg

orithm. First we divide it into one or more slieces ( a slice is a contiguous sub array. Then we sort each slice. After that, we join the sorted slices in the same order. Write a function solution that returns the max number of slices for which the algorithm will return a correctly sorted array

Computers and Technology
1 answer:
marta [7]3 years ago
4 0

Answer:

Check the explanation

Explanation:

the js code is as follows

function count_max_group(ar) {

if (ar.length < 2) return ar.length; // if no of elements are 2 then max groups are 2

let st = [0]; // stack to store the groups

for (let i = 1; i < ar.length; i++) {

if (ar[i] >= ar[i - 1]) st.push(i); // pushing elements if if ar[i] is greater than the previous element

for (let j = i; j > 0 && ar[j] < ar[j - 1]; j--) { // finding the max number of grps

swap(ar, j, j - 1); // swapping

if (j <= st[st.length - 1]) st.pop();

}

}

return st.length;

}

function swap(a, i, j) { // function to swap two variables

let t = a[i];

a[i] = a[j];

a[j] = t;

}

//sample solutions

console.log("the sample solutions are\n");

console.log("[2,1,6,4,3,7]\n");

console.log(count_max_group([2,1,6,4,3,7]));

console.log("[4,3,2,6,1]\n") ;

console.log(count_max_group([4,3,2,6,1]));

console.log("[2,4,1,6,5,9,7]\n");

console.log(count_max_group([2,4,1,6,5,9,7]));

You might be interested in
Tightly.
Radda [10]

Answer:

AG 6.

AG 1.

AG 3.

AG 4.

AG 7.

AG 5.

AG 2.

Explanation:

Chronology can be defined as an arrangement of data, items or documents in the order in which they occurred or happened (in time), from the earliest to the most recent or latest.

Simply stated, ordered events are organized in order of time and this process is known as chronology.

Generally, a chronology can be used as a filing process in various areas such as schools, hospitals, hotels, and business firms to help put data (informations) in order by time or date.

In Computer networking, a cable can be defined as a wired connector used for connecting and transmitting signals between two or more network devices such as CAT-5, CAT-6 and fiber optic cables. These cables which are either twisted or untwisted pair are to be crimped in order to make them eligible and appropriate for use in connecting network devices.

Furthermore, there are two (2) color codes used for the arrangement of the wires in a network cable based on the type of network connection;

I. For straight-through, host device to a router or switch;

Color code: white-orange, orange, white-green, blue, white-blue, green, white-brown, brown.

II. For cross-over, network device to a network device e.g router or router;

white-green, green, white-orange, blue, white-blue, orange,

5 0
3 years ago
What e-reader technology males a screen that is easy to read and extends battery life
lidiya [134]
I personally use the Kindle Paperwhite series, but any with an E-ink display will work great, as the display isn't very battery-consuming.
6 0
3 years ago
Fix the regular expression used in the rearrange_name function so that it can match middle names, middle initials, as well as do
marysya [2.9K]

Answer:

name = re.search(r"^([\w \.-]), ([\w \.-])$", list_name)

Explanation:

Regular expression is used to simplify the mode in which items in a data structure are for. It uses wildcards as shortcuts.

The python module for regular expression is 're'. The import statement is used to get the module and the search() method of the module is used to get the one matching item while the findall() method is used to get a list of all the matching items in a data structure.

7 0
3 years ago
Stacy's job involves direct coordination and communication with end users. Which option describes her job role?
masha68 [24]

Answer:

Stacy works as a Customer Service Representative.

Explanation:

Since Stacy uses coordination and communication, she would best fit the criteria for costumer service. A Customer Service Representative (CSR) helps customers out with questions about a business, including directions, finances, and other benefits of her company.

3 0
3 years ago
A larger gear will produce more torque: true or false
aliina [53]
Power is force multiplied by velocity. The engine power is actually (relatively) constant regardless of the gear. So when people say there is "more power" in a lower gear, it's the common misconception that "more powerful" is "more forceful" but that's only part of the equation.

So if P is constant, then that means if you can combine a large force and a low velocity or a low force and large velocity for the same power.

When you put it in a low gear, you produce a large torque -- or a large force -- and a low velocity.

For example, if you are towing a trailer or trying to climb a very steep grade, you need the force to be large which is why you put it in a low gear. If you are on something slippery like snow or ice, a high gear will keep the force at the wheels low so the tires don't exceed the coefficient of friction and spin.
8 0
3 years ago
Other questions:
  • La inteligencia o unidad lógica de un computador se denomina como??? Software, Hardware CPU o que, ayuda.....
    7·1 answer
  • .The __________ comes in handy when I'm using Microsoft Word to type an essay with a specific word number requirement
    6·1 answer
  • Assume that a is an array of two or more integers, and that b and c are integers.
    13·1 answer
  • The _______ of a secondary storage device indicates how much data the storage medium can hold.
    13·1 answer
  • Brainliest for whoever adds me on snap<br> gianavaughn007
    15·2 answers
  • Which of these is a type of social engineering attack?
    10·1 answer
  • What does CPU stand for
    7·1 answer
  • Write the pseudocode for this flowchart
    6·1 answer
  • Why are my texts green when texting another iphone.
    14·1 answer
  • What makes a recipe for a meal an example of an algorithm?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!