Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Chapter 12, Problem 34CRP
Explanation of Solution
Whether the following
- In the given algorithm, there is a direction that is given to a specified location. The instructions given in the algorithm are clear except the instruction that is “Ask the person standing on the corner if you should turn right or left...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Please assist with problem.
Note: Answer the question using Java language only.
Shaker is the first child who got scholarship into the village. He went to London to
study where he finds it very interesting to calculate number of ways of going to
point (c, d) from point (a, b) in co-ordinate plane. We can take horizontal and vertical
steps only and cannot visit at a point twice. In a step, you can move one unit only. We
have to reach to the point (c, d) from the point (a, b) using abs(a-c) + abs(b-d) steps
only. Shaker has two sets of points. Set A contains points having X co-
ordinate 0 and Y co-ordinates varying from 1 to N (both inclusive). Set B contains
points having X co-ordinate K and Y co-ordinates varying from 1 to N (both inclusive).
Both sets contain N number of integral points. He wants to calculate the sum of
number of ways to going to each point of set B from each point of set A.
Input
1
22
Output
8
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?
Chapter 12 Solutions
Computer Science: An Overview (12th Edition)
Ch. 12.1 - Prob. 1QECh. 12.1 - Prob. 2QECh. 12.1 - Prob. 3QECh. 12.1 - Prob. 4QECh. 12.2 - Prob. 1QECh. 12.2 - Prob. 2QECh. 12.2 - Prob. 3QECh. 12.2 - Prob. 4QECh. 12.2 - Prob. 5QECh. 12.3 - Prob. 1QE
Ch. 12.3 - Prob. 3QECh. 12.3 - Prob. 5QECh. 12.3 - Prob. 6QECh. 12.4 - Prob. 1QECh. 12.4 - Prob. 2QECh. 12.4 - Prob. 3QECh. 12.5 - Prob. 1QECh. 12.5 - Prob. 2QECh. 12.5 - Prob. 4QECh. 12.5 - Prob. 5QECh. 12.6 - Prob. 1QECh. 12.6 - Prob. 2QECh. 12.6 - Prob. 3QECh. 12.6 - Prob. 4QECh. 12 - Prob. 1CRPCh. 12 - Prob. 2CRPCh. 12 - Prob. 3CRPCh. 12 - In each of the following cases, write a program...Ch. 12 - Prob. 5CRPCh. 12 - Describe the function computed by the following...Ch. 12 - Describe the function computed by the following...Ch. 12 - Write a Bare Bones program that computes the...Ch. 12 - Prob. 9CRPCh. 12 - In this chapter we saw how the statement copy...Ch. 12 - Prob. 11CRPCh. 12 - Prob. 12CRPCh. 12 - Prob. 13CRPCh. 12 - Prob. 14CRPCh. 12 - Prob. 15CRPCh. 12 - Prob. 16CRPCh. 12 - Prob. 17CRPCh. 12 - Prob. 18CRPCh. 12 - Prob. 19CRPCh. 12 - Analyze the validity of the following pair of...Ch. 12 - Analyze the validity of the statement The cook on...Ch. 12 - Suppose you were in a country where each person...Ch. 12 - Prob. 23CRPCh. 12 - Prob. 24CRPCh. 12 - Suppose you needed to find out if anyone in a...Ch. 12 - Prob. 26CRPCh. 12 - Prob. 27CRPCh. 12 - Prob. 28CRPCh. 12 - Prob. 29CRPCh. 12 - Prob. 30CRPCh. 12 - Prob. 31CRPCh. 12 - Suppose a lottery is based on correctly picking...Ch. 12 - Is the following algorithm deterministic? Explain...Ch. 12 - Prob. 34CRPCh. 12 - Prob. 35CRPCh. 12 - Does the following algorithm have a polynomial or...Ch. 12 - Prob. 37CRPCh. 12 - Summarize the distinction between stating that a...Ch. 12 - Prob. 39CRPCh. 12 - Prob. 40CRPCh. 12 - Prob. 41CRPCh. 12 - Prob. 42CRPCh. 12 - Prob. 43CRPCh. 12 - Prob. 44CRPCh. 12 - Prob. 46CRPCh. 12 - Prob. 48CRPCh. 12 - Prob. 49CRPCh. 12 - Prob. 50CRPCh. 12 - Prob. 51CRPCh. 12 - Prob. 52CRPCh. 12 - Prob. 1SICh. 12 - Prob. 2SICh. 12 - Prob. 3SICh. 12 - Prob. 4SICh. 12 - Prob. 5SICh. 12 - Prob. 6SICh. 12 - Prob. 7SICh. 12 - Prob. 8SI
Knowledge Booster
Similar questions
- How many (positive) factors does the integer 60 have? (Both 1 and 60 are factors of 60). Enter your answer as an integer with no words. How many (positive) factors does the integer 100 have? (Both 1 and 100 are factors of 100). Enter your answer as an integer with no words.arrow_forwardAlgorithm Analysis Start with 102 coins on a table, 98 showing heads and 4 showing tails. There are two ways to change the coins: • flip over any ten coins, or • place n+ 1 additional coins, all showing tails, on the table where n is the number of heads currently showing on the table. For example, you might begin by flipping nine heads and one tail, yielding 90 heads and 12 tails, then add 91 tails, yielding 90 heads and 103 tails. (a) Model this situation as a state machine, carefully defining the set of states, the start state, and the possible state transitions. (b) Optionally, explain how to reach a state with exactly one tail showing. (c) Consider the following derived variables: C ::= the number of coins on the table H ::= the number of heads on the table T::= the number of tails on the table C, ::= parity (C) H2 ::= parity(H) T2 ::= parity(T) Here the parity : Z → {0,1} function is defined as parity(n) = 0 when n is even and 1 otherwise. Which of these variables is strictly…arrow_forwardStory: Once upon a time a farmer went to a market and purchased a wolf, a goat, and a cabbage. On his way home, the farmer came to the bank of a river and rented a boat. But crossing the river by boat, the farmer could carry only himself and a single one of his purchases: the wolf, the goat, or the cabbage. If left unattended together, the wolf would eat the goat, or the goat would eat the cabbage. Problem: Create a Flowchart and Algorithm of all the possible solutions on how the farmer carry himself and his purchases to the far bank of the river, leaving each purchase intact.arrow_forward
- Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science. Two cells are adjoining in the event that they share a side. Thusly, every cell (x, y) has precisely three neighbors: (x+1, y) (x−1, y) (x+1, y−1) in case x is even and (x−1, y+1) in any case. At first a few cells are contaminated, all the others are sound. The course of recuperation starts. Each second, for precisely one cell (despite the fact that there may be different cells that could change its state) one of the accompanying occurs: A sound cell with something like 2 contaminated neighbors likewise becomes tainted. A contaminated cell with something like 2 solid neighbors likewise becomes sound. In the event that no such cell exists, the course of recuperation stops. Patient is considered recuperated if the course of recuperation has halted and every one of the cells are solid. We're keen on a most dire outcome imaginable: is it conceivable that the patient…arrow_forwardAlgorithmarrow_forwardSuppose that you are given an n × n checkerboard and a checker. You must move the checker from the bottom edge of the board to the top edge of the board according to the following rule. At each step you may move the checker to one of three squares: 1. the square immediately above 2. the square that is one up and one to the left (but only if the checker if not already in the leftmost column) 3. the square that is one up and one to the right (but only if the checker is not already in the rightmost column). 1 Each time you move from square x to square y, you receive p(x, y) dollars. You are given p(x, y) for all pairs (x, y) for which a move from x to y is legal. Do not assume that p(x, y) is positive. design a recursive backtracking algorithm that determines the maximum amount of money you can recieve, when moving a checker frmo somewhere on the bottom row to somewhere on the top row. your algorithm is free to pick any squrre along the bottom row as a starting point and any square along…arrow_forward
- You are asked to determine the value of the decision parameter p used in Bresenham's circle drawing algorithm. The algorithm for drawing circles by Bresenham is presented in a series of instructions.arrow_forwardAlgorithms Question Three points P, Q, and R are said to be collinear if they are on a single line. To check whether the 3 points lie on the same line, we use the distance formula. If P, Q and R are three collinear points, then: Distance from P to Q + Distance from Q to R = Distance from P to R PQ + QR = PR The distance between two points (x1, y1) and (x2, y2) is given by Hence, we can easily find the distance between the points P, Q and R, with the help of this formula. Design an algorithm (pseudocode) to check whether three points are collinear. In your solution include the input and the output.arrow_forwardCorrect answer will be upvoted else Multiple Downvoted. Computer science. You are remaining on the OX-hub at point 0 and you need to move to an integer point x>0. You can take a few leaps. Assume you're at present at point (y might be negative) and hop for the k-th time. You can: either leap to the point y+k or on the other hand leap to the point y−1. What is the base number of hops you want to arrive at the point x? Input The main line contains a solitary integer t (1≤t≤1000) — the number of experiments. The solitary line of each experiment contains the single integer x (1≤x≤106) — the objective point. Output For each experiment, print the single integer — the base number of leaps to arrive at x. It very well may be demonstrated that we can arrive at any integer point x.arrow_forward
- Can you please help me I don’t understand how to solve this with the trading off algorithm, and also I did it once and my teacher said that I got it wrong so she said that I need to try to make 1 number end with 0, and not end with 5 because its easier to add the number that ends with 0 so we don’t need to worry about the carry over. Can you please help me understand what she meant and also help me solve this problem correctly like my teacher wanted it.arrow_forwardPlease answer this only in python Alice and Bob play a game. At first, there is only one tree with roots. The players take turns, Alice begins. At one point, Alice has to pick up any empty underground tree roots (or shrubs) and remove them. Bob, on the other hand, has to pick out any part of the empty leaves and remove them from the tree (or trees). (Please note that Bob always takes some depth from the leaves of the first tree.) It is not allowed to skip the turn. The game ends when the player is unable to take a chance. Alice's goal is to reduce the number of turns made by both players, while Bob wants the number to be greater. Considering that they both played very well, how many turns did they make last. Input 1 2 12 Output 2arrow_forwardCorrect answer will be upvoted else Multiple Downvoted. Computer science. Polycarp has a most loved arrangement a[1… n] comprising of n integers. He worked it out on the whiteboard as follows: he composed the number a1 to the left side (toward the start of the whiteboard); he composed the number a2 to the right side (toward the finish of the whiteboard); then, at that point, as far to the left as could really be expected (yet to the right from a1), he composed the number a3; then, at that point, as far to the right as could be expected (however to the left from a2), he composed the number a4; Polycarp kept on going about too, until he worked out the whole succession on the whiteboard. The start of the outcome appears as though this (obviously, if n≥4). For instance, assuming n=7 and a=[3,1,4,1,5,9,2], Polycarp will compose a grouping on the whiteboard [3,4,5,2,9,1,1]. You saw the grouping composed on the whiteboard and presently you need to reestablish…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