Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Given a string str and number n, write a program in Javascript that recursively appends a copy of string str n times and returns the resulting string in a sentence explaining whether the resulting string has an odd or even amount of the passed in str.
"" explaining whether the resulting string has an odd or even amount of the passed in str. """
//-> "aaaaaaaaaaa has a(n) odd number of a's" EXAMPLE
function RecursiveCopy(str, n) {
if (n === 0) {
return "";
} else {
return RecursiveCopy(str, n - 1) + str;
}
}
where should i add the if statemnt for the odd or even numbers of str ? that code is not complet
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
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
- python3 Write a recursive function called is_palindrome(string) that takes a string parameter and checks if it is a palindrome ignoring the spaces, if any, and returns True/False. Sample output:>>> print(is_palindrome("never odd or even"))True>>> print(is_palindrome("step on no pets"))Truearrow_forwardConsider a network of streets laid out in a rectangular grid, In a northeast path from one point in the grid to another, one may walk only to the north (up) and to the east (right). Write a program that must use a recursive function to count the number of northeast paths from one point to another in a rectangular grid. Your program should prompt the user to input the numbers of points to the north and to east respectively, and then output the total number of paths. Notes: 1. Here is a file (timer.h download and timer.cpp download) which should be included in your program to measure time in Window or Unix (includes Mac OS and Linux) systems (use start() for the beginning of the algorithm, stop() for the ending, and show() for printing). 2. The computing times of this algorithm is very high, and the number of paths may be overflow, don't try input numbers even over 16. 3. Name your recursive function prototype as calcPath(int north, int east) to ease grading. 4. Paste your outputarrow_forwardplease code in python Write a recursive function to add a positive integer b to another number a, add(a, b), where only the unit 1 can be added, For example add(5, 9) will return 14. The pseudocode is: # Base case: if b is 1, you can just return a + 1 # General case: otherwise, return the sum of 1 and what is returned by adding a and b - 1.arrow_forward
- Java program not in pythonCreate a java program that will take a string ‘s’ and some integer ‘i’ from the user. Then proceed to write an algorithm that will check within the given string ‘s’, the most vowels found within any substring of ‘s’ of given length ‘i’. You may return an integer for the number of vowels found as the output, see examples below for further explanation • For example, if the user inputs the string; s = “iopuuugab” and an integer i = 3, then the output of “3” will be returned as the string “uuu” contains three vowels • Second example: if the user inputs string “gaspesie” and i =“3” then the output returned is “2”, the strings “esi” and “sie” both contain 2 vowels (note: the vowels do not need to be consecutive) • Third example: if the user inputs the string “Lynx” and integer = “4”, output would be “0” as there are no vowels present. • Fourth example: if the user inputs the string “hello” and integer “2”, output would be “1” as the combinations yield only one…arrow_forwardNeed help Writing a function, countVowels, that accepts a string as an argument. countVowels should return the number of vowels in that string. Use recursion. example countVowels('Four score and seven years'); // => 9arrow_forward
arrow_back_ios
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