Rex_rawr
Rex_rawr
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Ohh okay okay ty for the help! I was kinda scared because the teacher just said yh make an insertionsort and i tried to understand what he said but he just rushed over it and stopped with the lesson 🥲 and i need it till tomorrow so yhhh😭 ty again
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Okay ill read it but ty for the help
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Im sorry a what?😭
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
cs
internal class Insertionsort {

static void Main() {
int[] unsortetArray = { 56, 8, 9, 85, 24, 23, 22, 33, 81, 44, 79, 41, 36, 46, 34, 52, 26,
72, 99, 31, 68, 95, 96, 17, 63, 55, 37, 14, 87, 23, 2, 93, 96, 16,
19, 34, 24, 79, 23, 3, 20, 40, 34, 79, 14, 5, 34, 86, 12, 5}; // generated int array from chat gpt to get a random number array

unsortetArray = InsertionSorting(unsortetArray);

foreach (int i in unsortetArray) {
Console.WriteLine(i);
}
}


static int[] InsertionSorting(int[] unsortetArray) {

int index = 0, compare, remember;

while (index < unsortetArray.Length - 1) {

index++;
compare = index - 1;

if (compare < 0) { // checks that if compare would be smaller than zero so an error wont occure
compare = 0;
}

if (unsortetArray[compare] > unsortetArray[compare + 1]) {

remember = unsortetArray[compare];
unsortetArray[compare] = unsortetArray[compare + 1];
unsortetArray[compare + 1] = remember;

index -= 2; // -2 so it can sort the numbers before that if they are not already sorted

}
}

return unsortetArray;
}
}
cs
internal class Insertionsort {

static void Main() {
int[] unsortetArray = { 56, 8, 9, 85, 24, 23, 22, 33, 81, 44, 79, 41, 36, 46, 34, 52, 26,
72, 99, 31, 68, 95, 96, 17, 63, 55, 37, 14, 87, 23, 2, 93, 96, 16,
19, 34, 24, 79, 23, 3, 20, 40, 34, 79, 14, 5, 34, 86, 12, 5}; // generated int array from chat gpt to get a random number array

unsortetArray = InsertionSorting(unsortetArray);

foreach (int i in unsortetArray) {
Console.WriteLine(i);
}
}


static int[] InsertionSorting(int[] unsortetArray) {

int index = 0, compare, remember;

while (index < unsortetArray.Length - 1) {

index++;
compare = index - 1;

if (compare < 0) { // checks that if compare would be smaller than zero so an error wont occure
compare = 0;
}

if (unsortetArray[compare] > unsortetArray[compare + 1]) {

remember = unsortetArray[compare];
unsortetArray[compare] = unsortetArray[compare + 1];
unsortetArray[compare + 1] = remember;

index -= 2; // -2 so it can sort the numbers before that if they are not already sorted

}
}

return unsortetArray;
}
}
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Ohh sorry ill do that
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
here is the code:
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Yea sure do i need to use some kind of command or just paste it in here
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
The teacher said that we should always check the number before it and then swap them out so like if we have [2,5,7,4] it should firstly look is the numer bigger then if yes then leave it if it is smalle rthen change it and that till it is right and he called it an insertionsort do idk tbh
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
No description
29 replies
CC#
Created by Rex_rawr on 10/26/2024 in #help
Does this count as an InsertionSort
Sorry im on it rn booting up my laptop ill send a screenshot any second
29 replies