adplus-dvertising

Welcome to the Arrays and Pointers MCQs Page

Dive deep into the fascinating world of Arrays and Pointers with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Arrays and Pointers, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Arrays and Pointers, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Arrays and Pointers. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Arrays and Pointers. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Arrays and Pointers MCQs | Page 13 of 15

Explore more Topics under Data Structures and Algorithms

Discuss
Answer: (a).The fraction of zero elements over the total number of elements
Q122.
How would you store an element in a sparse matrix?
a)

public void store(int row_index, int col_index, Object val)
{
        if (row_index < 0 || row_index > N)
 {
            System.out.println("row index out of bounds");
   return;
 }
        if (col_index < 0 || col+index > N)
 {
            System.out.println("column index out of bounds");
   return;
 }
        sparse_array[row_index].store(col_index, val);
}

b)

public void store(int row_index, int col_index, Object val)
{
        if (row_index < 0 || row_index > N)
 {
            System.out.println("column index out of bounds");
   return;
 }
        if (col_index < 0 || col+index > N)
 {
            System.out.println("row index out of bounds");
   return;
 }
        sparse_array[row_index].store(col_index, val);
}

c)

public void store(int row_index, int col_index, Object val)
{
        if (row_index < 0 && row_index > N)
 {
            System.out.println("row index out of bounds");
   return;
 }
        if (col_index < 0 && col+index > N)
 {
            System.out.println("column index out of bounds");
   return;
 }
        sparse_array[row_index].store(col_index, val);
    }

d)

public void store(int row_index, int col_index, Object val)
{
        if (row_index < 0 && row_index > N)
 {
            System.out.println("column index out of bounds");
   return;
 }
        if (col_index < 0 && col+index > N)
 {
            System.out.println("row index out of bounds");
   return;
 }
        sparse_array[row_index].store(col_index, val);
}

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (a).a
Q123.
What is the functionality of the following piece of code?
{
        if (row_index < 0 || col_index > N)
 {
            System.out.println("column index out of bounds");
   return;
 }
        return (sparse_array[row_index].fetch(col_index));
}
Discuss
Answer: (b).Get the element from the specified position
Q124.
What are the advantages of sparse matrices over normal matrices?
Discuss
Answer: (d).All of the mentioned
Discuss
Answer: (a).number of rows X number of columns
Q126.
Which of the following property does not hold for matrix multiplication?
Discuss
Answer: (c).Commutative
Q127.
How do you allocate a matrix using a single pointer in C?(r and c are the number of rows and columns respectively)
Discuss
Answer: (b).int *arr = (int *)malloc(r * c * sizeof(int));
Q128.
Select the code snippet which performs matrix multiplication.(a and b are the two given matrices, resultant marix is c)
a)

for (int i = 0; i < n; i++)
{
    for (int j = 0; j < n; j++)
    {
        for (int k = 0; k < n; k++)
        {
            c[i][j] = c[i][j] + a[i][k] * b[k][j];
        }
    }
}

b)

for (int i = 0; i < n; i++)
{
    for (int j = 0; j < n; j++)
    {
        for (int k = 0; k < n; k++)
        {
            c[i][j] = c[i][j] * a[i][k] * b[k][j];
        }
    }
}

c)

for (int i = 0; i < n; i++)
{
    for (int j = 0; j < n; j++)
    {
        for (int k = 0; k < n; k++) 
        {
            c[i][j] = c[i][j] + a[i][k] + b[k][j];
        }
    }
}

d) None of the mentioned

a.

a

b.

b

c.

c

d.

d

Discuss
Answer: (a).a
Q129.
What does the following piece of code do?
for(int i = 0; i < row; i++)
{  
    for(int j = 0; j < column; j++)
    {
        if(i == j)
            sum = sum + (array[i][j]);
    }
}
System.out.println(sum);
Discuss
Answer: (b).Trace of a matrix
Q130.
If row-major order is used, how is the following matrix stored in memory?
a b c

d e f

g h i
Discuss
Answer: (b).abcdefghi

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!