Computer Science: An Overview (12th Edition)
12th Edition
ISBN: 9780133760064
Author: Glenn Brookshear, Dennis Brylow
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6, Problem 8CRP
Suppose f is a function that returns the result of reversing the string of symbols given as its input, and g is a function that returns the concatenation of the two strings given as its input. If x is the string abcd, what is returned by g(f(x), x)?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Two words are anagrams if they are formed by rearranging the letters of another, such as
cinema, formed from iceman, and vice versa.
Implement an anagram checker function using string functions in C.
Your program should be able to:
1. Scan for the two words to be checked
2. Pass those two words to a function called areAnagrams which returns an int to be
interpreted in the main() whether the given words are anagrams or not.
3. The program should loop indefinitely until the words "EXIT NOW" is used as input.
Sample Run:
Enter two strings: cinema iceman
cinema and iceman are anagrams!
Enter two strings: almost atoms
almost and atoms are NOT anagrams
Enter two strings: vice versa
vice and versa are NOT anagrams!
Enter two strings: frail flare
frail and flare are NOT anagrams!
Enter two strings: algorithm logarithm
algorithm and logarithm are anagrams!
Enter two strings: EXIT NOW
We can assign a value to each character in a word based on their
position in the alphabet (a = 1, b = 2, ..., z = 26). A balanced word
is one where the sum of the values on the left side of the word equals
the sum of the values on the right side. For odd-length words, the
middle character (balance point) is ignored.
Write a function that returns true if the word is balanced and false if
it is not.
Examples
balance("zips") → true
// "zips" = "zi|ps"
"zips" = 26+9 | 16+19
= 35 35 = true
balanced ("brake") → false
// "brake" = "br|ke" = 2+18 11+5 = 2016 = false
li
Write the function strend (s ,t ), which returns 1 if the string t occurs at the end of the string s, and zero otherwise.
Chapter 6 Solutions
Computer Science: An Overview (12th Edition)
Ch. 6.1 - In what sense is a program in a third-generation...Ch. 6.1 - We can summarize the imperative programming...Ch. 6.1 - Prob. 4QECh. 6.2 - Why is the use of a constant considered better...Ch. 6.2 - Prob. 2QECh. 6.2 - Prob. 3QECh. 6.2 - Identity some common control structures found in...Ch. 6.2 - What is the difference between an array and an...Ch. 6.3 - Prob. 1QECh. 6.3 - Prob. 2QE
Ch. 6.3 - Why do many programming languages implement I/O...Ch. 6.3 - Prob. 4QECh. 6.3 - Prob. 5QECh. 6.4 - Prob. 1QECh. 6.4 - What is a symbol table?Ch. 6.4 - What is the difference between a terminal and a...Ch. 6.4 - Prob. 4QECh. 6.4 - Prob. 5QECh. 6.4 - Prob. 6QECh. 6.5 - What is the difference between an object and a...Ch. 6.5 - Prob. 2QECh. 6.5 - Suppose the classes PartTimeEmployee and...Ch. 6.5 - What is a constructor?Ch. 6.5 - Why are some items within a class designated as...Ch. 6.6 - Prob. 1QECh. 6.6 - Prob. 2QECh. 6.6 - Prob. 3QECh. 6.7 - Prob. 2QECh. 6.7 - Prob. 3QECh. 6.7 - Prob. 4QECh. 6 - Prob. 1CRPCh. 6 - Translate the following Python program into the...Ch. 6 - Prob. 3CRPCh. 6 - Why was it necessary to identify the type of data...Ch. 6 - Prob. 6CRPCh. 6 - Suppose the function f expects two numeric values...Ch. 6 - Suppose f is a function that returns the result of...Ch. 6 - Prob. 9CRPCh. 6 - Summarize the distinction between a machine...Ch. 6 - John Programmer argues that the ability to declare...Ch. 6 - Summarize the distinction between declarative...Ch. 6 - Explain the differences between a literal, a...Ch. 6 - a. What is operator precedence? b. Depending on...Ch. 6 - Prob. 16CRPCh. 6 - What is the difference between the meaning of the...Ch. 6 - Draw a flowchart representing the structure...Ch. 6 - Prob. 19CRPCh. 6 - Prob. 20CRPCh. 6 - Draw a flowchart representing the structure...Ch. 6 - Rewrite the following program segment using a...Ch. 6 - Summarize the following rats-nest routine with a...Ch. 6 - Prob. 24CRPCh. 6 - Prob. 25CRPCh. 6 - Suppose the variable X in a program was declared...Ch. 6 - Prob. 27CRPCh. 6 - Why would a large array probably not be passed to...Ch. 6 - Sometimes an actual parameter is passed to a...Ch. 6 - Prob. 32CRPCh. 6 - What ambiguity exists in the statement X = 3 + 2 ...Ch. 6 - Suppose a small company has five employees and is...Ch. 6 - Prob. 35CRPCh. 6 - Prob. 36CRPCh. 6 - Prob. 37CRPCh. 6 - Prob. 38CRPCh. 6 - Prob. 39CRPCh. 6 - Design a set of syntax diagrams that describes the...Ch. 6 - Prob. 41CRPCh. 6 - Prob. 42CRPCh. 6 - Add syntax diagrams to those in Question 5 of...Ch. 6 - Prob. 44CRPCh. 6 - What code optimization could be performed by a...Ch. 6 - Simplify the following program segment Y = 5 if (Y...Ch. 6 - Simplify the following program segment while (X !=...Ch. 6 - In an object-oriented programming environment, how...Ch. 6 - Describe how inheritance might be used to develop...Ch. 6 - What is the difference between the public and...Ch. 6 - a. Give an example of a situation in which an...Ch. 6 - Describe some objects that might be found in a...Ch. 6 - Prob. 53CRPCh. 6 - Prob. 54CRPCh. 6 - Prob. 55CRPCh. 6 - Prob. 56CRPCh. 6 - Prob. 57CRPCh. 6 - Prob. 58CRPCh. 6 - Prob. 59CRPCh. 6 - In general copyright laws support ownership rights...Ch. 6 - By using a high-level programming language, a...Ch. 6 - Prob. 3SICh. 6 - Prob. 4SICh. 6 - Prob. 5SICh. 6 - Suppose an amateur programmer writes a program for...Ch. 6 - Prob. 7SI
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
The following perfectly valid C program was written without much attention paid to its format. As you will obse...
Programming in C
T F The base class constructor is called after the derived class constructor.
Starting Out with C++ from Control Structures to Objects (8th Edition)
What is the general problem with static scoping?
Concepts of Programming Languages (11th Edition)
Assume the following statement appears in a program: days = 'Monday Tuesday Wednesday'
Starting Out with Python (4th Edition)
What is a source program?
Absolute Java (6th Edition)
What two questions should you ask to determine a classs responsibilities?
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
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
- Write a function that takes two integers and returns True if the integers have a common divisor that is different than 1, otherwise returns False. For example, notRelPrime(3,5) returns False, whereas notRelPrime (8,12) returns True. Because, 3 and 5 have only one common divisor, which is 1, whereas 8 and 12 are both divisible by 1, 2 and 4. def notRelPrime (a, b):arrow_forwardWrite the function that takes three dimensions of a brick: height(a), width(b) and depth(c) and returns true if this brick can fit into a hole with the width (w) and height(h). Examples doesBrickFit(1, 1, 1, 1, 1) → true doesBrickFit(1, 2, 1, 1, 1) → true doesBrickFit(1, 2, 2, 1, 1) false Notes • You can turn the brick with any side towards the hole. • We assume that the brick fits if its sizes equal the ones of the hole (i.e. brick size should be less than or equal to the size of the hole, not strictly less). • You can't put a brick in at a non-orthogonal angle.arrow_forwardIn Kotlin, write a higher-order function with an expression body that takes an int n and a function f from int to int and returns the result of calling f(f(n)). For example if you call the function with n = -5 anda function that calculates absolute value, your function will return 5, and if you send the value 2 and a function that calculates the sqaure of an int, the function will return 16. in addition to the function, write the syntax to call it with:a. a function name as the function arguementb. some lambda expression as the function argumentarrow_forward
- write c++ program Write a function, isPalindrome, that returns true if a string is a palindrome and false otherwise. A string is a palindrome if it reads forward and backward in the same way. For example, the strings "madamimadam", "5", "434", and "789656987" are all palindromes. The prototype of the function is as follows: bool isPalindrome(string str);arrow_forwardWrite a function that takes two integers and returns True if the integers have a common divisor that is different than 1, otherwise returns False. For example, notRelPrime(3,5) returns False, whereas notRelPrime(8,12) returnsTrue. Because, 3 and 5 have only one common divisor, which is 1, whereas 8 and 12 are both divisible by 1, 2 and 4.arrow_forwardWrite out a function that prints out all the permutations of a string. For example, abc would give you abc, acb, bac, bca, cab, cba.arrow_forward
- We can assign a value to each character in a word, based on their position in the alphabet (a = 1, b = 2, ..., z = 26). A balanced word is one where the sum of values on the left-hand side of the word equals the sum of values on the right-hand side. For odd length words, the middle character (balance point) is ignored. Write a function that returns true if the word is balanced, and false if it's not. Examples balanced ("zips") → true // "zips" = "zi|ps" = 26+9|16+19 = 35|35 = true balanced ("brake") // "brake" = "br|ke" false = 2+18 | 11+5 = 20 16 = falsearrow_forwardGiven a letter, created a function which returns the nearest vowel to the letter. If two vowels are equidistant to the given letter, return the earlier vowel. Examples nearest Vowel("b") - "a" nearestVowel("s") → "u" nearest Vowel ("c") → "a" nearest Vowel("i") → "i"arrow_forwardWrite a function sumOddInts(). sumOddInts should return the sum of all odd integers between the values provided to the two parameters, inclusive, e.g., sumOddInts(5,9) should return 21. start and finish do not have to be odd, e.g, sumOddInts (4,8) should return 12. start and finish do not have to be positive, e.g., sumoddlnts(-5,7) should return 7, However, finish may be assumed to be greater or equal to start. whereas Python has a modulo operator "%", MATLAB has a built-in mod() function that returns the remainder. For instance, >> mod (13,5) ans = 3 >> mod (13,2) ans = 1 Notes: End all assignment statements with a semi-colon to suppress output to screen. Include the key word end at the end of your function.arrow_forward
- Create a function that takes two integers, num and n, and returns an integer which is divisible by n and is the closest to num. If there are two numbers equidistant from num and divisible by n, select the larger one. Examples roundNumber (33, 25). - 25 roundNumber (46, 7)→ 49 roundNumber (133, 14) → 140arrow_forward5. Write a function harmonic that will take an integer n as a parameter and return the result of the harmonic series: Γράψτε μια συνάρτηση harmonic που θα πάρει έναν ακέραιο η ως παράμετρο και θα επιστρέψει το αποτέλεσμα της αρμονικής σειράς: 1 1 -+-+-+ 3 + 2 For example, harmonic (2) = 1.5 and harmonic (3) = 1.833arrow_forwardGiven an integer n as input, print smallest number x such that x >= n and x is a palindrome. You havedone a question to find whether a number is a palindrome or not in the previous assignment. Using thesame logic, write a function palindrome_helper (int p) such that it returns whether a numberp is a palindrome or not?Format:int palindrome_helper (int p){// write your logic here}main(){/* Read n;Call palindrome_helper () to check smallest number xsuch that smallest x >= n, and x is a palindrome */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
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY