Answer:
The final case in selection sort is trivially sorted.
The final iteration in insertion sort is not needed.
Explanation:
For selection sort, you make sub arrays and find the smallest element placing it in the front and repeat until sorted. This guarantees the final element will already be the greatest element, thus it is trivially sorted.
For Insertion sort, you use the initial element and compare it to the previous element and swap if the current is larger than the previous. Using this sort, you will always perform n-1 comparisons where n is the total amount of elements in the array. Thus, there are only 11 iterations for a 12 element array.
Cheers.
Answer:
How to create a string and assign it to a variable. To create a string, put the sequence of characters inside either single quotes, double quotes, or triple quotes and then assign it to a variable.
If you're programming in python, you simply have to assign a value to x and then use the print function. For instance,
x = 3
print(3 * x)
9 will be the output. I hope this helps!
Answer:
5,400 because it turns at the right speed, but if it is too fast or too slow, it will not perform at it's fullest potential. Such as speed and storage.
In python 3.8:
def func(value_list):
lst = [x for x in value_list if type(x) == int or type(x) == float]
return sum(lst)
print(func(["h", "w", 32, 342.23, 'j']))
This is one solution using list comprehensions. I prefer this route because the code is concise.
def func(value_list):
total = 0
for x in value_list:
if type(x) == int or type(x) == float:
total += x
return total
print(func(["h", "w", 32, 342.23, 'j']))
This is the way as described in your problem.