UNIT 1 Flashcards

1
Q

Array

A
1. Collection of data which has similar data types
#include   
void main ()  
{  
    int marks[6] = {56,78,88,76,56,89);  
    int i;    
    float avg;  
    for (i=0; i<6; i++ )   
    {  
        avg = avg + marks[i];   
    }    
    printf(avg);   
}   
 2.Marks[0] denotes the marks in first subject, marks[1] denotes the marks in 2nd subject and so on.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Advantages of Array

A
  • Single name for the group of variables of the same type,Which makes easier to remember the elements in the array
  • Traversing an array is a very simple process, we just need to increment the base address of the array in order to visit each element one by one.
  • Any element in the array can be directly accessed by using the index.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Address of any element of a 1D array can be calculated by using the following formula:

A

Formula: Base address + size * ( i - first index)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Syntax of 2D array:

A

int arr[max_rows][max_columns];

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Address of an element a[i][j] of the array stored in row major order is calculated as

A

Address(a[i][j]) = B. A. + (i * n + j) * size

a[m][n] where m is the number of rows while n is the number of columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Address of an element a[i][j] of the array stored in column major order is calculated as,

A

Address(a[i][j]) = B. A. + (i +( j*m)) * size,a[m][n] where m is the number of rows while n is the number of columns

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Linked List

A
  1. A linked list can also be defined as the collection of the nodes in which one node is connected to another node, and node consists of two parts, one is the data part and the second one is the address part, as shown in the below figure.
  2. The linked list contains two parts, i.e., the first one is the data element, and the other is the pointer. The pointer variable will occupy 4 bytes which is pointing to the next element.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly