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
Question
: Given a sorted array of strings that is interspersed with empty strings, write a
method to find the location of a given string.
EXAMPLE
Input: ball, {"at",
""}
Output: 4
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 4 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
- Binary Search of Strings1. Write a version of the selection sort algorithm presented in the unit, which is usedto search a list of strings.2. Write a version of the binary search algorithm presented in the unit, which isused to search a list of strings. (Use the selection sort that you designed aboveto sort the list of strings.)3. Create a test program that primes the list with a set of strings, sorts the list, andthen prompts the user to enter a search string. Your program should then searchthe list using your binary search algorithm to determine if the string is in the list.Allow the user to continue to search for strings until they choose to exit theprogramarrow_forwardCount the number of elements in a that have values between 10 and 20 inclusive. int count=0; for(int i=0;i<10,i++) { if(a[i]>=10 && a[i]<=20) { count=count+1; } System.out.println(“count… = “+ count); }arrow_forwardWrite code in assembly language Question 1: Construct a program using 2D array. Define a list of strings in the 2D arrays, the list should be only a string. Get a string from a user as input Search the user's string in the list of strings. If string is found print the string, and a message "String is Found". If string is not found print only a message "String is Not Found".arrow_forward
- Write a loop that counts how many elements in an array are equal to zero. arrays.cpp 1 #include // sizet 2 int countZeros (const int values[], size_t size) { int count = 0; 3 4 for (int i; i using namespace std; 3 2 4 int countZeros(const int values[], size_t size); 5 int main() { int a[] = {1, 2, 0, 3}; cout <« countZeros (a, 4) <« endl; cout « "Expected: 1" « endl; 6 7 8 9 10 11 int b[] = {0, 2, 0, 3}; cout <« countZeros (b, 4) <« endl; cout « "Expected: 2" « endl; 12 13 14 15 int cl] -{1, 0, θ, 0, 0 ; cout <« countZeros (c, 5) <« endl; cout « "Expected: 4" « endl; 16 17 18 19 } CodeCheck Reset Testers Running Tester.cpp pass fail fail 1 Expected: 1 Expected: 2 Expected: 4 Score 1/3arrow_forward1. Given a string of at least 3 characters as input, if the length of the string is odd return the character in the middle as a string. If the string is even return the two characters at the midpoint. public class Class1 { public static String midString(String str) { //Enter code here } } ----------- 2. Given an array of integers return the sum of the values stored in the first and last index of the array. The array will have at least 2 elements in it public class Class1 { public static int endSum(int[] values) { //Enter code here } } ----------- 3. The method takes a string as a parameter. The method prints treat if the string is candy or chocolate (of any case, such as CaNdY) Otherwise print trick import java.util.Scanner; public class Class1 { public static void trickOrTreat(String str) { //Enter code here } public static void main(String[] args) { Scanner s = new Scanner(System.in); trickOrTreat(s.nextLine()); } }arrow_forwardWrite a while loop to read positive integers from input until a non-positive integer is read. For each positive integer read before the non-positive integer, add the positive integer plus five to vector vect1. Ex: If the input is 9 1 2 8 -999, then the output is: 14 6 7 13 Note: Positive integers are greater than 0. 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 7 8 9 10 11 12 13 14 15 16 17 } vector vect1; int value; int i; V* Your code goes here */ for (i = 0; i < vect1.size(); ++i) { cout << vect1.at (i) << endl; } return 0; Iarrow_forward
- Write code in assembly language Question 1: Construct a program using 2D array. Define a list of strings in the 2D arrays, the list should be only a string. Get a string from a user as input Search the user's string in the list of strings. If string is found print the string, and a message "String is Found". If string is not found print only a message "String is Not Found".arrow_forwardQuestion in image Please explain the algorithm with the answer. Python programmingarrow_forwardMatich the following statements with the correct data structure by clicking on the drop down arrow and selecting the correct choice.. You need to store a list of elements and the number of elements in the program is fixed. If most of operations on a list involve retrieving an element at a given index. You have to add or delete the elements at the beginning of a list. Linked List ArrayList Arrayarrow_forward
- Write a version of the binary search algorithm that can be used to search a list of strings. (Use the selection sort that you designed to sort the list.)arrow_forwarddef findOccurrences(s, ch): lst = [] for i in range(0, len(s)): if a==s[i]: lst.append(i) return lst Use the code above instead of enumerate in the code posted below. n=int(input("Number of rounds of Hangman to be played:")) for i in range(0,n): word = input("welcome!") guesses = '' turns = int(input("Enter the number of failed attempts allowed:")) def hangman(word): secrete_word = "-" * len(word) print(" the secrete word " + secrete_word) user_input = input("Guess a letter: ") if user_input in word: occurences = findOccurrences(word, user_input) for index in occurences: secrete_word = secrete_word[:index] + user_input + secrete_word[index + 1:] print(secrete_word) else: user_input = input("Sorry that letter was not found, please try again: ") def findOccurrences(s, ch): return [i for i, letter in enumerate(s) if letter == ch] *** enumerate not discussed in…arrow_forwardJava Task Write a for loop that prints the characters stored in a String object backward. The String is entered by the user. ***Use ch = phrase.charAt(i); to get the character that is in index i of the String phrase.**** For example The user enters “Good morning!” The printout should be “!gninrom dooG”.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