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

  Determine the minimum spanning tree

Draw the above transport network showing weights between the nodes and Create an algorithm that will determine the minimum spanning tree.

  FINS3648 Banking, Finance and Technology Assignment

FINS3648 Banking, Finance and Technology Assignment Help and Solution, University of New South Wales - Assessment Writing Service

  Implement a k-means cluster analysis data mining algorithm

CIS 210 - define a main function to assign values to k, r, and f, and call visualizeQuakes. main should return None. Include code in your .py file to call

  Implement a class called countrycatalogue

Implement a class called CountryCatalogue. Implement a class Country that holds the information about a single country; name the file country.py.

  Design a program to input three numbers from the user

Design a program to input three numbers from the user, find the largest of the three numbers, and display the three numbers along with the largest numbers.

  Construct a program that will simulate a push button

Project: PLC Programming with Ladder Logic - Construct a program that will simulate a push button activated LED - After this point the shutdown process

  Write a python program that uses iteration and decision

CS115 INTRODUCTION TO COMPUTER PROGRAMMING- Write a Python program that uses iteration and decision to solve a problem.

  Modify your code to ask the user for the id of a restaurant

Copy check1.py to check2.py and continue to work on check2.py. Modify your code to ask the user for the id of a restaurant between 1 and 155 (humans don't need to know about list ids starting at 0).

  Determines number of occurrences of a given letter in string

In this last checkpoint, you will write a new program that determines the number of occurrences of a given letter in a string. To do so, you are only allowed to use the replace() and len() functions.

  Write a fuunction that computes future investment value

Write a fuunction that computes future investment value at a given interest rate for a specified number of years.

  Write a script to plot given function in python

Write a script to plot this function in python 2.7.12 - It should still look like that if choose ai values to be 1 after the script

  Find the largest palindrome made from the product

Find the largest palindrome made from the product of two three-digit numbers using a Python code. Afterward, write brief explanation walking through your code.

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