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
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?
Suppose 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…
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
- 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_forwardWhat 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_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_forwardI need the answer as soon as possiblearrow_forwardHelparrow_forward
- Give 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_forwardAnswer question 1. There are two algorithms given in pseudo code.arrow_forwardOn an input of size 100, an algorithm that runs in time lg n requires steps whilst an algorithm that runs in time n! requires roughly 9.3 x 10 to the power.arrow_forward
- Method A conducts 10n2 basic operations, while algorithm B does 300ln(n) basic operations, resulting in a total of 300ln(n) basic operations. At what point does algorithm B begin to outperform algorithm A in terms of performance?arrow_forwardConsider the problem of computing the sum of the first n cubes: S(n) = 13 + 23 + … + n3. Design two algorithms as follows: Recursive algorithm Non-recursive algorithm Analyze the time efficiency of your two algorithms and compare which is better.arrow_forwardWrite a simple code (python). Given a list of n elments with each element between 1 and n. determine whether there are any duplicates. Then find the following: 1. What does the algorithms compute? 2. What is its basic operation? 3. How many times is the basic operation executed? 4. What is the efficiency class of the algorithm? Keep in mind it's an Analysis of Algorithms course.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