Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
13th Edition
ISBN: 9780134875460
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 56CRP
  1. a. Identity the preconditions for the sequential search as represented in Figure 5.6. Establish a loop invariant for the while structure in that program that, when combined with the termination condition, implies that upon termination of the loop, the algorithm will report success or failure correctly.
  2. b. Give an argument showing that the while loop in Figure 5.6 does in fact terminate.
Blurred answer
Students have asked these similar questions
Loop invariants Consider the following code, assuming that i, x, y, and n are integers, with n > 0. • State a non-trivial loop invariant for variable x. • Prove the loop invariant. Be sure that the proof includes the final conditions after the loop has ended. Note: a correct proof of an incorrect invariant will still receive partial credit. • Give the final value of a in terms of n. Hint: is the pattern close to (e.g. off by one) from some other pattern you might recognize? Hint: you might need to include a condition for y somewhere within your proof. i = 0; x = 1; while in do y = x + 2; x=x*y; i = 1 + 1; After the loop, x = (the invariant goes here)
(a) The Fibonacci sequence can also be seen in hurricanes prediction. The shape takes in the form of a spiral, it can be in a nesting process and repeated into infinity. It is called the logarithmic spiral, and it abounds in nature. The Fibonacci sequence of numbers, “Fn”, is defined using the recursive relation. Fibonacci sequence of numbers can be computed as follows: Fn = Fn-1+Fn-2 If the 12th and 13th terms in the hurricane prediction sequence are 89 km/hour and 144 km/hour, analyze the value of the 15th, 16th, and 17th hurricane speed by using the Fibonacci formula as stated above.
a. Correctness of dynamic programming algorithm: Usually, a dynamic programming algorithm can be seen as a recursion and proof by induction is one of the easiest way to show its correctness. The structure of a proof by strong induction for one variable, say n, contains three parts. First, we define the Proposition P(n) that we want to prove for the variable n. Next, we show that the proposition holds for Base case(s), such as n = 0, 1, . . . etc. Finally, in the Inductive step, we assume that P(n) holds for any value of n strictly smaller than n' , then we prove that P(n') also holds. Use the proof by strong induction properly to show that the algorithm of the Knapsack problem above is correct.    b. Bounded Knapsack Problem: Let us consider a similar problem, in which each item i has ci > 0 copies (ci is an integer). Thus, xi is no longer a binary value, but a non-negative integer at most equal to ci , 0 ≤ xi ≤ ci . Modify the dynamic programming algorithm seen at class for this…

Chapter 5 Solutions

Computer Science: An Overview (13th Edition) (What's New in Computer Science)

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
Background pattern image
Computer Science
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
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
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