Question

In: Computer Science

Question III: Programming\flowcharts\algorithms Sort the following list from the smallest to the largest using the bubble...

Question III: Programming\flowcharts\algorithms

  1. Sort the following list from the smallest to the largest using the bubble sort algorithm (show all passes) [4 points]

20

10

30

5

0

  1. Write a python program that asks the user to enter the number of seconds. The program will print the whole hours, whole minutes and remaining seconds. For example: if the user entered the number of seconds as 3663 then the output will be: 1 hour(s), 1 minute(s), 3 second(s). [5 points]

Note: You do not need to add comments

  1. Draw a flowchart (use loops) that gets a positive integer number from the user (num) and prints the first 3 multiples of num. [6 points]

For example: if the user entered 3 then the output will be:

3

6

9

Note: multiples of 3 are: 1 x 3= 3, 2 x 3=6, 3 x 3=9, etc.

Solutions

Expert Solution

Sorting List:

CODE:

a=[20,10,30,50]

for i in range(len(a)):
for j in range(len(a)-i-1):
if a[j]>a[j+1]:
temp=a[j] #swap adjacent elements if condition meets
a[j]=a[j+1]
a[j+1]=temp
print(a)

Screenshots:

Python program that find hours,minutes and seconds

CODE:

#Reading input from user
t=int(input("Enter seconds::"))
#Find no.of hours
hours=int(t/3600)
t=t%3600
#Find no.of minutes
minutes=int(t/60)
t=t%60
#Find no.of seconds
seconds=t

print(str(hours)+" hour(s),"+str(minutes)+" minute(s),"+str(seconds)+" second(s)")

Screenshots:

Flow chart for first three multiples of a number


Related Solutions

Write two algorithms to find both the smallest and largest numbers in a list of n...
Write two algorithms to find both the smallest and largest numbers in a list of n numbers. In first algorithm, you simply write one loop to find the minimum and maximum. So there will be 2(n - 1) comparisons. In second algorithm, you try to find a method that does at most 1.5n comparisons of array items. Determine the largest list size (i.e., n) that Algorithm 1 can process and still compute the answer within 60 seconds. Report how long...
In Python, there are different sorting algorithms. Selection Sort, Bubble Sort and Insertion Sort. • Write...
In Python, there are different sorting algorithms. Selection Sort, Bubble Sort and Insertion Sort. • Write a Pseudo code first for each of these sort methods.   • After writing the pseudo code write python code from the pseudo code. • Upload the pseudo code and Python code for each of the three algorithm mentioned.
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that...
LISP Programming Language Write a Bubble Sort program in the LISP Programming Language called “sort” that sorts the array below in ascending order.  LISP is a recursive language so the program will use recursion to sort. Since there will be no loops, you will not need the variables i, j, and temp, but still use the variable name array for the array to be sorted.             Array to be sorted is 34, 56, 4, 10, 77, 51, 93, 30, 5, 52 The...
Rank the algorithms from slowest to fastest. . Bubble Sort Linear Search Binary Search Shellsort
Rank the algorithms from slowest to fastest. . Bubble Sort Linear Search Binary Search Shellsort
Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the...
Sort the following set of numbers using bubble sort, insertion sort, and selection sort. Show the process step-by-step, and find the time complexity in Big-O notation for each method. For sorting, use ascending order. 49, 7, 60, 44, 18, 105
Which of the following statements are true for both bubble sort and heapsort?. a) Largest values...
Which of the following statements are true for both bubble sort and heapsort?. a) Largest values accumulate on the right b) Both must be implemented with arrays c) Largest values accumulate on the left d) This is a trick question, there is nothing in common. Heapsort uses heaps, which is a tree. e) Smallest values accumulate on the left
c++ Run the following sorting algorithms: 1. Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort...
c++ Run the following sorting algorithms: 1. Bubble sort 2. Insertion sort 3. Quicksort 4. Mergesort Under the following scenarios for input data: 1. Uniform random 2. Almost sorted (90% sorted – 1 in 10 is out of place) 3. Reverse sorted On data of sizes 5,000, 10,000, … in increments of 5,000 up to …, 50,000 -Attach a screenshot of a program compilation below -Attach a screenshot of a successful program run below -Attach a graph (either line graph...
C++ Question- Write function templates for 5 sort algorithms: - Quick Sort Apply these algorithms to...
C++ Question- Write function templates for 5 sort algorithms: - Quick Sort Apply these algorithms to 10 different arrays of integers. Each array has 100 integer elements. The arrays are filled with random integer numbers.
1.   Bubble Sort Implement a bubble sort program that will read from a file “pp2.txt” from...
1.   Bubble Sort Implement a bubble sort program that will read from a file “pp2.txt” from the current directory a list of intergers (10 numbers to be exact), and the sort them, and print them to the screen. You can use redirection to read data from a given file through standard input, as opposed to reading the data from the file with the read API (similar to Lab #1). You can assume the input data will only have 10 numbers...
1.)recursive merge sort on a list.(Python) 2.)recursive bubble sort using a list without enumerate() function.(python) Show...
1.)recursive merge sort on a list.(Python) 2.)recursive bubble sort using a list without enumerate() function.(python) Show Base case, and recursive case.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT