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 5, Problem 45CRP
Explanation of Solution
Steps to design an
- 1. Create a list of names and then assign it to the variable “a”.
- 2. Consider that the first element is the name with the longest word and then assign it to the variable “temp”.
- 3. Use a “for” loop and “if” statement and then compare the length of each name with the first name.
- 4. Assign the name length to the variable “longest”
- 5. Finally, print the longest name...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
is....... a process of looking for the best sequence is called
solution
problem
Path
search
Write an algorithm (pseudo code) for a program that display a person name x times. Use For loop, while loop, and Do-while loop.
The greatest common divisor of two positive integers, A and B, is the largest number that can be evenly divided into both of them. Euclid’s algorithm can be used to find the greatest common divisor (GCD) of two positive integers. You can use this algorithm in the following manner:
Compute the remainder of dividing the larger number by the smaller number.
Replace the larger number with the smaller number and the smaller number with the remainder.
Repeat this process until the smaller number is zero.
The larger number at this point is the GCD of A and B. Write a program that lets the user enter two integers and then prints each step in the process of using the Euclidean algorithm to find their GCD.
An example of the program input and output is shown below:
Enter the smaller number: 5 Enter the larger number: 15 The greatest common divisor is 5
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
- solve code in matlabarrow_forwardIn a class of n students print the total no. of female students and total no. of male students. At the end print the total no. of students in n class both males and females. In this problem, for loop is required.arrow_forwardCorrect answer will be upvoted else downvoted. Computer science. section grouping is a string containing just characters "(" and ")". A standard section succession is a section grouping that can be changed into a right number juggling articulation by embedding characters "1" and "+" between the first characters of the arrangement. For instance, section successions "()()" and "(())" are normal (the subsequent articulations are: "(1)+(1)" and "((1+1)+1)"), and ")(", "(" and ")" are not. You need to find a string b that comprises of n characters to such an extent that: b is a standard section grouping; in the event that for some I and j (1≤i,j≤n) ai=aj, bi=bj. As such, you need to supplant all events of 'A' with a similar kind of section, then, at that point, all events of 'B' with a similar sort of section and all events of 'C' with a similar sort of section. Your undertaking is to decide whether such a string b exists. Input The primary line contains a solitary…arrow_forward
- The best sequence is list of actions, called solution problem Path searcharrow_forwardDevelop a solution that will calculate the average temperature, given a set of temperatures. The number of temperatures may differ from time to time. (Use a trip values to stop the processing of the loop.) Test the solution with the following 10 temperatures. 78 90 85 80 87 83 75 90 86 70arrow_forwardExercise H for the Nested Loop Nested Loop Problems Write the program that would generate the multiplication table for numbers 1 to 10. For example: Result 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 14 16 18 20 3 6 9 12 15 18 21 24 27 30 4 8 12 16 20 24 28 32 36 40 5 10 15 20 25 30 35 40 45 50 6 12 18 24 30 36 42 48 54 60 7 14 21 28 35 42 49 56 63 70 8 16 24 32 40 48 56 64 72 80 9 18 27 36 45 54 63 72 81 90 10 20 30 40 50 60 70 80 90100arrow_forward
- The following program generates all permutations of the numbers 0, 1, 2, ... , n – 1, without using recursion. The algorithm uses the fact that the set to be permuted consists of distinct numbers. Thus, you cannot use the same algorithm to compute the permutations of the characters in a string. You can, however, use this technique to get all permutations of the character positions and then compute a string whose ith character is s[a[i]]. Use this approach to reimplement the generate_permutations function without recursion. c++arrow_forwardIn a Collatz sequence, all of its terms are positive integers which satisfy the following recursive formula an=0.5an−1 if an−1 is even an=3an−1+1 if an−1 is odd Directions: Given an initial term implement a Collatz sequence, and find its length.Input: a1Output: the length of the Collatz sequence Don't use some sort of menu loop to get user inputarrow_forwardWrite a program for calculating these roots and for graphing them as points on the unit circle. Apply the program to z^n = 1 with n = 2,3...,10. Then extend the program to one for arbitrary roots, using an idea near the end of the text, and apply the program to examples of your choice. PLEASE SHOW THE STEP-BY STEP SOLUTION WITH EXPLANATIONarrow_forward
- Actual timings. Instrument FrequencyCounter to use Stopwatch and StdDrawto make a plot where the x-axis is the number of calls on get() or put() and the y-axisis the total running time, with a point plotted of the cumulative time after each call.Run your program for Tale of Two Cities using SequentialSearchST and again usingBinarySearchST and discuss the results. Note : Sharp jumps in the curve may be explained by caching, which is beyond the scope of this question.arrow_forwardSuppose I have 50 strings. At every step, I randomly pick 2 ends of strings(they could be the ends of the same string) and tie them together. At each step, I couldmake either a longer string or a loop.a) What is the expected number of steps it takes me to turn all the strings into loops?b) What is the expected number of loops? (Express this as a sum)arrow_forwardWrite an algorithm to solve it: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