EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 5, Problem 25E
Program Plan Intro
Interpreter:
- Interpreter executes each statement of a program at a time.
- It calls recursive functions for “statement”, “expression”, “factor”, “term” and “Identifier” to execute a statement.
- It allows arithmetic operations addition, subtraction, multiplication, division and exponentiation.
Explanation of Solution
b. Trace for input “v = x * ( y – w ) - - z”;
Statement() v = x * ( y – w ) - - z;
readId() v = x * ( y – w ) - - z;
expression() x * (y – w ) - - z;
term() x * ( y – w ) - - z;
factor() x * ( y – w ) - - z;
readId() x * ( y – w ) - - z;
factor() ( y – w ) - - z;
checking ‘(’ ( y – w ) - - z;
expression() y – w ) - - z;
term() y – w ) - - z;
factor() y – w ) - - z;
readId() y – w ) - - z;
term() w ) - - z;
factor() w ) - - z;
readId() w ) - - z;
checking ‘)’ ) - - z;
term() �...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Given 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"
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
Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ).
Using c language
Chapter 5 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Ch. 5 - Prob. 1ECh. 5 - Prob. 2ECh. 5 - Prob. 3ECh. 5 - Prob. 4ECh. 5 - Prob. 5ECh. 5 - Prob. 6ECh. 5 - Prob. 7ECh. 5 - Prob. 8ECh. 5 - Prob. 9ECh. 5 - Prob. 10E
Ch. 5 - Prob. 11ECh. 5 - Prob. 12ECh. 5 - Prob. 13ECh. 5 - Prob. 14ECh. 5 - Prob. 15ECh. 5 - Prob. 16ECh. 5 - Prob. 17ECh. 5 - Prob. 18ECh. 5 - Prob. 19ECh. 5 - Prob. 20ECh. 5 - Prob. 21ECh. 5 - Prob. 22ECh. 5 - Prob. 23ECh. 5 - Prob. 24ECh. 5 - Prob. 25ECh. 5 - Prob. 26ECh. 5 - Prob. 27ECh. 5 - Prob. 28ECh. 5 - Prob. 29ECh. 5 - Prob. 1PACh. 5 - Prob. 3PACh. 5 - Prob. 4PACh. 5 - Prob. 5PA
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
- Midterm Practice Problems 1. Use recursion to write a function count_ones that returns how many Is there are in a number n when represented in decimal (base 10). For example, 1231 has two 1s. You can assume that n is nonnegative and at most 9 digits long. Do not use global (or static) variables. In main perform at least three tests of count_ones and use assert to check that the returned value is correct. Your function should have the following prototype: // count_ones (n) returns the number of is in the decimal representation of n // requires: 0 <= n < 10^9 int count_ones (int n);arrow_forwardWrite a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ). In c languagearrow_forward3. You are expected to write a recursive function called powy(base, exponent) that, when called, returns baseponent As an example, powy( 6, 5 ) =6*6*6*6*6. Assume that exponent is an integer greater than or equal to 1. Hint: The recursion step would use the relationship baseponent - base baseponent - 1 and the terminating condition occurs when exponent is equal to 1, because base' = basearrow_forward
- Create a recursive function and program for following equation using C++ f(5) = 5*(4/2)*3*(2/2)*1 f(7) = 7*(6/2)*5*(4/2)*3*(2/2)*1 You must create them using recursive approach, and provide an explanation in top of program using comment.arrow_forwardI am trying to add sentences but it’s showing error?arrow_forwardQ1: Please write a used-defined function in Matlab to monitor the balance of a bank account over years: Xi+1 = (1+ a) · x - b where the bank's annual interest rate a and the cash withdrawal amount b are defined as the global variables. Then write a main program to determine x1,X2, ,XN with x1=1000, a=0.05, b=200 until no money is left in the bank account after N years.arrow_forward
- A palindrome is a string that reads the same both forward and backward. For example, the string "madam" is a palindrome. Write a program that uses a recursive function to check whether a string is a palindrome. Your program must contain a value-returning recursive function that returns true if the string is a palindrome and false otherwise. Do not use any global variables; use the appropriate parameters.arrow_forward2. You are expected to write a recursive function called powy(base, exponent) that, when called, returns baseexponent As an example, powy( 6, 5 ) =6*6*6*6*6. Assume that exponent is an integer greater than or equal to 1. Hint: The recursion step would use the relationship baseexponent = base basexponent - 1 and the terminating condition occurs when exponent is equal to 1, because base' = basearrow_forwardprogram in C. Write a recursive function that takes a positive integer and returns the factorial of that integer. Attention, the function must be recursive, and its name must be "factorial".arrow_forward
- Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ). Particularly in c programarrow_forwardThis is a matlab problem: "Modify the selection sort function developed in this chapter so that it accepts a second optional argument, which may be either 'up' or 'down'. If the argu-ment is 'up', sort the data in ascending order. If the argument is 'down', sort the data in descending order. If the argument is missing, the default case is to sort the data in ascending order. (Be sure to handle the case of invalid arguments, and be sure to include the proper help information in your function.)" Here is the given function which need to be modified: function out = ssort(a)nvals = length(a);for ii = 1:nvals-1iptr = ii; for jj = ii+1:nvals if a(jj) < a(iptr) iptr = jj; end end if ii ~= iptr temp = a(ii); a(ii) = a(iptr); a(iptr) = temp; end end out = a;arrow_forwardPython only* Use recursive function*. Define concentricCircles with 4 parameters Use def to define concentricCircles with 4 parameters here is the specification for concentricCircles function: It draws a series of concentric circles, where the first parameter specifies the radius of the outermost circle, and the second parameter specifies the number of circles to draw. When viewed as nested rings, all rings should have the same thickness. The third and fourth parameters specify an outer color and an other color, respectively. The outer color is used for the outermost circle, and then every other circle in to the center alternates between that color and the other color. We will test both how many circles are drawn as well as whether the correct circles are drawn in the correct order. Hint: Each function call frame only needs to draw a single circle. Note that you must use the turtleBeads drawDot function to draw each circle Do not use any kind of loop Within the definition of…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