STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 9.6, Problem 9.12CP
Explanation of Solution
Basic operations:
The basic operation is the initial step in the
- Normally, the algorithm executes the basic step in constant time rather than considering about the size of the input.
- So, it means that size of the bound does not affect the efficiency of the operations.
- The complexity of an algorithm can be found out by finding the number of basic steps required for an input.
Comparing the efficiency of an algorithm:
In the given question, one algorithm requires “
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
A certain computer algorithm executes twice as many operations when it is run with an input of size k as when it is run with an input of size k – 1 (where k is an integer that is greater than 1). When the
algorithm is run with an input of size 1, it executes seven operations. How many operations does it execute when it is run with an input of size 26?
For each integer n 2 1, let s, -1 be the number of operations the algorithm executes when it is run with an input of size n. Then s, =
and s =
for each integer k 2 1. Therefore,
So, S1, S21
-Select---
with constant
Select---
|, which is
So, for every integer n 2 0, s,
It follows that for an input of size 26, the number of
... is
operations executed by the algorithm is s
which equals
---Select--- v
Two algorithms A, B sort the same problem. When you go through each algorithm and break them down into their primitive operations, each can be represented as below
A = n4 + 100n2 + 10n + 50
B = 10n3 + 2n2 + nlogn + 200
For very large values of n which of these algorithms explain why B
will run in the shortest time to solve the problem
A certain computer algorithm executes twice as many operations when it is run with an input of size k as when it is run with an input of
size k - 1 (where k is an integer that is greater than 1). When the algorithm is run with an input of size 1, it executes seven operations. How
many operations does it execute when it is run with an input of size 24?
For each integernz 1, let s,-1 be the number of operations the algorithm executes when it is run with an input of size n. Then
for each integer 2 1. Therefore, So, S3. Sz.
is -Select-
and s,=
with constant
Select-
,which is
. So, for every integer n 2 0, s, =
It follows that for an input of size 24, the number
of operations executed by the algorithm is s
-Select-v
which equals
Need Heln?
Desd
Chapter 9 Solutions
STARTING OUT WITH C++ MPL
Ch. 9.2 - Prob. 9.1CPCh. 9.2 - Prob. 9.2CPCh. 9.2 - Prob. 9.3CPCh. 9.2 - Prob. 9.4CPCh. 9.3 - True or false: Any sort can be modified to sort in...Ch. 9.3 - Prob. 9.6CPCh. 9.3 - Prob. 9.7CPCh. 9.3 - Prob. 9.8CPCh. 9.3 - Prob. 9.9CPCh. 9.6 - Prob. 9.10CP
Ch. 9.6 - Prob. 9.11CPCh. 9.6 - Prob. 9.12CPCh. 9.6 - Prob. 9.13CPCh. 9.6 - Prob. 9.14CPCh. 9.6 - Prob. 9.15CPCh. 9 - Prob. 1RQECh. 9 - Prob. 2RQECh. 9 - Prob. 3RQECh. 9 - Prob. 4RQECh. 9 - Prob. 5RQECh. 9 - Prob. 6RQECh. 9 - Prob. 7RQECh. 9 - A binary search will find the value it is looking...Ch. 9 - The maximum number of comparisons that a binary...Ch. 9 - Prob. 11RQECh. 9 - Prob. 12RQECh. 9 - Bubble sort places ______ number(s) in place on...Ch. 9 - Selection sort places ______ number(s) in place on...Ch. 9 - Prob. 15RQECh. 9 - Prob. 16RQECh. 9 - Why is selection sort more efficient than bubble...Ch. 9 - Prob. 18RQECh. 9 - Prob. 19RQECh. 9 - Prob. 20RQECh. 9 - Prob. 21RQECh. 9 - Charge Account Validation Write a program that...Ch. 9 - Lottery Winners A lottery ticket buyer purchases...Ch. 9 - Lottery Winners Modification Modify the program...Ch. 9 - Batting Averages Write a program that creates and...Ch. 9 - Hit the Slopes Write a program that can be used by...Ch. 9 - String Selection Sort Modify the selectionSort...Ch. 9 - Binary String Search Modify the binarySearch...Ch. 9 - Search Benchmarks Write a program that has at...Ch. 9 - Sorting Benchmarks Write a program that uses two...Ch. 9 - Sorting Orders Write a program that uses two...Ch. 9 - Ascending Circles Program 8-31 from Chapter 8...Ch. 9 - Modified Bin Manager Class Modify the BinManager...Ch. 9 - Using Files-Birthday List Write a program that...Ch. 9 - Prob. 14PCCh. 9 - Using Files-String Selection Sort Modification...Ch. 9 - Using Vectors String Selection Sort Modification...
Knowledge Booster
Similar questions
- A computer science student designed two candidate algorithms for a problem while working on his part-time job The time complexity of these two algorithms are T,(n) = 3 n logn and T2(n) = n6/5 a) Which algorithm is better? Why? b) If we run both algorithms at the same time with an input size of 105, which algorithm produces results faster than the other one? Why?arrow_forwardSuppose that the running time of an algorithm A is T(n) = n2. If the time it takes for algorithm A to finish on an input of size n 10 is 100ms, what will be the time that it will take for A to finish on an input of size 20? Assume that the algorithm runs on the same machine.arrow_forwardSuppose you have algorithms with five running times. Assume these are the exact running times. How much slower do each of these algorithms get when you (a) double the input or (b) increase the input size by one? Do both. This problem requires discrete math. I solved all of these but I had a quick question. My teacher wanted us to use the big 0 notation for these running times, but the problem is that I'm not sure if that's necessary for these problems for the question it's asking. I tried to the big 0 notations for the first three. For (a) I got 8n3. Which I'm not sure is right. For example, for 1b I got 3n2 + 3n + 1 for how much slower these get from the original. Is that correct? Was I supposed to do something more for the big 0 notation. You can check to see if these answers are correct. The big O notation formula is f(n) = 0(g(n)). (a) n2 For double size I got 4n2. I got 2n + 1 from the input the size by one. I think that's all I need to do. I got similar answers for theother…arrow_forward
- Consider the following algorithm segment. Assume that n is a positive integer. for i:=1 to 4n S := 0 for i:=1 to i - 1 s := s + j(i- j + 1) next j r:= s² next i (a) What is the actual number of elementary operations (additions, subtractions, multiplications, divisions, and comparisons) that are performed when the algorithm segment is executed? For simplicity, count only comparisons that occur within if-then statements, and ignore those implied by for-next loops. Express your answer in terms of n. (Hint: See Example 11.3.3 and exercises 11.3.11a and 11.3.14a in the "Read It" link.) The number of operations is (b) Apply the theorem on polynomial orders to the expression in part (a) to find that an order for the algorithm segment is narrow_forwardThere are two algorithms called alg1 and alg2 for a problem of size n. alg1 runs in n2 microseconds and alg2 runs in 100n log n microseconds. alg1 can be implemented using 4 hours of programmer time and needs 2 minutes of cpu time. on the other hand, alg2 requires 15 hours of programmer time and 6 minutes of cpu time. if programmers are paid 20 dollars per hour and cpu time costs 50 dollars per minute, how many times must a problem instance of size 500 be solved using alg2 in order to justify its development cost?arrow_forwardSuppose your computer's CPU limits the time to one minute to process the instance of the problem with size n = 1000 using the algorithm with time complexity T(n) = n. If you upgrade your computer with the new CPU that runs 1000 times faster, what instance size could be precessed in one minute using the same algorithm?arrow_forward
- Suppose you are implementing a sorting algorithm and you want to compare its performance with another algorithm. The first algorithm takes 25 seconds to sort an input of size 10,000, while the second algorithm takes 45 seconds to sort the same input size. What is the ratio of the running times of the two algorithms?arrow_forwardHelparrow_forwardGive the exact number of additions performed in the following segment of certain algorithm assuming a₁, a2, ..., an are positive real numbers and n = 20. for i=1 to n for j=1 to n Sij = ai + aj + 2;arrow_forward
- Analyze another algorithm under Divide and Conquer. In your discussion, include the following: 1. Introduction about the algorithm. 2. The pseudocode 3. Explanation of its complexityarrow_forwardFollowing are the various algorithms time complexities expressions. Find the dominant terms and specify the Big-Oh complexity of each algorithm. S. No. Expression Dominant term(s) O (. . .) 1. 75 + 0.001n1.3 + 0.025n + (1000)4 2. 500n + 100n + 50n log10 n 3. (10n1.5)4 + 0.3n + 5n6.5 + 2.5 · n2.75 4. 150n3 + n2 log2 n + n(log2 n)4 5. 3 log10 n + log2 log2 n 6. 100n4 + 0.01n2 + 200(log2 n)4 7. n3 + 0.01n + 100n2 + 5n3 8. 2n0.5 + n0.35 + 0.5n0.25 9. 0.01n2 log2 n + n(log2 n) 10. 50n3 log3 n + n5 log3 n + 100n4arrow_forwardFollowing are the various algorithms time complexities expressions. Find the dominant terms and specify the Big-Oh complexity of each algorithm. S. No. Expression Dominant term(s) O (. . .) 1. 75 + 0.001n1.3 + 0.025n + (1000)4 2. 500n + 100n + 50n log10 n 3. (10n1.5)4 + 0.3n + 5n6.5 + 2.5 · n2.75 4. 150n3 + n2 log2 n + n(log2 n)4 5. 3 log10 n + log2 log2 n 6. 100n4 + 0.01n2 + 200(log2 n)4 7. n3 + 0.01n + 100n2 + 5n3 8. 2n0.5 + n0.35 + 0.5n0.25 9. 0.01n2 log2 n + n(log2 n) 10. 50n3 log3 n + n5 log3 n + 100n4arrow_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