We are given an integer type array containing both positive and negative numbers, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that there will be a positive number that will be surrounded by negative numbers. If there are more positive and negative numbers, then they will be arranged at the end of an array.Let us see various input output scenarios for this −Input − int arr[] = {-1, -2, -3, 1, 2, 3}Output − Array before Arrangement: -1 -2 -3 1 2 3 Rearrangement of an array in alternating positive & negative ... Read More
To create a base R plot without axes but keeping the frame of the plot, we can set axes argument to FALSE and frame.plot argument to TRUE.For example, if we have a vector called V and we want to create a plot of V without axes but with the frame of the plot then, we can use the command given below −plot(V,axes=FALSE,frame.plot=TRUE)Check out the below example to understand how it works.ExampleConsider the following snippet −x
We are given a positive integer type array, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that when we multiply an element with its alternative element and then add all the resultant elements then it should return the minimum sum.Let us see various input output scenarios for this −Input − int arr[] = {2, 5, 1, 7, 5, 0, 1, 0}Output − Rearrangement of an array to minimize sum i.e. 7 of product of consecutive pair elements is: 7 0 5 0 5 1 2 1Explanation − we are given an integer array ... Read More
We are given a positive integer type array, let's say, arr[] of any given size. The task is to rearrange an array in such a manner that all the elements present at an odd index should value greater than the element presents at an even index and print the result.Let us see various input output scenarios for this −Input − int arr[] = {2, 1, 5, 4, 3, 7, 8}Output − Array before Arrangement: 2 1 5 4 3 7 8 Rearrangement of an array such that every odd indexed element is greater than it previous is: 1 4 2 5 3 ... Read More
If we have frequency data then we first need to find the total data or complete data by repeating the values up to the frequency corresponding to each value after that we can apply var function on this complete data.For Example, if we have a data frame called df that contains two columns say X and Frequency then we can find the total data by using the command given below −Total_data
We are given a positive integer type array, let's say, arr[] of any given size such that elements in an array should value greater than 0 but less than the size of an array. The task is to rearrange an array in such a manner that if arr[i] is ‘i’, if ‘i’ is present in an array else it will set the arr[i] element with the value -1 and print the final result.Let us see various input output scenarios for this −Input − int arr[] = {0, 8, 1, 5, 4, 3, 2, 9 }Output − Rearrangement of an array such that ... Read More
The autocorrelation plot or ACF plot is a display of serial correlation in data that changes over time. The ACF plot can be easily created by using acf function.For example, if we have a vector called V then we can create its autocorrelation plot by using the command acf(V). If we want to extract autocorrelation values then we would need to save the plot values in an object by using the below command. This will not create the plot.Autocorrelation_x
To find the row mean of all matrices stored in an R list, we can use sapply function along with rowMeans function.For example, if we have a list called LIST that contains some matrices then the row means for each matrix can be found by using the following command −sapply(LIST,rowMeans)Check out the below example to understand how it works.ExampleFollowing snippet creates the matrices −M1
If we have frequency data then we first need to find the total data or complete data by repeating the values up to the frequency corresponding to each value after that we can apply median function on this complete data.For Example, if we have a data frame called df that contains two columns say X and Frequency then we can find the total data by using the following command −Total_data
We are given a positive integer type array, let's say, arr[] of any given size such that elements in an array should value greater than 0 but less than the size of an array. The task is to rearrange an array in such a manner that if arr[j] is ‘j’ then arr[j] becomes ‘i’ and print the final result.Let us see various input output scenarios for this −Input − int arr[] = {3, 4, 1, 2, 0}Outpu t− Array before Arrangement: 3 4 1 2 0 Rearrangement of an array such that arr[j] becomes i if arr[i] is j is: 4 ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP