Programming and Data Structures - Arrays

6. Size of the array need not be specified, when

  • Option : A
  • Explanation :
    Consider the following declaration
    double balance[] = {1000.0, 2.0, 3.4, 17.0, 50.0};
    If you omit the size of the array, an array just big enough to hold the initialization is created.
    So, correct option is 'A'.
Cancel reply
Cancel reply

7. A one dimensional array A has indices 1....75. Each element is a string and takes up three memory words. The array is stored starting at location 1120 decimal. The starting address of A[49] is

  • Option : C
  • Explanation :
    One element takes three memory words so memory location 1120, 1121, 1123 stores first element.
    A[49] will be stored at location 1264, (1120+(48*3))
Cancel reply
Cancel reply

8. Minimum number of interchange needed to convert the array 89,19,40,14,17,12,10,2,5,7,11,6,9,70, into a heap with the maximum element at the root is

  • Option : C
  • Explanation :
    Only element 70 violates the rule. Hence, it must be shifted to its proper position.
    Step1: swap(10, 70)
    Step2: swap(40, 70)
    Hence, only 2 interchanges are required.
Cancel reply
Cancel reply