Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5, Problem 46CRP
Design an
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Name:
Na
ID: A
Name:
3. An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two
versions of the algorithm below.
Algorithm I: Set the value of a variable max to - 1. Iterate through the list of integer values. If a data value is
greater than the value of the variable max, set max to the data value.
Algorithm II : Set the value of a variable max to the first data value. Iterate through the remaining values in
the list of integers. If a data value is greater than the value of the variable max, set max to the data value.
Which of the following statements best describes the behavior of the two algorithms?
Algorithm I always works correctly, but
Algorithm II only works correctly when
the maximum value is not the first value
Both algorithms work correctly on all
input values.
а.
с.
in the list.
b. Neither algorithm will correctly identify d. Algorithm II always works correctly, but
the maximum value when the input
contains both positive and…
Programming
Python language
Chapter 5 Solutions
Computer Science: An Overview (12th Edition)
Ch. 5.1 - Prob. 1QECh. 5.1 - Prob. 2QECh. 5.1 - Prob. 3QECh. 5.1 - Suppose the insertion sort as presented in Figure...Ch. 5.2 - A primitive in one context might turn out to be a...Ch. 5.2 - Prob. 2QECh. 5.2 - The Euclidean algorithm finds the greatest common...Ch. 5.2 - Describe a collection of primitives that are used...Ch. 5.3 - Prob. 2QECh. 5.3 - Prob. 3QE
Ch. 5.3 - Prob. 4QECh. 5.4 - Modify the sequential search function in Figure...Ch. 5.4 - Prob. 2QECh. 5.4 - Some of the popular programming languages today...Ch. 5.4 - Suppose the insertion sort as presented in Figure...Ch. 5.4 - Prob. 5QECh. 5.4 - Prob. 6QECh. 5.4 - Prob. 7QECh. 5.5 - What names are interrogated by the binary search...Ch. 5.5 - Prob. 2QECh. 5.5 - What sequence of numbers would be printed by the...Ch. 5.5 - What is the termination condition in the recursive...Ch. 5.6 - Prob. 1QECh. 5.6 - Give an example of an algorithm in each of the...Ch. 5.6 - List the classes (n2), (log2n), (n), and (n3) in...Ch. 5.6 - Prob. 4QECh. 5.6 - Prob. 5QECh. 5.6 - Prob. 6QECh. 5.6 - Prob. 7QECh. 5.6 - Suppose that both a program and the hardware that...Ch. 5 - Prob. 1CRPCh. 5 - Prob. 2CRPCh. 5 - Prob. 3CRPCh. 5 - Select a subject with which you are familiar and...Ch. 5 - Does the following program represent an algorithm...Ch. 5 - Prob. 6CRPCh. 5 - Prob. 7CRPCh. 5 - Prob. 8CRPCh. 5 - What must be done to translate a posttest loop...Ch. 5 - Design an algorithm that when given an arrangement...Ch. 5 - Prob. 11CRPCh. 5 - Design an algorithm for determining the day of the...Ch. 5 - What is the difference between a formal...Ch. 5 - Prob. 14CRPCh. 5 - Prob. 15CRPCh. 5 - The following is a multiplication problem in...Ch. 5 - Prob. 17CRPCh. 5 - Four prospectors with only one lantern must walk...Ch. 5 - Starting with a large wine glass and a small wine...Ch. 5 - Two bees, named Romeo and Juliet, live in...Ch. 5 - What letters are interrogated by the binary search...Ch. 5 - The following algorithm is designed to print the...Ch. 5 - What sequence of numbers is printed by the...Ch. 5 - Prob. 24CRPCh. 5 - What letters are interrogated by the binary search...Ch. 5 - Prob. 26CRPCh. 5 - Identity the termination condition in each of the...Ch. 5 - Identity the body of the following loop structure...Ch. 5 - Prob. 29CRPCh. 5 - Design a recursive version of the Euclidean...Ch. 5 - Prob. 31CRPCh. 5 - Identify the important constituents of the control...Ch. 5 - Identify the termination condition in the...Ch. 5 - Call the function MysteryPrint (defined below)...Ch. 5 - Prob. 35CRPCh. 5 - Prob. 36CRPCh. 5 - Prob. 37CRPCh. 5 - The factorial of 0 is defined to be 1. The...Ch. 5 - a. Suppose you must sort a list of five names, and...Ch. 5 - The puzzle called the Towers of Hanoi consists of...Ch. 5 - Prob. 41CRPCh. 5 - Develop two algorithms, one based on a loop...Ch. 5 - Design an algorithm to find the square root of a...Ch. 5 - Prob. 44CRPCh. 5 - Prob. 45CRPCh. 5 - Design an algorithm that, given a list of five or...Ch. 5 - Prob. 47CRPCh. 5 - Prob. 48CRPCh. 5 - Prob. 49CRPCh. 5 - Prob. 50CRPCh. 5 - Prob. 51CRPCh. 5 - Does the loop in the following routine terminate?...Ch. 5 - Prob. 53CRPCh. 5 - Prob. 54CRPCh. 5 - The following program segment is designed to find...Ch. 5 - a. Identity the preconditions for the sequential...Ch. 5 - Prob. 57CRPCh. 5 - Prob. 1SICh. 5 - Prob. 2SICh. 5 - Prob. 3SICh. 5 - Prob. 4SICh. 5 - Prob. 5SICh. 5 - Is it ethical to design an algorithm for...Ch. 5 - Prob. 7SICh. 5 - Prob. 8SI
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Explain the benefits of marking transaction boundaries, declaring lock characteristics, and letting a DBMS plac...
Database Concepts (8th Edition)
This optional Google account security feature sends you a message with a code that you must enter, in addition ...
SURVEY OF OPERATING SYSTEMS
Look at the following code: String str1 = To be, or not to be; String str2 = str1.replace(o, u); System.out.pri...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
What is a ToolTip?
Starting Out With Visual Basic (8th Edition)
In Exercises 33 through 40, determine the output displayed in the list box by the lines of code.
Introduction To Programming Using Visual Basic (11th Edition)
Write an if-else statement that assigns 1 to x when y is equal to 100. Otherwise, it should assign 0 to x.
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Using Pseudocode structure, write an algorithm that takes as input distinct integers and finds the location of the largest even integer in the list or returns 0 if there are no even integers in the list.arrow_forwardSolve the following question either by uploading the answer or by writing in the input text area. Apply the insertion sort algorithm to the following list. Show all steps. 60, 15, 18, 1, 9 A- BI = E E Earrow_forwardLangauge is python 3arrow_forward
- 35. A particular sorting algorithm takes integer list 10, 6, 8 and incorrectly sorts the list to 6, 10, 8. What is true about the algorithm's correctness for sorting an arbitrary list of three integers? A.The algorithm is correct. B.The algorithm is incorrect. C.The algorithm's correctness is unknown. D.The algorithm only works for 10, 6, 8.arrow_forwardGiven a sorted list 8, 12, 26, 39, 45, 51, 67, 78. Find 51 in an array of the above elements using the following algorithm. Write down the coding in c++ programming and provide the output: 1. Sequential algorithm 2. Binary search algorithmarrow_forwardAssume you have the following list of integer numbers. Show a list the numbers which will be successively selected for comparisons when a binary search algorithm is searching for number 42. 1, 7, 15, 18, 21, 26, 32, 42, 43, 49, 54, 59, 60, 67, 71, 77, 81arrow_forward
- Q2: a. Write an algorithm that searches a sorted list of n items by dividing it into three sublists of almost n/3 items. This algorithm finds the sublist that might contain the given item and divides it into three smaller sublists of almost equal size. The algorithm repeats this process until it finds the item or concludes that the item is not in the list. Dry run the above algorithm to find the value 240. A[] = {10,15,20,60,65,110,150,220,240,245,260,290,300,460,470,501}arrow_forwardJava Programming Allow the user to enter 10 numbers, sort and display the list in ascending and descending order. Solve the problem using Bubble Sortarrow_forwardQuestion in image Please explain the algorithm with the answer. Python programmingarrow_forward
- Computer Science Design a logic for a program that prompt a user for 10 items and store them within an array. Using bubble sort algorithm, sort out your array and print out the median of the sorted list within the array. The list should be sorted in an ascending order.arrow_forwardan algorithm ==> psudocode pleasearrow_forwardQuestion in image Please explain the algorithm with the answer. Python programmingarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License