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]
4 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]4 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
Sort Sorts by value; assign new numbers as the keys.
JulijaS [17]

Answer: (a) sort()

Explanation:

Using sort() the keys are not preserved. However it sorts the array.

example : sort($array);

6 0
4 years ago
Which number is equivalent to 3e-2?<br><br> 30<br><br> 0.03<br><br> 0.3<br><br> 3
nevsk [136]

Answer:

0.03

Explanation:

3e-2 is in scientific notation, also known as standard form. Used to write large or small numbers in another way. In the number 3e-2, the numbers are defined as follows:

3 = coefficient

e = 10 to the power of

-2 = exponent

The scientific notation 3e-2 is same as 3 x 10^-2 or 3 x 10-2. Thus, to get the answer to 3e-2 as a decimal, we multiply 3 by 10 to the power of -2.

= 3e-2

= 3 × 10-2

= 0.03

3 0
2 years ago
What is the fifth-generation wireless broadband technology based on the 802.11ac standard engineered to greatly increase the spe
kirza4 [7]

Answer:

The fifth-generation wireless broadband technology based on the 802.11ac standard is called the

5G.

Explanation:

The 5G is the newest baby in town in the area of wireless broadband technology.  The technology is based on the IEEE 802.11ac standard. 5G operates with a 5Ghz signal and is set to offer out-of-this-world speeds of up to 1 Gb/s.  This implies massive connectivity for everyone and everything.  However, its trial has been fraught with many challenges.  Questions have been raised, especially relating to some health concerns about the technology.  However, many advantages have been ascribed to this wireless technology.  They include more reliability, massive network capacity, increased availability, more uniform user experience, higher performance. and improved efficiency.

4 0
3 years ago
The ampacity of a No. 12 aluminum wire with RHW insulation installed in a raceway that has 19 other wires is
GREYUIT [131]
<span>i believe the answer is C</span>
7 0
3 years ago
Which evaluation factor will be most important when choosing technology for the company
soldier1979 [14.2K]

Answer and Explanation:

Look for a company's latest updates, see what servers they use, check if they're using the latest technology like containers or AI and look for how flexible they are with regards to change and innovation.

7 0
3 years ago
Other questions:
  • In pre-shared key mode, a passphrase should be at least ________ characters long.
    15·1 answer
  • If parties in a contract are not _______, the contract can be canceled.
    7·1 answer
  • _ is a model of computing in which computer processing, storage, software, and other services are provided as a shared pool of v
    10·1 answer
  • Which of the following statements is not true about proper tire care? a.If you see a wear bar across the width of the tread whil
    14·2 answers
  • Why is it important for people to express resentments in the workplace?
    9·1 answer
  • Why do the holes at the top of parachutes make it go slower
    12·1 answer
  • You have been asked to create a Community leveraging Out-of-the-box login, logout, self-registration, and error pages. Would you
    5·1 answer
  • When writing about environment concerns, which topic would demonstrate civic-mindedness on a global scale?
    11·2 answers
  • Jason has decided to use his name on all the images to protect them from misuse. He has also decided to use the logo of his comp
    15·2 answers
  • Based on what you know about the Sort and Find functions, return to the database file to determine the answers to the following
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!