Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5.6, Problem 6QE
Program Plan Intro
A program segment defines the validity of a program and the validity of set of instructions can be determined by checking expected output values for each input value.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Code the follow.
Description
A mathmatician Goldbach's conjecture: any even number(larger than 2) can divide into two prime number’s sum.But some even numbers can divide into many pairs of two prime numbers’ sum.
Example:10 =3+7, 10=5+5, 10 can divide into two pairs of two prime number.
Input
Input consist a positive even number n(4<=n<=32766).
Output
Print the value of how many pairs are this even number can be divided into.
Sample Input 1
1234
Sample Output 1
25
Written in Python as well as screenshotted accepting user input and computed values
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
Knowledge Booster
Similar questions
- use pythonarrow_forwardYou can approximate e using the following summation: Write a program that displays the e value for i = 10000, 20000, …, and 100000.arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. You are given an integer n. Check if n has an odd divisor, more noteworthy than one (does there exist such a number x (x>1) that n is separable by x and x is odd). For instance, assuming n=6, there is x=3. Assuming n=4, such a number doesn't exist. Input The primary line contains one integer t (1≤t≤104) — the number of experiments. Then, at that point, t experiments follow. Each experiment contains one integer n (2≤n≤1014). If it's not too much trouble, note, that the input for some experiments will not squeeze into 32-cycle integer type, so you should use no less than 64-digit integer type in your programming language. Output For each experiment, output on a different line: "Indeed" if n has an odd divisor, more noteworthy than one; "NO" in any case. You can output "YES" and "NO" regardless (for instance, the strings yEs, indeed, Yes and YES will be perceived as certain).arrow_forward
- PYTHON QUESTION : The Syracuse sequence of an integer N is the sequence of integers starting with the term N, where each following term is half of the preceding term if it is even, and one plus three times the preceding term if it is odd. The sequence ends when it reaches the integer 1. The maximum of the Syracuse sequence of an integer N is the highest number reached by this sequence. This maximum can sometimes be very high compared to the starting integer N. What is the maximum of the Syracuse sequence of 3428767? To answer this question it is useful to modify the code given in demonstration which calculates the Syracuse sequence. The code given in the demo : n = 27 print(n) while n != 1: if n%2 == 0: n = n // 2 # where n //= 2 or n >>= 1 else: n = 1 + 3*n print(n)arrow_forwardNeed help in python. Problem: 2D random walk. A two dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with probability 1/4, independently of previous moves. Compose a program that takes a command-line argument n and estimates how long it will take a random walker to hit the boundary of a 2n+1-by-2n+1 square centered at the starting point. //Given codeImport stdioImport randomImport sysn = int(sys.argv[1])//write code herestdio.write('The walker took ')stdio.write(c)stdio.writeln(' steps')arrow_forwardThe binomial coefficient (n, k) is an integer equal to (n, k) = n! / [k! (n – k)!] Note that n! = n(n – 1)(n – 2) … (1) and that 0! = 1. a) Using this form for the binomial coefficient, write a Python user-defined function binomial(n,k) that calculates the binomial coefficient for given n and k. Make sure your function returns the answer in the form of an integer (not a float) and gives the correct value of 1 for the case where k = 0. Use phyton code to answer,arrow_forward
- pythonarrow_forwardGiven the recursive function below where n is an integer: if n = 0 or n = 1 or n = 2 f(n) = {f(n – 2) + f(n – 4) otherwise Which of the following statements is true? IMPORTANT: There is no "Check" button for this question. You can change the answer as many times as you like. Select one: O a. The function terminates if and only if n is 1 or even. O b. The function terminates if and only if n24. O . The function terminates if and only if n=1 or n is even and greater or equal to 0. O d. The function terminates if and only if n is 0, 1 or 2. O e. The function terminates if and only if n20.arrow_forwardI'm confused every thing....arrow_forward
- Write a recursive algorithm with the following prototype: int divide (int x, int y); that returns x/y (integer division). You need not test for divide by 0. THE FUNCTION MUST BE RECURSIVE. (hint: base case should be when xarrow_forwardWrite a recursive function F(N) that generalízes the following function: NF(N) 1 2 10 19 4 37 5 70 (Hìnt: F(N) computes the output differently for odd and even values of N! Think about the base case first, then think about what would be the recursive case for the odd value of N and what would be the recursive case for an even value of N!) For example: Test Result print(F(0)) 1 Answer: (penalty regime: 0, 0, 0, 0, 0, 5, 10, 15, 20, .. %)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_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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 Ptr
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