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
Need help with trying to rewrite the getFrequencyOf method using recursion. I will provide the original non recursive code also. Try not to use the toArray method and use node chain.
Non-recursive method
public int getFrequencyOf(T anEntry) {
int frequency = 0;
int counter = 0;
Node currentNode = firstNode;
while ((counter < numberOfEntries) && (currentNode != null)) {
if (anEntry.equals(currentNode.data)) {
frequency++;
}
counter++;
currentNode = currentNode.next;
}
return frequency;
}
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
- Write a recursive method called add(int n). This method adds the integers from 0 to some value n. For example, the call to add(4) would return 10 (4+3+2+1=10).arrow_forwardIN JAVA LANGUAGE FILL OUT THE FIND MAX FUNCTION public int findMax();/* Returns the largest element in the tree.* This method should call upon the recursive findMax_r() you write.** @return the largest element in the tree (an int value)* Example: findMax() will return 29 for the tree below** (28)* / \* (14) (29)* /* (1)*/ DO THIS BY CALLING A RECURSIVE FUNCTION SHOULD RETURN LARGEST ELEMENT IN A BST THANK YOU!!!!!arrow_forward//write a recursion function that will find the largest interger in the string. Can you give me some feedback on this function public int findMax(String s,intmax) { if (s.length()== 0) return 1; for (int = 0 ; i > s.length() ;i++) if (s.charAt (i) > s.charAt(i) )) returnmax; returnmax;arrow_forward
- Do not use static variables to implement recursive methods. USING JAVA What is the worst case runtime complexity of the following code in terms of n for (int pass = 1; pass <= n; pass++) { for (int index = 0; index < n; index++) { for (int count = 1; count < 10; count++) { // constant time operation } // end for } // end for } // endarrow_forwardPlease help solve the python problem, thank youarrow_forwardThe following recursive method called z is created. This method accepts two parameters: A string s, and an integer index The code in the method is: if (index == s.length()) return ""; <------ base case if(index % 2 == 0) return ""+ s.charAt(index) + z(s,index+1); <---- recursive call else return z(s,index+1); <----- recursive call What would be the output with the call: z("javajavajava",0);arrow_forward
- Consider the following function:int enigma(NodeInt32* node){if(node == NULL)return 0; elsereturn 1 + enigma(node->next);}(a)The enigma function is recursive.A. True B. Falsearrow_forwardConsider the following recursive method: public int recursiveMethod (int n) if (n <= 0) return 0; else int smaller = n - 1; return recursiveMethod (smaller) + n (n - 1); What is the integer return of a call recursiveMethod (5)? 36 39 40 44 Next Page Previous Pagearrow_forwardTry to do it asaparrow_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