Page 1 of 1

Exercise 1: Implementing Recursive Binary Search Assume that you have a list of rames (all lower case) which are alphabe

Posted: Fri Apr 29, 2022 7:08 am
by answerhappygod
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 1
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 1 (49.23 KiB) Viewed 22 times
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 2
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 2 (49.23 KiB) Viewed 22 times
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 3
Exercise 1 Implementing Recursive Binary Search Assume That You Have A List Of Rames All Lower Case Which Are Alphabe 3 (34.69 KiB) Viewed 22 times
Exercise 1: Implementing Recursive Binary Search Assume that you have a list of rames (all lower case) which are alphabetically ordered ordered_namest'ayla', 'ben', 'can', 'david', 'eliz, fatna.gene', 'huseyin', 'kenal","ken', 'natt, 'zach 1 ython2.pdf You should implement a recursive function that checks whether a given input name is in this given input) list or not. If the name is in the list your implementation should return True, otherwise it should return false emirtager ini To have a good and fast running recursive implementation, you can use the Binary Search approach. In the Binary Search approach. you first compute the mid-point Index, and then you check whether or not the mid-point of the list is smaller (or greater). There are many online resources available on this topic and you are welcome to search on Google "Binary Search to get more info on Binary Search In our problem, we can use Binary Search approach to check if the element in the list located at the mid-point is alphabetically smaller than the given input name. If the mid-point element is smaller than we continue the search in the upper half of the list (mid+1 to end). If the mid-point clement is greater, we continue the search in the lower half (begining to mid-1). If the mid-point element is equal to name, we are done and return True. Regardless of which half of the list has been chosen, we repeat the previous step for it and keep repeating until we end up with an empty list. In that case we return False since we don't have the name in the list yea : ordered_nanes - l'ayla', 'ben', 'can', 'david', 'elix','fatmals 'gene", "huseyin', 'Kemal', 'en', 'Liam', 'attach' l'ayla', 'ben', 'can', 'david', 'eliz', 'fatna', 'gene', 'huseyin', 'kenal', 'ken', 'lian', 'natt, zach' Hali fata 1 r2020_Find
Exercise 1: Implementing Recursive Binary Search Assume that you have a list of rames (all lower case) which are alphabetically ordered ordered_namest'ayla', 'ben', 'can', 'david', 'eliz, fatna.gene', 'huseyin', 'kenal","ken', 'natt, 'zach 1 ython2.pdf You should implement a recursive function that checks whether a given input name is in this given input) list or not. If the name is in the list your implementation should return True, otherwise it should return false emirtager ini To have a good and fast running recursive implementation, you can use the Binary Search approach. In the Binary Search approach. you first compute the mid-point Index, and then you check whether or not the mid-point of the list is smaller (or greater). There are many online resources available on this topic and you are welcome to search on Google "Binary Search to get more info on Binary Search In our problem, we can use Binary Search approach to check if the element in the list located at the mid-point is alphabetically smaller than the given input name. If the mid-point element is smaller than we continue the search in the upper half of the list (mid+1 to end). If the mid-point clement is greater, we continue the search in the lower half (begining to mid-1). If the mid-point element is equal to name, we are done and return True. Regardless of which half of the list has been chosen, we repeat the previous step for it and keep repeating until we end up with an empty list. In that case we return False since we don't have the name in the list yea : ordered_nanes - l'ayla', 'ben', 'can', 'david', 'elix','fatmals 'gene", "huseyin', 'Kemal', 'en', 'Liam', 'attach' l'ayla', 'ben', 'can', 'david', 'eliz', 'fatna', 'gene', 'huseyin', 'kenal', 'ken', 'lian', 'natt, zach' Hali fata 1 r2020_Find
True Exercise 2: Implementing the same problem with iterative methods Implement the same (above-given) problem without using recursion. You will need to use the same input! (Use iterative methods.) Exercise 3: Comparison of both approaches In this part, we will study which one of those two implementations that you have already implemented runs faster. First compute the time required to run your implementation in Exercise 1 you can use the same code that you used in Exercise 1 here), and then compute the time required to run your implementation in Exercise 2. Compare the times required time values at the end in your code and print the fast running algorithm's name to the screen.