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 23CRP
What sequence of numbers is printed by the following
def MysteryWrite(Last, Current):
if (Current < 100):
print(Current)
Temp = Current + Last
MysteryWrite(Current, Temp)
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
# Lists A and B of integers are in the input, each on a separate line.
# Task: Substitute all occurrences of maximum in B by minimum of value of A.
#Print modified B. Print only values separated by single spaces.
111
Example:
Input
3
23452345 2 3 4 5
55 20 33 11 55 33 11 33 44 44 55
Output
Assume n is a positive integer. Consider the loop below:
x := 0
for i:= 5 to 5n
x = 2(x+i) - 7
next i
There are
the total number of operations performed in this loop is
operations performed in each run of the loop and the loop runs
times, so
Explain Algorithm: To sequentially search for the first occurring even number in the list of numbers given.Input 1: –1, 3, 5, 7, –5, 7, 11, –13, 17, 71, 21, 9, 3, 1, 5, –23, –29, 33, 35, 37, 40.Input 2: 6, 17, 71, 21, 9, 3, 1, 5, –23, 3, 64, 7, –5, 7, 11, 33, 35, 37, –3, –7, 11.Input 3: 71, 21, 9, 3, 1, 5, –23, 3, 11, 33, 36, 37, –3, –7, 11, –5, 7, 11, –13, 17, 22.
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
ICA 13-22
As a reminder, the Reynolds number is discussed in Chapter 9. Dimensionless Number.
When discussing t...
Thinking Like an Engineer: An Active Learning Approach (4th Edition)
Why is grain spacing important in grinding wheels?
Degarmo's Materials And Processes In Manufacturing
Use what you've learned about the binary numbering system in this chapter to convert the following decimal numb...
Starting Out with Python (4th Edition)
Write an application that reads two integers, determines whether the first is a multiple of the second and prin...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Consider the following class declaration: public class Circle { private double radius; public Circle(double r) ...
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
The ____________ is always transparent.
Web Development and Design Foundations with HTML5 (8th Edition)
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
- Which one is correct for the following snippet of code? def factorial1(x): if x== 0: return 1 return x *factorial1(x-1) def factorial2 (x,y=1): if x== 0: return y return factorial2 (x-1,x*y) Group of answer choices a) Both factorial1() and factorial2() aren’t tail recursive. b) Both factorial1() and factorial2() are tail recursive. c) factorial1() is tail recursive but factorial2() isn’t. d) factorial2() is tail recursive but factorial1() isn’t.arrow_forwardFor Loop Code in Java (more details in the pic below)arrow_forwardWhich for statement repeats for all positive four-digit integers in decreasing order? I.e.: the for loop will repeat for 9999, 9998, 9997, ..., 1000. Select one: a. for (int j = 9999; j > 1000; j--) b. for (int j = 1000; j 999; j--) e. None of the othersarrow_forward
- Q2: Write an Algorithm to evaluate the following equations: X4 x6 x8 x10 3. Y = X2 + 3! .N Terms 5! 7! 9!arrow_forwardA factorial of N is defined as 1 if N is 0 or 1, and 1*2*...*N if N is a non-negative integer. Write a program that would accept a value for N and would compute and display its factorial. For example: Input Result 0 1 5 P 120arrow_forwardSum of digits algorithm Step 1: Get number by user Step 2: Get the moduusiremainder of the number Step 3: sum the remainder of the number Stop 4: Divde the number by 10 Step 5: Repeat the stop 2 while number is greater than 0 CODE DISSECTION int netr, sum-0,mdata; Screen prompt while(n>0) { Apalindrome number is a rumber hast is same after reverse. For ecample 121, 34543, 343, 131, 994 are he patindrome numbers. COOE DISSECTION: tinclude int main ( int ndatain,value,sum-,tempralue; (Screen Prompt whileno0) ( sum"(sum multiply by 10ervalue; VAsterisk is sensitive character in HSP else returnarrow_forward
- Nonearrow_forwardUsing VBA: Write a guessing game where the user has to guess a secret number. After every guess the program tells the user whether their number was too large or too small. At the end the number of tries needed should be printed. The guess counts only as one try if they input the same number multiple times consecutivelyarrow_forwardGiven an integer n, you can do the following replacement operations: 1. Replace n with n/2 if n is even 2. Replace n with either n - 1 or n + 1 if n is odd Given an integer n, determine the minimum number of replacements needed to reach 1? For example, if n = 50, then we need a minimum of 7 replacements, as follows: 50 divide by 2 →25 50 add 1 23- Another example, if n = 23, then we need a minimum of 6 replacements, as follows: divide by 2 subtract 1 24 Output: 24 12 divide by 2 divide by 2 12 6 Please use recursion to solve this task and do NOT use loops. Sample Testcase 0: Input: divide divide by 2arrow_forward
- 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…arrow_forwardPYTHON CODING Find the Closest Point to the starting point We want to use the formula below to calculate distance between two coodinates: import math import from math sqrt def distance(p1, p2): distance = sqrt (((p1 [0] - p2 [0]) **2) + ((p1 [1] - p2 [1]) **2)) return distance Now we want to find which of the coodinates in the list (remaining_points) is closest to the starting point. def find_closest (start_point, remaining_points): #enter code here return closest_point EXAMPLE INPUT & OUTPUT: find_closest((5,8), [(5.5,3), (3.5,1.5), (2.5,3.5), (7.5,9), (1,3), (7,9.5), (9,2), (1,0), (6,8), (3,7.5), (8,2.5)])# should return (6, 8)arrow_forwardMailbox Mnemonic Code IN STO 90 IN ADD 90 STO 90 IN SUB 90 OUT COB 00 01 02 1. The following Little Man program is supposed to add two input numbers, subtract a third input number from the sum, and output the result, i.e., OUT = IN1 + IN2 – IN3 03 04 05 06 07 08 Numeric Code 901 390 901 190 390 901 290 902 000 What is wrong with this program? Modify the program so that it produces the correct result.arrow_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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License