Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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 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?
Chapter 9 Solutions
Starting Out With C++: Early Objects (10th Edition)
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
- Suppose 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_forward2) 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 T1(n) = 3 n logn and T2(n) = nº/5 . a) Which algorithm is better? Why? b) If we run both algorithms at the same time with an input size of 10°, which algorithm produces results faster than the other one? Why?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
- The two different algorithms that perform the same complexity process are called B and C. The total number of operations (operations) performed with algorithm B is 64n. The total number of operations performed with the C algorithm is 16 n ^ 2. Here is my question: Determine the problem size n0 where B is better than C for n> n0 please.arrow_forward2) 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 T1(n) = 3 n log n and T2(n) = nº/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_forwardConsider 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_forward
- What is the smallest value of n such that an algorithm whose running time is 100n runs faster than an algorithm whose running time is 2"on the same machine?arrow_forwardThe performance of a binary searching method is logarithmic. O(logn)finding a particular item from a list of 1,000 items takes three seconds. How long do you think it will take to search through a list with 100,000,000 items? How did you come to your conclusion?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
- What one of the following is false? The complexity of time requires more CPU cycles. Less memory is needed because of space's complexity. Time complexity is calculated using the total number of operations. The worst situation for an algorithm is when there are too many operations.arrow_forwardSuppose 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_forwardI need the answer as soon as possiblearrow_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