Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
4th Edition
ISBN: 9780134787961
Author: Tony Gaddis, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 16.3, Problem 16.11CP
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 16 Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Ch. 16.1 - Prob. 16.1CPCh. 16.1 - Prob. 16.2CPCh. 16.1 - Prob. 16.3CPCh. 16.1 - Prob. 16.4CPCh. 16.2 - Prob. 16.5CPCh. 16.2 - Prob. 16.6CPCh. 16.2 - Prob. 16.7CPCh. 16.2 - If a sequential search is performed on an array,...Ch. 16.3 - Prob. 16.9CPCh. 16.3 - Prob. 16.10CP
Ch. 16.3 - Prob. 16.11CPCh. 16.3 - Prob. 16.12CPCh. 16.3 - Prob. 16.13CPCh. 16.3 - Prob. 16.14CPCh. 16.3 - Let a[ ] and b[ ] be two integer arrays of size n....Ch. 16.3 - Prob. 16.16CPCh. 16.3 - Prob. 16.17CPCh. 16.3 - Prob. 16.18CPCh. 16 - Prob. 1MCCh. 16 - Prob. 2MCCh. 16 - Prob. 3MCCh. 16 - Prob. 4MCCh. 16 - Prob. 5MCCh. 16 - Prob. 6MCCh. 16 - Prob. 7MCCh. 16 - Prob. 8MCCh. 16 - Prob. 9MCCh. 16 - Prob. 10MCCh. 16 - True or False: If data is sorted in ascending...Ch. 16 - True or False: If data is sorted in descending...Ch. 16 - Prob. 13TFCh. 16 - Prob. 14TFCh. 16 - Assume this code is using the IntBinarySearcher...Ch. 16 - Prob. 1AWCh. 16 - Prob. 1SACh. 16 - Prob. 2SACh. 16 - Prob. 3SACh. 16 - Prob. 4SACh. 16 - Prob. 5SACh. 16 - Prob. 6SACh. 16 - Prob. 7SACh. 16 - Prob. 8SACh. 16 - Prob. 1PCCh. 16 - Sorting Objects with the Quicksort Algorithm The...Ch. 16 - Prob. 3PCCh. 16 - Charge Account Validation Create a class with a...Ch. 16 - Charge Account Validation Modification Modify the...Ch. 16 - Search Benchmarks Write an application that has an...Ch. 16 - Prob. 8PCCh. 16 - Efficient Computation of Fibonacci Numbers Modify...
Knowledge Booster
Similar questions
- There 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_forwardA 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_forward
- 2) 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_forwardMethod A performs 10 n2 basic operations, while algorithm B does 300ln(n) basic operations, resulting in a difference of 10 n2. At what point does algorithm B begin to outperform algorithm A in terms of performance?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_forward
- 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…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_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
- You are given two algorithms A and B where A has 3,500 instructions and runs in 3 seconds; while B has 26,400 instructions and runs in 2 seconds. If you are required to compare the 2 algorithms, what criteria should you use to determine which of them is better in solving the given problem?arrow_forwardThe 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_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_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