Generate a new sorted list by iteratively adding correct num

Assignment Help Python Programming
Reference no: EM132356449

Question : Counting Sort

In general, the best performance you can hope to accomplish with sorting is an O(n log n) solution. When you know that the number of unique values you will be sorting is relatively small compared to the size of the list (n), you can improve on this solution by using a method called counting sort. The general premise of counting sort is as follows:

1. Iterate over the list one time and count the frequency of each value that occurs. This can be done in O(n) time.

2. Sort the list of unique values, which is much smaller than the size of the list, and therefore much faster to sort. This can be done in O(k log k) time, where k is the number of unique values in the list. Since k is much less than n, this is much faster than O(n log n)

3. Generate a new, sorted list by iteratively adding the correct number of repetitions of each unique value in the correct order. This can be done in O(n) time. create a Python file called count.py and implement a function called countsort that takes a list as input. This function must return a new, sorted copy of the input list using the counting sort method described above.

Note - for this question, you can use a built-in sorting function that Python offers to sort the unique values, or implement any other sorting algorithm if you want.

Reference no: EM132356449

Questions Cloud

Some companies put lot of effort into the user experience : Everything we touch that is electronic has a Human to Computer Interface (HCI). Some companies put a lot of effort into the user experience;
Describe the target learners and discuss unique needs : Describe the target learners, discussing at least three (3) unique needs and / or challenges the online learners face. Propose the primary learning theory.
?write program that uses main and a void function : ?Write program that uses main and a void function named randnums that takes no arguments and does not return anything.
Topic - Industrial IoT Solutions in Supply Chain Management : Prepare 15 pages Description on given topic. Topic - Industrial IoT Solutions in Supply Chain Management
Generate a new sorted list by iteratively adding correct num : Generate a new, sorted list by iteratively adding the correct number of repetitions of each unique value in the correct order. This can be done in O(n) time.
Develop a current resume and create a formal cover letter : Write a one-page double spaced introductory cover letter in which you explain your professional objectives, professional interests, and strengths
Determining the competitive value of information technology : Identify three factors to consider in determining the competitive value of information technology. Justify the selected factors.
Accept a single integer argument and calculate the factorial : Create a Python file that a single function called cachedfactorial. The function will accept a single integer argument and calculate the factorial value.
Competitive advantage for organization web strategy : Analyze how social media provides a competitive advantage for an organization's Web strategy, why a robust Web presence matters to company executives.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd