Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question
An incomplete program named w_pl java, which must include three methods, is provided.
You must implement two methods within the program as described below. The third method,
which is a main method, is already written in the program and you can use it to test your
program.
The two methods you mast inplement are:
• find method
• Signature:
public statie vold find(int[] a, int x)
• Behavior:
• Reccives an array of integers a and an integer x
• Performs a linear search on a for x.
• If x is in a, print the indexes of the aray slots where x is stored (there may be multiple
x's in a) on the screen.
• Ifx is not in a, print the message "x does not exist" on the screen.
Note that you should not use Java's built-in method. Your program must scan and search the
array.
• isPrifie method
• Signature:
public statie boolean isPrefix(String s1, String s2)
• Behavior:
• Receives two strings sl and s2. Assume that length of sl length of s2.
Returns true if sl is a prefix of s2 and returns false otherwise.
Note that you should not use Java's built-in method. Your program must determine whether
sl is a prefix of s2 by comparing characters, one at a time, in the two strings.
main method
The main method is already written in the given file and it is used to test above two methods.
After completing the above two methods, if you run your program, your output mast be:
5 is in a[0]
5 is in a[2]
5 is in a[7]
18 does not exist
abc is a prefix of abcde
abc is not a prefix of abdef
expand button
Transcribed Image Text:An incomplete program named w_pl java, which must include three methods, is provided. You must implement two methods within the program as described below. The third method, which is a main method, is already written in the program and you can use it to test your program. The two methods you mast inplement are: • find method • Signature: public statie vold find(int[] a, int x) • Behavior: • Reccives an array of integers a and an integer x • Performs a linear search on a for x. • If x is in a, print the indexes of the aray slots where x is stored (there may be multiple x's in a) on the screen. • Ifx is not in a, print the message "x does not exist" on the screen. Note that you should not use Java's built-in method. Your program must scan and search the array. • isPrifie method • Signature: public statie boolean isPrefix(String s1, String s2) • Behavior: • Receives two strings sl and s2. Assume that length of sl length of s2. Returns true if sl is a prefix of s2 and returns false otherwise. Note that you should not use Java's built-in method. Your program must determine whether sl is a prefix of s2 by comparing characters, one at a time, in the two strings. main method The main method is already written in the given file and it is used to test above two methods. After completing the above two methods, if you run your program, your output mast be: 5 is in a[0] 5 is in a[2] 5 is in a[7] 18 does not exist abc is a prefix of abcde abc is not a prefix of abdef
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
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
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education