Answered step by step
Verified Expert Solution
Question
1 Approved Answer
a) The input to a recursive binary search algorithm is target x and list L: (3, 4,7,10,14,17,20,24,27,30). The algorithm sets the variables low and
a) The input to a recursive binary search algorithm is target x and list L: (3, 4,7,10,14,17,20,24,27,30). The algorithm sets the variables low and high so that if x occurs in the list, then x is guaranteed to occur somewhere in locations low through high. Which assignment is guaranteed to maintain the correct properties of low and high for the following conditions? (5 points) i) ii) If x 22 If 30 x 5 b) The input list of binary search is: (3, 8, 12, 15, 19, 21, 25, 28, 31, 35) For the target value x = 19, give the values for variables low and high for each call to BinarySearch. Then give the final value return value. (5points) c) Give a recursive algorithm that takes as input a string s, removes all occurrences of the character 'a' and reverses the string. For example, on input "alabama", the algorithm should return "mbl". The function ISA(c) returns a Boolean value indicating whether the character c is 'a'. Your algorithm should not use an iterative loop. (10 Points)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
For the recursive binary search algorithm i If x22 low mid 1 high high ii If 30x5 low mid 1 high hig...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started