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
mr_godi [17]
3 years ago
13

Write bubblesort algorithm using random programming language

Computers and Technology
2 answers:
melamori03 [73]3 years ago
7 0

Answer:

def bubbleSort( theSeq ):

   n = len( theSeq )

   for i in range( n - 1 ) :

       flag = 0

       for j in range(n - 1) :

           

           if theSeq[j] > theSeq[j + 1] :  

               tmp = theSeq[j]

               theSeq[j] = theSeq[j + 1]

               theSeq[j + 1] = tmp

               flag = 1

       if flag == 0:

           break

   return theSeq

el = [21,6,9,33,3]  

result = bubbleSort(el)

print (result)

maks197457 [2]3 years ago
3 0

Answer:

   n := length(A)

   repeat

       swapped := false

       for i := 1 to n-1 inclusive do

          <em> /* if this pair is out of order */</em>

           if A[i-1] > A[i] then

<em>                /* swap them and remember something changed */</em>

               swap(A[i-1], A[i])

               swapped := true

           end if ⇒

       end for

   until not swapped

end procedure

\\

Explanation:

This is pseudocode

You might be interested in
What kind of company would hire an Information Support and Service employee?
Anni [7]
A service company would hire an Information Support and Service employee.

hope it helps you!
6 0
3 years ago
Read 2 more answers
Which access method would be most appropriate if your manager gave you a special cable and told you to use it to configure the s
GrogVix [38]
Console Port Method

Connecting a computer to a Cisco device through the console port requires a special console cable.
8 0
3 years ago
If you have downloaded this book's source code from the companion Web site, you will find a file named text.txt in the Chapter 1
Lubov Fominskaja [6]

Answer:

Explanation:

The following python code loops through each line within a file called text.txt and counts all the words, then it divides this count by the number of sentences in the text file. Finally, output the average number of words per sentence.

f = open("text.txt", "r")

all_words = 0

sentences = 0

for x in f:

   list = x.split(' ')

   all_words += len(list)

   sentences += 1

average = all_words / sentences

print("There are an average of " + str(average.__round__()) + " words in each sentence.")

6 0
3 years ago
PLEASE HELP! 25 POINTS!
irina [24]

Answer:

Its hard to answer unless im in the situation but id find a way to stop the car and figure out a way to get out and then call police

Explanation:

6 0
3 years ago
Read 2 more answers
Which of the following is a type of intangible business property that is protected by law
xz_007 [3.2K]
Google might be it ok
6 0
3 years ago
Other questions:
  • What types of issues can you most likely resolve by knowing how to access and use the control Panel?
    15·1 answer
  • Ethan is responsible for writing the dialogue in a movie. Which role is he playing? Ethan is playing the role of a(n).....''BLAN
    8·1 answer
  • Marie uses a browser to visit a blog. What is the unique identifier of the blog?
    13·2 answers
  • Which of the following statements is true?
    12·1 answer
  • What is the full form of bcc please tell​
    15·2 answers
  • Which of the following TCP/IP settings should be configured to specify DNS suffixes to use other than resolving names through a
    9·1 answer
  • What are the pasting options in Outlook 2016? Check all that apply.
    10·2 answers
  • Study the images of two different fronts.
    7·2 answers
  • You have many drugs that you want to store electronically along with their purchase dates and prices, what kind of software woul
    7·1 answer
  • How to implement switch statement in Python?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!