#Beginner

11 messages · Page 1 of 1 (latest)

obtuse aspen
#

If i assign a element of a particular index to a temp variable, will it create an empty space in the array.

jovial hazelBOT
#

This post has been reserved for your question.

Hey @obtuse aspen! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

cosmic oracle
#

that's a pretty vague question

#

but it is impossible to "create" empty spaces in an array one by one

#

if you have an array variable, it is either uninitialized (contains no array, and thus has no spaces to initialize), or it is initialized, in which case all the empty spaces are already there

obtuse aspen
#

Can you explain why in insertion sort we assign the element of a index to a variable instead of the index itself. for (int i = 1; i < a.length; i++) {

int c = a[i];
int b = i - 1;

        while (b >= 0 && a[b] >` c`) {
            a[b + 1] = a[b];
            b--;
        }
        a[b + 1] =` c;`
    }
}
cosmic oracle
#

no, because i don't understand what that question means

obtuse aspen
deep grail
#

It doesn't create an empty space.
The space used by the item to insert just gets overwritten.

#

Which is fine since the overwritten value was saved in variable c