ya əun 10 saua Step 1: create a array named result that's n! in si: This will be a two-dimensional array. int[][] foo = new int[6][]; Will allocate an array of 6 int arrays. Step 2: if the size of the input array, arr, is 1 关
ya əun 10 saua Step 1: create a array named result that's n! in si: This will be a two-dimensional array. int[][] foo = new int[6][]; Will allocate an array of 6 int arrays. Step 2: if the size of the input array, arr, is 1 关
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
How to implement this method
![Permute the elements of the array.
Step 1: create a array named result that's n! in size
This will be a two-dimensional array.
<pre>
int[][] foo = new int[6][];
</pre>
Will allocate an array of 6 int arrays.
Step 2: if the size of the input array, arr, is 1
insert it into result at index zero,
then return from the function.
Step B: for each element i of the array arr, create
a smaller array, sm, with that element removed.
Step 4: For each array in the smaller array, append
arr[i], and put the return value in result.
Step 5: return the result.
int[][] permutation(int[] arr);](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fdc88626a-4317-4667-9c61-42c19d7a8a1b%2F7d40238d-187c-4fd2-b38d-2499377c34d2%2Fygu39r2b_processed.jpeg&w=3840&q=75)
Transcribed Image Text:Permute the elements of the array.
Step 1: create a array named result that's n! in size
This will be a two-dimensional array.
<pre>
int[][] foo = new int[6][];
</pre>
Will allocate an array of 6 int arrays.
Step 2: if the size of the input array, arr, is 1
insert it into result at index zero,
then return from the function.
Step B: for each element i of the array arr, create
a smaller array, sm, with that element removed.
Step 4: For each array in the smaller array, append
arr[i], and put the return value in result.
Step 5: return the result.
int[][] permutation(int[] arr);
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Step 1
Complete main2D.c file:
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#define DIM_1 10
#define DIM_2 5
int main(int argc, char **argv)
{
int i,j;
int count = 0;
int rc = 0;
int **arr = NULL;
// allocating memory for the arrray of pointers to int array
arr = (int **) malloc(sizeof(int *) * DIM_1);
// initialize the pointers to NULL
for (i = 0; i < DIM_1; i++) arr[i] = NULL;
// allocate memory for each element in the array arr
// each element should contains the address of a 1D array of DIM_2 elements each of type int
for (i = 0; i < DIM_1; i++)
{
arr[i]= (int *) malloc(sizeof(int) * DIM_2);
}
// populate the array (using 2 for loops)
count = 1;
// outer loop of size DIM_1
for (i = 0; i < DIM_1; i++)
{
// inner loop of size DIM_2
for (j = 0; j < DIM_2; j++)
{
// set array element to count
arr[i][j] = count;
// increment count by 1
count += 1;
}
}
// print the array (using 2 for loops)
for (i = 0; i < DIM_1; i++)
{
// inner loop of size DIM_2
for (j = 0; j < DIM_2; j++)
{
// print array element at index [i][j]
printf("%d\t", arr[i][j]);
}
// leave a line after printing one row
printf("\n");
}
return(0);
}
Output Screenshot:
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Recommended textbooks for you
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY