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
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
|