Question

We are given an array A holding n integers, for some large n. The array is...

We are given an array A holding n integers, for some large n. The array is sorted, and the
values in A range from -2147483648 to 2147483647, evenly distributed. Give Θ expressions
for the following tasks:
A. Running the insertion sort algorithm on the array A:
B. Running the selection sort algorithm on the array A:
C. Performing binary search for integer k which is not in A:
D. Performing interpolation search for integer k not in A:

0 0
Add a comment Improve this question Transcribed image text
Answer #1

A. Running the insertion sort algorithm on the array A:

(N), Insertion Sort takes (N) in best case as the Input is Sorted

B. Running the selection sort algorithm on the array A:


(N2), Selection Sort takes (N2) in worst case nd does not care much about the input. Even with Sorted Input it takes

(N2) time

C. Performing binary search for integer k which is not in A:

(Log N), Binary search space reduces by half hence it takes (Log N) time

D. Performing interpolation search for integer k not in A:

In worst case it can take upto O(n), hence (N)

Thanks, PLEASE COMMENT if there is any concern.

Add a comment
Know the answer?
Add Answer to:
We are given an array A holding n integers, for some large n. The array is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 10: Given an array of data: array1 10 5 15 2 7 21 Write the...

    Question 10: Given an array of data: array1 10 5 15 2 7 21 Write the code for the selection sort to sort the data and draw a table showing how the data is sorted using selection sort. Write the code for Binary search algorithm to find the value 15 from the sorted array. Draw the tree diagram showing the binary search of the list.

  • Please Use C++ Language. And Note that please donot post the answer already there Because there...

    Please Use C++ Language. And Note that please donot post the answer already there Because there is similar answer code but I need with modified Quick sort algorithm ​. Update your program from ... Create an array that holds 1000 random integers between 1-1000. Allow the user to enter an integer to search. Create and implement modified Quick sort algorithm which will sort the array before the Binary Search algorithm is executed. Create and implement a Binary Search Algorithm ....

  • The input is an array of N integers ( sorted ) and an integer X. The...

    The input is an array of N integers ( sorted ) and an integer X. The algorithm returns true if X is in the array and false if X is not in the array. Describe an algorithm that solves the problem with a worst case of O(log N) time.

  • 1. a. Using C++, represent the following graph using adjacency matrix, and implement depth first searching...

    1. a. Using C++, represent the following graph using adjacency matrix, and implement depth first searching (DFS) by stack (define it with class) to traverse the graph. 6 7 2 4 b. If starting with node 2, when node 7 is printed, what numbers are in the stack (for DFS)? Please draw the stack step by step to show how the numbers are pushed into and popped out of it. 2. a. Given a set of integer numbers as int...

  • Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case...

    Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case time and insertion sort runs in Θ(n 2 ) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of...

  • (+30) Provide a python program which will Populate an array(list) of size 25 with integers in...

    (+30) Provide a python program which will Populate an array(list) of size 25 with integers in the range -100 (negative 100)   to +100 inclusive Display the array and its length (use the len function) Display the average of all the integers in the array Display the number of even integers (how many) Display the number of odd integers (how many) Display the number of integers > 0   (how many) Display the number of integers < 0   (how many) Display the...

  • In Java: In a sorted (ascending) integer array of length n with no duplicates, print all...

    In Java: In a sorted (ascending) integer array of length n with no duplicates, print all values in the range x to y. Assume both x and y are in the array. What is the worst case big O running time if there are k integers within the range?

  • JH: Student Name: 4) Given the following array, do the following (show all the work). A...

    JH: Student Name: 4) Given the following array, do the following (show all the work). A (56, 89, 23, 58, 22, 11, 45, 48, 90) (a - 5 pts) Construct a hash table for the given array using the hash function H(K)- K mod 5 (b- 4 pts) Determine the average number of comparisons for a successful search using the hash table of (c -3 pts) What is the worst case number of comparisons for an unsuccessful search in the...

  • 1. What is the worst case time complexity of insertion into a binary search tree with...

    1. What is the worst case time complexity of insertion into a binary search tree with n elements? You should use the most accurate asymptotic notation for your answer. 2. A binary search tree is given in the following. Draw the resulting binary search tree (to the right of the given tree) after deleting the node with key value 8. 10 3. You have a sorted array B with n elements, where n is very large. Array C is obtained...

  • 1. (16 pts.) Sorted Array Given a sorted array A of n (possibly negative) distinct integers,...

    1. (16 pts.) Sorted Array Given a sorted array A of n (possibly negative) distinct integers, you want to find out whether there is an index i for which Al = i. Give a divide-and-conquer algorithm that runs in time O(log n). Provide only the main idea and the runtime analysis.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT