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
QUESTION 4 of 10: True or False: According to the reading, investors care about your love for your business.
mixer [17]

Answer:

false

Explanation:

5 0
3 years ago
Read 2 more answers
If multiple people require the use of proprietary software at the same time, what type of license is needed?
docker41 [41]

Answer:

The anwer is C: Concurrent

Explanation:

Concurrent licensing is best known as per concurrent user. As the name suggests, this type of license occurs when a specific group of users in a network accesses a program simultaneously. Assume we have five users who have a per concurrent user license. The five users can access the program at the same time. If another user from the network tries to access this network, he or she will not be logged.

4 0
3 years ago
A _____________ delivers all the files that form web pages
Alexus [3.1K]

The database of the worldwide web delivers all the files that form web pages.

<h3>What is the worldwide web?</h3>

The World Wide Web (WWW), sometimes known as the Web, is the most widely used software platform on the planet  It is an online information space where documents and other web resources can be viewed using a web browser through the Internet.  

The Internet has had a huge impact on people's lives.  It is the major means of communication on the Internet for billions of people throughout the world.

Therefore database of the worldwide web delivers all the files that form web pages.

To know more about the worldwide web follow

brainly.com/question/14715750

#SPJ4

6 0
2 years ago
What is computing networking​
andre [41]
A computer network is a group of computers that use a set of common communication protocols over digital interconnections for the purpose of sharing resources located on or provided by the network nodes.
6 0
3 years ago
When a windows computer starts, it initiates the stateless address autoconfiguration process, during which it assigns each inter
stiks02 [169]
1) <span>The IPv6 implementation on the system construct a link-local address for
     each interface by using the fe80::/64 network address
2) </span><span> Using IPv6 Neighbor Discovery protocol, the system check if the
     address is a duplicate 
</span>3) <span>Knowing the link-local address is unique, it configures the interface to use
    that address
4) </span><span>The system uses the Neighbor Discovery protocol to transmit Router
     Solicitation messages to the all routers multicast address 
5) </span><span>The router on the link uses the ND protocol to relay Router
     Advertisement messages to the system 
6) </span><span>By using the information it receives from the router, the system produce
    a routable address and configures the interface to use it </span>
5 0
3 years ago
Other questions:
  • Katie wants to use VLOOKUP for a column in a table. Which value of the mode parameter should she use to look for an exact match
    7·1 answer
  • Richard is shopping online and has to enter a password to access his bank account. Which method attribute will securely submit h
    11·2 answers
  • Which of the following can you not code in a subclass? Select one: a. a method with the same signature as a method in the superc
    13·1 answer
  • Write an algorithm which gets a number A, if it is even, prints even, and if it is odd prints odd.
    7·1 answer
  • Sarah has entered data about football players from team A and team B in a worksheet. She enters names of players from team A wit
    9·2 answers
  • Antivirus software products require that you update _____ on a regular basis
    8·2 answers
  • Write a function called random_marks. random_marks should #take three parameters, all integers. It should return a #string. # #T
    13·1 answer
  • State two ways of preventing virus attack on a computer.​
    12·1 answer
  • What time is it NOW??
    11·2 answers
  • This ICT can someone do it for me in scratch
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!