1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vazorg [7]
3 years ago
12

Design a program takes as input, X, an unsorted list of numbers, and returns the sorted list of numbers in X. The program must b

e based on the following strategy: Handle the case when X is empty and has only 1 item. Split X into two lists, using the split function in the previous problem. Sort L and G. Put everything together into a sorted list. Test your program with 10 different unsorted lists.
Computers and Technology
1 answer:
Lelechka [254]3 years ago
7 0

Answer:

The program in python is as follows:

def split(X):

   L = []; G = []

   for i in range(len(X)):

       if X[i]>=X[0]:

           G.append(X[i])

       else:

           L.append(X[i])

   L.sort(); G.sort()

   return L,G

X = []

n = int(input("Length of X: "))

for i in range(n):

   inp = int(input(": "))

   X.append(inp)

   

if len(X) == 0 or len(X) == 1:

   print(X)

else:

   X1,X2=split(X)

   newList = sorted(X1 + X2)

   print(newList)

Explanation:

The following represents the split function in the previous problem

def split(X):

This initializes L and G to empty lists

   L = []; G = []

This iterates through X

   for i in range(len(X)):

All elements of X greater than 0 equal to the first element are appended to G

      <em> if X[i]>=X[0]:</em>

<em>            G.append(X[i])</em>

Others are appended to L

<em>        else:</em>

<em>            L.append(X[i])</em>

This sorts L and G

   L.sort(); G.sort()

This returns sorted lists L and G

   return L,G

The main function begins here

This initializes X

X = []

This gets the length of list X

n = int(input("Length of X: "))

This gets input for list X

<em>for i in range(n):</em>

<em>    inp = int(input(": "))</em>

<em>    X.append(inp)</em>

This prints X is X is empty of has 1 element

<em>if len(X) == 0 or len(X) == 1:</em>

<em>    print(X)</em>

If otherwise

else:

This calls the split function to split X into 2

   X1,X2=split(X)

This merges the two lists returned (sorted)

   newList = sorted(X1 + X2)

This prints the new list

   print(newList)

You might be interested in
A security administrator is analyzing a user report in which the computer exhibits odd network-related outages. The administrato
elena-s [515]

Answer: Session Hijacking

Explanation:Session hijacking is the attacking activity that threats the valid session of the computer. This attack also invokes the system with unauthorized access for hacking the information and other processes.

Other options are incorrect because crpto-malware is the ransomware that demands ransom for data encrypted by the hackers, rootkit  permits the authorized access in system without getting noticed and logic bomb is a malicious code to harm the program computing. Thus, the correct option is session hijacking.

8 0
3 years ago
_______________, such as BASIC, Python, Java, Prolog, and C , make the programming process easier by replacing unintelligible st
musickatia [10]

Answer:

High level Languages

Explanation:

High level languages are made so that the byte code, Assembly code that computers can understand should be converted into a higher level human understandable languages such as Python,C++. Also, remember that the compilers of these languages such as Visual studio ultimately converts the high level code into low level code ( Assembly code ) that computers can understand.

8 0
3 years ago
Now the y0utube home screen is gone
erik [133]

Answer:

oh no thanks not good

Explanation:

did you try it on a different device mabye a phone

7 0
3 years ago
Read 2 more answers
A_ is an object makerfirst program second object third class fourth method ​
liberstina [14]

Answer:

you will use the components object animator whether sjetchware or HTML

5 0
3 years ago
, 13 dB correspond to a power ratio of ....?
ohaa [14]

Answer:

19.95

Explanation:

Power ratio (in db) = 10 * log [P(out)/P(in)]

Here, P(in) and P(out) correspond to input and output power in Watts respectively.

This implies, 13 db = 10 * log [P(out)/P(in)]

Rearranging,  log [P(out)/P(in)] = (13/10)

Or, P(out)/P(in) = 10 ^ 1.3 = 19.95

But, P(out)/P(in) corresponds to the power ratio of output and input power.

So the required power ratio corresponds to 19.95

5 0
4 years ago
Other questions:
  • - The __________ is called a single-selection statement.
    10·1 answer
  • What range of leakage current must trip an IDCI?​
    15·1 answer
  • What will the following code display? #include using namespace std; void doSomething(int); int main() { int x{2}; cout &lt;&lt;
    9·1 answer
  • What characteristics of IT careers can be a challenge for employees
    9·2 answers
  • Which is the most likely reason film companies expanded so quickly?
    8·1 answer
  • Windows displays a(n)
    11·1 answer
  • 1. Hypothesis: It is easier to establish an ethical work environment in a non-profit organization than in a for-profit organizat
    9·1 answer
  • Raj needs to apply sorting to a current list in his Word document.
    9·2 answers
  • In which situation is coauthoring of presentations primarily utilized?
    9·1 answer
  • The cpu understands instructions written in a binary machine language. <br> a. true <br> b. false
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!