Programming and Data Structures - Arrays

1. O(N)(linear time) is better than O(1) constant time.

Cancel reply
Cancel reply

4. If x is an array of integer, then the value of &x[i] is same as

  • Option : A
  • Explanation :
    x+i means increment in value of x not in address of x so it cant represent address of x.
    &x[i] means address of the ith element.

    So &x[i-1] defines address of i-1 element .sizeof(int) defines size of an element
    So &x[i-1] + sizeof(int) means address of i-1 element plus size of an element that means address of ith element.
    It cant be option c as x+i is not representing any address.

    x+i means increment in value of x not in address of x so it cant represent address of x.
    So option (A) is correct
Cancel reply
Cancel reply