C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6, Problem 6.33RE
(Binary Search) Modify the
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y isthe largest integer that evenly divides both x and y. Write a recursive function gcd that returns thegreatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equalto 0, then gcd(x, y) is x; otherwise gcd(x, y) is gcd(y, x % y), where % is the remainder operator.
Question 4: (Find the minimum value in an array) Write a program that include arecursive function “recursiveMinimum” that takes an integer array and the array size asarguments and returns the smallest element of the array. The function should stopprocessing and return when it receives an array of one element.
(GREATEST COMMON DIVISOR) The greatest common divisor of integers
x and y is the largest integer that evenly divides into both x and y. Write and
test a recursive function gcd that returns the greatest common divisor of x
and y. The gcd of x and y is defined recursively as follows: If y is equal to 0,
then gcd (x, y) is x; otherwise, gcd (x, y) is gcd (y, x % y), where % is the
remainder operator.
Chapter 6 Solutions
C How to Program (8th Edition)
Ch. 6 - Fill in the blanks in each of the following: C...Ch. 6 - State which of the following are true and which...Ch. 6 - Write statements to accomplish each of the...Ch. 6 - Consider a 2-by-5 integer array t. Write a...Ch. 6 - (Sales Commissions) Use a one-dimensional array to...Ch. 6 - (Bubble Sort) The bubble sort presented in Fig....Ch. 6 - Write loops that perform each of the following...Ch. 6 - Prob. 6.13ECh. 6 - (Mean, Median and Mode Program Modifications)...Ch. 6 - (Duplicate Elimination) Use a one-dimensional...
Ch. 6 - Label the elements of 3-by-5 two-dimensional array...Ch. 6 - What does the following program do?Ch. 6 - What does the following program do?Ch. 6 - (Dice Rolling) Write a program that simulates the...Ch. 6 - (Game of Craps) Write a program that runs 1000...Ch. 6 - Prob. 6.21ECh. 6 - (Total Sales) Use a two-dimensional array to solve...Ch. 6 - (Turtle Graphics) The Logo language made the...Ch. 6 - Prob. 6.24ECh. 6 - (Knights Tour: Brute-Force Approaches) In Exercise...Ch. 6 - (Eight Queens) Another puzzler for chess buffs is...Ch. 6 - (Eight Queens: Brute-Force Approaches) In this...Ch. 6 - (Duplicate Elimination) In Chapter 12, we explore...Ch. 6 - (Knights Tour: Closed Tour Test) In the Knights...Ch. 6 - (The Sieve of Eratosthenes) A prime integer is any...Ch. 6 - Prob. 6.31RECh. 6 - (Linear Search) Modify the program of Fig. 6.18 to...Ch. 6 - (Binary Search) Modify the program of Fig. 6.19 to...Ch. 6 - Prob. 6.35RECh. 6 - Prob. 6.36RECh. 6 - Prob. 6.37RE
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
In this chapter, we have introduced some functions with, unsual call and return behaviors longjmp, execve, and ...
Computer Systems: A Programmer's Perspective (3rd Edition)
Explain the difference between the WHERE and HAVING clause.
Modern Database Management
Write a program to print the corresponding Celsius to Fahrenheit table.
C Programming Language
What is a condition-controlled loop?
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Essay Class Design an Essay class that extends the GradedActivity class presented in this chapter. The Essay cl...
Starting Out with Programming Logic and Design (4th Edition)
Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g is...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
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
- (Q7) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you.arrow_forward(Check test scores) The answers to a true-false test are as follows: T T F F T. Given a two-dimensional answer array, in which each row corresponds to the answers provided on one test, write a function that accepts the two-dimensional array and number of tests as parameters and returns a one-dimensional array containing the grades for each test. (Each question is worth 5 points so that the maximum possible grade is 25.) Test your function with the following data: int score = 0;arrow_forward(Towers of Hanoi: Iterative Solution) Any program that can be implemented recursivelycan be implemented iteratively, although sometimes with considerably more difficulty and considerably less clarity. Try writing an iterative version of the Towers of Hanoi. If you succeed, compareyour iterative version with the recursive version you developed in Exercise 5.36. Investigate issuesof performance, clarity, and your ability to demonstrate the correctness of the programs.arrow_forward
- (Recursive Binary Search) Write a recursive method RecursiveBinarySearch to perform abinary search of the array. The method should receive the search key, starting index, endingindex and array A as arguments. If the search key is found, return its index in the array. If thesearch key is not found, return -1.int RecursiveBinarySearch(int search, int start, int end, int[] A)arrow_forward(CP6) Write a function that is passed an array of structs and performs calculations. The function should locate the highest gpa from a group of students. The function is passed the array of structs, the first element to be searched, and the last element to be searched. The return value of the function is the highest gpa in the search range. struct data{ string name; double gpa;}; double highestGpa( data [ ], int, int ); data [ ] - array of structs to search int - first element to be searched int - last element to be searched return - highest gpa from grouparrow_forward(Pointers + Dynamic 1D Arrays) c++ program please use only pointers and dynamic 1D array and please don't use recursion and vector or otherarrow_forward
- (find the minimum valuein an array)write a programthat include a recrusive function "recrusiveMinimum" that takes an integer array and the array size as arguments an return the smallest element of the arraythe function should stop processing and return when it receivesan array of one elementarrow_forward(C Language) Write a recursive function called DigitCount() that takes a non-negative integer as a parameter and returns the number of digits in the integer. Hint: The digit count increases by 1 whenever the input number is divided by 10.arrow_forward(JAVA) Create a two-dimensional array of type double to contain the three different SD Marks (JD521, PRG521, and IP521) for six different students. A single array of type String must be used to store the student names (Maxwell, Carl, Gerhard, Paul, James, and Cena). Allow a user to enter in a number, ranging from 1 to 6, which will represent the student position in the table MCSD max and present the marks for each respecting module. The program can only stop when the user enter a number greater than 6. Printout the student name including the JD521, PRG521, and IP521 max, the total of marks and the average of all marks. Use a condition statement to decide that the student has passed or not (Pass rate is 70). The programming language is java Student name JD521 PRG521 IPG521 Maxwell 80 65 70 Carl 95 70 65 Gerhard 87 80 73 Paul 65 45 60 James 45 87 65arrow_forward
- (IN PYTHON) Problem 2 Write a function count_8s(string) that performs the following actions: Receives a single parameter called string that we expect to be a string. If we receive something that is NOT a string, raise a TypeError with the message “Non-string input received.” Uses recursion to count the number of eights in the string. Use a string of length 0 as your base case. Otherwise, determine if the first character in string is “8” or not, and call count_8s() again with the rest of the string as an argument. Returns the number of eights found in the string. NOTE: You are not to use a while or for loop in your code.arrow_forwardLanguage: C Write a program to reverse an array using recursion. a) Declare an array of N integers. Use the preprocessor #define directive for the size of the array. Fill it with pseudorandom numbers. b) Define the recursive procedure, that reverses the array by swapping the last with the first element, and then recursively swapping the remaining subarray. To this end, define the function void reverseArray(int *inputArray, int leftIndex, int rightIndex). The function should stop the recursion, whenever leftIndex >= rightIndex. c) Print your original, and the reversed array. Test your results for both even, and for odd N.arrow_forward(Q9) This is a Data Structures problem and the programming language used is Lisp. Solve the question we detailed steps and make it concise and easy to understand. Please and thank you.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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License