1. Use the following Python code to generate an input array: d. Radix ...
[Pages:1]1. Use the following Python code to generate an input array:
import numpy as np np.random.seed(1809xxx) # the number part of your student id np.random.choice(90, 10, replace=False) + 10
and then sort the array by a. Mergesort (10 marks) b. Quicksort (10 marks) c. Heapsort (10 marks) d. Radix sort (10 marks)
You need to show each major intermediate step of applying these sorting algorithms.
2. A positive integer array [1 ... ] is said to have a majority element if more than half of its entries are the same. Given an array, design an efficient algorithm with () time to tell whether the array has a majority element, and, if so, to find that element. Otherwise, return 0. An algorithm with time complexity other than () will receive no marks. a. Write pseudocode of your algorithm. (30 marks) b. Implement this algorithm in Python as a function:
def find_majority_element(S):
Two cases will be tested while one array has a majority element and one array does not have. The sum of running time is recorded. The fastest three implementations in the class will get a bonus 10 points for this assignment. (30 marks)
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- c stb cvs local research user stb cv book fundamentals cv
- python arrays university of babylon
- creating simple array and converting to numpy array github pages
- 2d arrays 2d arrays and double pointers bryn mawr
- homework 1 perceptron cornell university
- generating random rough edges surfaces and volumes lithoguru
- python lab 3 2d arrays and plotting university of york
- a python wrapper code generator for dynamic librari es tuhh
- 2d arrays practice exercises university of pennsylvania
- random numbers random walk umass
Related searches
- python code to replace string
- how to create an empty array numpy
- python code to loop through column
- use alternator to generate electricity
- 3 1 what are the hexadecimal bytes for the following instructions a inc dptr
- 3 1 what are the hexadecimal bytes for the following instructions
- which of the following lists python units of abstraction from smallest to larges
- python how to make an object
- python code to read csv
- python code to convert csv to excel
- python code to add numbers
- convert python code to c