Find the minimum and maximum number in the array

Assignment Help Python Programming
Reference no: EM132845419

In this practice, we will be implementing linear search, binary search, and order statistic algorithm discussed in the class. You are required to use python and do not use any method/library that directly performs the task. For help, use the lecture slides. You should be able to explain your code clearly not just read it.

Task 1: Linear Search

This function should return true or false. If the key is present in the array A, then return True, else False.
def LinearSearch(A, key):
# write your code here

1. Generate an array A with 100000 elements consisting of number from 1 to 100000 in ascending order.

2. Provide a value for the key that depicts the best-case runtime for the algorithm. Measure the time using the timing code from the previous assignment. Repeat this process for 3 times and note down the time for each run. Report the average time.

3. Provide a value for the key that depicts the worst-case runtime for the algorithm. Measure the time using the timing code from the previous assignment. Repeat this process for 3 times and note down the time for each run. Report the average time.

Task 2: Binary Search

This function should return true or false. If the key is present in the array A, then return True, else False.

def BinarySearch(A, key):
# write your code here

1. Generate an array A with 100000 elements consisting of number from 1 to 100000 in ascending order.

2. Provide a value for the key that depicts the best-case runtime for the algorithm. Measure the time using the timing code from the previous assignment. Repeat this process for 3 times and note down the time for each run. Report the average time.

3. Provide a value for the key that depicts the worst-case runtime for the algorithm. Measure the time using the timing code from the previous assignment. Repeat this process for 3 times and note down the time for each run. Report the average time.

Task 3: Order Statistic

This function should return the n'th largest number in the array A. Where n=1 means the maximum number.
def OrderStatistic(A, n):
# write your code here

1. Generate an array A with 100000 elements consisting of random numbers in a range from 1 to 100000. The same number can repeat in the array.

2. Find the minimum and maximum number in the array using appropriate values of n.

Attachment:- Linear Search.rar

Reference no: EM132845419

Questions Cloud

Describe how each strategy encourages critical thinking : In 250-500 words, reflect upon your instructional choices and rationalize the appropriateness of each strategy related to the specified student needs.
Describe the sample space : In Risk Thoery, The sample space is the collection of all possible outcomes of a random experiment. Describe the sample space in each of the following situation
What were the goals of the founders of jamestown colony : What were the goals of the founders of Jamestown Colony, the Massachuhhtes bay colony, and plymouth colony? How did they go about achieving goals?
Mean weight of swamp wallaby : The mean weight of the adult Australian animal Swamp Wallaby the previous year was 15.4kg with a standard deviation of 2.5kg. This year a sample of 35 Swamp Wal
Find the minimum and maximum number in the array : Find the minimum and maximum number in the array using appropriate values of n - Generate an array A with 100000 elements consisting of random numbers
How did slaves use white southerners own philosophies : How did slaves use white southerners' own philosophies - paternalism and Christianity, for example - to their advantage in these efforts?
Explain each of the major types of building construction : Develop a PowerPoint presentation of 8-12 slides that explains each of the major types of building construction. In addition, your presentation should address.
What z-score is used to represent the highest : What z-score is used to represent the highest 25% of the data? Answer to three decimal places.
By how much would operating profit increase : The company produced 10,000 units and sold 8,000 units. If sales were to increase by 3,000 units, by how much would operating profit increase

Reviews

len2845419

3/31/2021 4:14:13 AM

Please tutor should make program as straightforward as possible and comments all things so it will make us understand better also line-to-line comments to understand

len2845419

3/31/2021 1:55:54 AM

Do python task 1 2 and 3 Except the last past (programming challenge Problem)

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