Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 8, Problem 2P
(a)
Program Plan Intro
To give an
(b)
Program Plan Intro
To give an algorithm of running time of
(c)
Program Plan Intro
To give a stable sorting element that uses constant amount of storage space.
(d)
Program Plan Intro
To give RADIX-SORT algorithm that sorts n -records with b -bits keys in
(e)
Program Plan Intro
To describe the counting sort so that it sorted the records in
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Search a sorted matrix: The input consists of a real number x and a matrix A[1..n, 1..m] of nm real values, where A[i, 1..m] and A[1..n, j] are the rows and columns, respectively, of the matrix. The objective is to either state that all of the members of A are greater than x or to locate the largest array entry A[i, j] that is less than or equal to x. Create and evaluate an iterative approach for this issue that looks at the least amount of matrix entries feasible. If you think the issue can be resolved with a straightforward binary search, think twice.
For example,
Input: {10, 12, 17, 14, 8, 3, 22}
Output: {5, 4, 2, 3, 6, 7, 1}
Given an array of different integers, replace each element by its corresponding
descending order in the array. The maximum array element has the order 1; the second
maximum element has order 2, and so on...
a) Design a brute-force algorithm to solve this problem (4 marks), and analyse the
complexity of your solution
b) Design a more efficient algorithm to do the same task with less complexity ,
and analyse the complexity of your solution.
c) Develop a python code to implement your efficient algorithm.
depend on the correctness of the code, indentation, comments, test-case]
d) Prepare a brief report (250 words) comparing the two algorithms
Search a sorted matrix: The input consistsof a real number x and a matrix A[1..n, 1..m] of nm real numbers such that each rowA[i, 1..m] is sorted and each column A[1..n, j] is sorted. The goal is to find the maximum array entry A[i, j] that is less than or equal to x, or report that all elements of Aare larger than x. Design and analyze an iterative algorithm for this problem that examines as few matrix entries as possible. Becareful if you believe that a simple binarysearch solves the problem.
make a lower bound, and recursive algorithm.
Chapter 8 Solutions
Introduction to Algorithms
Knowledge Booster
Similar questions
- Search a sorted matrix: The input consistsof a real number x and a matrix A[1..n, 1..m] of nm real numbers such that each rowA[i, 1..m] is sorted and each column A[1..n, j] is sorted. The goal is to find the maximum array entry A[i, j] that is less than or equal to x, or report that all elements of Aare larger than x. Design and analyze an iterative algorithm for this problem that examines as few matrix entries as possible. Becareful if you believe that a simple binarysearch solves the problem.arrow_forwardLet m be a matrix with n rows and n columns whose entries are either 1 or 0. recall that the element of m on row i and column j is denoted by mij . the diagonal entries of m are {mii} for 1 ≤ i ≤ n. We call M permutable if it is possible to swap some of the rows and some of columns so that all diagonal entries are 1. Design a polynomial time algorithm that decides whether a binary matrix M is permutable or not. Note that we can swap any two rows or two columns. Also, the order in which these swaps are done is not important.arrow_forwardGiven an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix. Note that it is the kth smallest element in the sorted order, not the kth distinct element. You must find a solution with a memory complexity better than O(n2). Example 1: Input: matrix = [[1,5,9],[10,11,13],[12,13,15]], k = 8 Output: 13 Explanation: The elements in the matrix are [1,5,9,10,11,12,13,13,15], and the 8th smallest number is 13 Example 2: Input: matrix = [[-5]], k = 1 Output: -5arrow_forward
- Given a set of jobs {J1, ... , Jn}, each job Ji = < ti, wi > has a required processing time ti and aweight wi. Design an efficient algorithm (pseudo code) to minimize the weighted sum of overall completion times ∑ni=1wiCi, where Ci is the completion time of job i. What is the time complexityof your algorithm? Note: You first need to briefly explain your ideas to solve the problem, e.g. what data structures are used, how the intermediate results are saved, which sorting strategy is used, and why the final results are correct;arrow_forward1. (a)The objective is to shuffle a given array of n different elements. You would like to compare various shuffling algorithms and select the best of them. What does it mean: “the best shuffling algorithm”? What is a requirement for the perfect shuffling algorithm? (b) Is the Fisher-Yates Shuffle the perfect shuffling algorithm? Present a formal mathematical proof that this algorithm meets (or does not meet) the requirement given in (a). (c) Evaluate empirically performance of the Fisher-Yates Shuffle for selected numerical values of n. Propose your evaluation criteria and explain your evaluation methodology. Report your observations and conclusions.arrow_forwardQuestion 17. Sorting a data set is an important sub-problem in data science. Given the size n of a data set, which statements are correct? a) Bubble Sort has worst-case run-time complexity O(n).b) Bubble Sort has worst-case run-time complexity O(n log N).c) Bubble Sort has worst-case run-time complexity O(n2).d) Merge Sort has worst-case run-time complexity O(n).e) Merge Sort has worst-case run-time complexity O(n log N).f) Merge Sort has worst-case run-time complexity O(n2).g) Quick Sort has worst-case run-time complexity O(n).h) Quick Sort has worst-case run-time complexity O(n log N).i) Quick Sort has worst-case run-time complexity O(n2).arrow_forward
- (Average time complexity) the Time Complexity (TC) considered is generallyreferred to as the worst-case (WS) TC. Note that WS-TC reflects only the performance of an algorithmin the worst case, as the name suggests, which does not necessarily capture its practical performance.1 Incontrast to WS-TC, another related concept, called Average Time Complexity (AV-TC), captures the averageperformance of an algorithm over a large number of pre-set random instances. A typical way to evaluatethe AV-TC of a given algorithm is to first identify a class of instances and then output the average runningtime over them. In the context of sorting algorithms when input size is n, we can get testing instances bygenerating a given number of random permutations over [n] = {1,2,3,...,n}.Please implement the following algorithms, namely, (1) Cocktail Sort (CS), (2) the complementary reversionof CS (CS-R), (3) Merge Sort parameterized with an integer k = 2 (MS(k = 2)), (4) Merge Sort parameterizedwith an…arrow_forwardObserve the following two Sequential Search and Binary Search algorithms in the image. Perform a comparative analysis of the Sequential Search and Binary Search algorithms in terms of the number of basic operations executed by the two algorithms. A. Calculate and analyze the time complexity T(n) and the efficiency class of the two search algorithms in the worst case. B. Write an example case by writing down the elements for different data sizes, for example n=4, 8, ... Please specify the elements of table A and the data you are looking for, x. Write an illustration of the comparison process for every n to confirm the complexity of the algorithm in point a). C. Describe your opinion regarding the comparative analysis of the efficiency of the two algorithms! Please solve subparts A,B,C in 60 minutes ASAP can u get thank uarrow_forwardExplain the running time of algorithms that reduce the sizeof the remaining data to be processed by half, at each step.Explain why decrease-by-constant-factor is associatedwith lg n as a factor in running-time expressions. In divide and conquer, what is divided in such a way asto enable faster than linear time? What is it about divide-and-conquer that may offerfast running times?arrow_forward
- Consider the array A[1 . . . n] consisting of n non-negative integers. There is a frog on the LAST index of the array, i.e. the nth index of the array. In each step, if the frog is positioned on the i th index, then it can make a jump of size at most A[i] towards the beginning of the array. In other words, it can hop to any of the indices i, . . . , i − A[i]. (a) Develop a Greedy algorithm to determine whether the frog can reach the FIRST index of A. (b) Show the correctness of your algorithm in part (a). (c) Find and justify the time complexity of your algorithm.`arrow_forward7. The American Museum of Natural History in New York City contains more than 32 million specimens and artifacts in its various collections, including the world’s largest collection of dinosaur fossils. Many of these are in storage away from public view, but all must be carefully inventoried. a) Suppose the inventory is unordered (!) and a sequential search is done to locate a specific artifact. Given that the search is executed on a computer that can do 12,000 comparisons per second, about how much time on the average would the search require? b) Assuming the inventory is sorted, about how much time would a binary search require?arrow_forwardSuppose you have been given a map of 6 cities connected with each other via different paths. Your job is to visit every city just once covering the minimum distance possible. Solve this problem using Genetic Algorithm. You can start at any point and end at any point. Just make sure that all the cities have been covered. 1. Encode the problem and create an initial population of 3 different chromosomes 2. Choose any one parent from your above solution and identify the following:i. Gene ii. Chromosome 3. Think of an appropriate fitness function to this problem and give proper justification. 4. Use the fitness function to calculate the fitness level of all the chromosomes in your population. Select the fittest 2 chromosomes based on the fitness function. 5. Perform crossover that you have been taught in the class on the selected parents. Now based on the offspring, for this problem do you think that is the best way to perform crossover? If not, explain why. 6. Perform mutation that you…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education