Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9304093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T23:37:59+00:00 2026-06-18T23:37:59+00:00

Now I have an algorithm for dynamically allocating memory on an array: If array

  • 0

Now I have an algorithm for dynamically allocating memory on an array:

  • If array is full I create a new array of twice the size, and copy items.
  • If array is one-quarter full I create a new array of half the size, and copy items.

This is fairly fast algorithm for dynamic memory allocation despite the extra over-head of copying the elements to the newly allocated array.

  1. What is the faster, List<T> or such an algorithm based on an array? What would you recommend to use?

  2. does List<T> use simple array as internal data structure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T23:38:01+00:00Added an answer on June 18, 2026 at 11:38 pm

    TO answer your question:

    It is true, C#’s List<T> implementation uses an internal array that is

    1. Serializable
    2. Thread-safe
    3. Implements IEnumerable<T> (which means it can be LINQ Queried, foreached etc)
    4. Binary Searched

    and so on

    Hence, I would ask you to use List<T> instead of your own List.

    Oh and btw, if you want the source code of List<T> from Microsoft, then here it is

    List.cs

    EDIT

    The source code of EnsureCapacity in List<T> is:

        // Ensures that the capacity of this list is at least the given minimum
        // value. If the currect capacity of the list is less than min, the
        // capacity is increased to twice the current capacity or to min,
        // whichever is larger.
        private void EnsureCapacity(int min) {
            if (_items.Length < min) {
                int newCapacity = _items.Length == 0? _defaultCapacity : _items.Length * 2;
                if (newCapacity < min) newCapacity = min;
                Capacity = newCapacity;
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to implement a search algorithm for a school assignment. Right now, i'm
I have an algorithm which currently allocates a very large array of doubles, which
I have a studentadministration application. Now I have to implement a new part of
So, I create my own Snake game with AI, but now I have very-very
I wrote the code for the secant algorithm , and now I have the
Following this trick to grab unique entries for a NumPy array, I now have
I have a double[] array holding many numbers. I have an algorithm that selects
In my Android app, I have a Bitmap object and an int[]. One algorithm
So I am implementing Karatsuba's multiplication algorithm in python. Right now I have infinite
I like to use std::algorithm whenever I can on plain arrays. Now I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.