Answer:
In Python:
def split(A):
L=[]; G=[]
for i in range(1,len(A)):
if (A[i] != A[0] and A[i] < A[0]):
L.append(A[i])
if (A[i] != A[0] and A[i] > A[0]):
G.append(A[i])
return L, G
Explanation:
This defines the function
def split(A):
This initializes the L and G lists
L=[]; G=[]
This iterates through the original list A
for i in range(1,len(A)):
This populates list L using the stated condition
<em> if (A[i] != A[0] and A[i] < A[0]):</em>
<em> L.append(A[i])</em>
This populates list G using the stated condition
<em> if (A[i] != A[0] and A[i] > A[0]):</em>
<em> G.append(A[i])</em>
This returns the two lists L and G
return L, G
A string variables??? I'm not sure does this have any multiple choice
Multics was the first operating system to integrate security as its core functions.
Answer:
Explanation:
Since all of the items in the array would be integers sorting them would not be a problem regardless of the difference in integers. O(n) time would be impossible unless the array is already sorted, otherwise, the best runtime we can hope for would be such a method like the one below with a runtime of O(n^2)
static void sortingMethod(int arr[], int n)
{
int x, y, temp;
boolean swapped;
for (x = 0; x < n - 1; x++)
{
swapped = false;
for (y = 0; y < n - x - 1; y++)
{
if (arr[y] > arr[y + 1])
{
temp = arr[y];
arr[y] = arr[y + 1];
arr[y + 1] = temp;
swapped = true;
}
}
if (swapped == false)
break;
}
}
If you save the input as num,
this will print the input 8 times.
num = input("Enter a number: ")
print(num * 8)
If you want to do actual math calculations,
then the input needs to be a number.
num = float(input("Enter a number: "))
print(num * 8)
This doesn't account for any errors in which the user doesn't input a number, but I don't think that's what you were looking for anyway :)