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...
icon
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);
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
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:

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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…
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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY