Arrays
Tutorial 1:
Q1: Define data structure. What do you mean by Linear and non-linear data structure? Give
example.
Q2: List out the areas in which data structures are applied extensively. Also list the various
operations that can be performed on data structure.
Q3: In image processing, pixels are accessed in both row and column fashion.
Discuss how the choice between row-major and column-major storage can affect image
manipulation performance.
Q4: Suppose you're given a library written in Fortran (uses column-major order), and your C
program (uses row-major order) has to pass 2D arrays to it.
What precautions or transformations would you need to perform to ensure data is interpreted
correctly?
Q5: Consider the following structure
struct test
{
int A[3][2]; //Integer takes-4 bytes
char B[10]; //Char takes-1 bytes
float C[2][2]; // float takes-8 bytes
}struct test * next;
struct test r[20];
If the base address of r is 200. What is the address of C[1,1]?
Q6: Suppose there is an integer array M(5,8), the address of M(0,0), M(0,3) and M(1,2) are 100,
106 and 120 respectively, what is the address of M(4,5)?
Q7: You are told a 2D array M[3][3] is stored starting from memory address 500, and each
element is 4 bytes.
You are given the address of M[1][2] as 548.
Can you deduce whether the array is stored in row-major or column-major order? Show
calculations.