Results 1 to 7 of 7

Thread: static array or dynamic array?

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Answers
    13

    Question static array or dynamic array?

    How can you quickly find the number of elements stored in a
    a) static array or in b) dynamic array ?


  2. #2
    Junior Member
    Join Date
    Jun 2007
    Answers
    1

    Re: static array or dynamic array?

    dynamic array


  3. #3
    Contributing Member
    Join Date
    Apr 2007
    Answers
    41

    Re: static array or dynamic array?

    static array
    -----------

    static array access would be more faster. Since its the index move.
    And the static array space is allocated at stack.

    ex: a[4]={'1','2','3','4'}

    for(i=0;i<4;i++)
    {
    printf("%d",a[i]);
    }
    Since its the index jump this would be faster.

    Dynamic array
    --------------

    Dynamic array would be slow since its pointer(address) increment.


  4. #4
    Junior Member
    Join Date
    Nov 2007
    Answers
    2

    Re: static array or dynamic array?

    static array


  5. #5
    Contributing Member
    Join Date
    Nov 2007
    Answers
    46

    Re: static array or dynamic array?

    dynamic array:

    - if array has bulk elements then its efficient.

    dynamic array is quick to find elements


  6. #6
    Contributing Member
    Join Date
    Dec 2007
    Answers
    46

    Re: static array or dynamic array?

    Quote Originally Posted by rpgubba View Post
    How can you quickly find the number of elements stored in a
    a) static array or in b) dynamic array ?
    Is this a trick question

    First of all, you need to specify the language where you want this answer.

    2.
    Lets assume you are programming in C. Then, there is no way one can find the number of elements stored in a static array. If there is way, I would like to know how it is done.

    3.
    One might only find the maximum no of elements in an array if there is a special value entered programatically that indicates that we have reached the end of the array.


  7. #7

    Re: static array or dynamic array?

    I dont know man dont disturb


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact