Hello can you help me with this problem?
the method liste.sort() that I use just crash my code after a few recursions.
#Recall in Worked Example 5.2.5 that we showed you the
code
#for two versions of binary_search: one using recursion, one
#using loops. For this problem, use the recursive one.
#
#In this problem, we want to implement a new version of
#binary_search, called binary_search_year. binary_search_year
#will take in two parameters: a list of instances of Date,
#and a year as an integer. It will return True if any date
#in the list occurred within that year, False if not.
#
#For example, imagine if listOfDates had three instances of
#date: one for January 1st 2016, one for January 1st 2017,
#and one for January 1st 2018. Then:
#
# binary_search_year(listOfDates, 2016) -> True
# binary_search_year(listOfDates, 2015) -> False
#
#You should not assume that the list is pre-sorted, but you
#should know that the sort() method works on lists of dates.
#
#Instances of the Date class have three attributes: year,
#month, and day. You can access them directly, you don't
#have to use getters (e.g. myDate.month will access the
#month of myDate).
#
#You may copy the code from Worked Example 5.2.5 and modify
#it instead of starting from scratch. You must implement
#binary_search_year recursively.
#
#Don't move this line:
from datetime import date
#Write your code here!
#Below are some lines of code that will test your function.
#You can change the value of the variable(s) to test your
#function with different inputs.
#
#If your function works correctly, this will originally
#print: True, then False
listOfDates = [date(2016, 11, 26), date(2014, 11, 29),
date(2008, 11, 29), date(2000, 11, 25),
date(1999, 11, 27), date(1998, 11, 28),
date(1990, 12, 1), date(1989, 12, 2),
date(1985, 11, 30)]
print(binary_search_year(listOfDates, 2016))
print(binary_search_year(listOfDates, 2007))
from datetime import date
#Write your code here!
def binary_search_year(searchList, searchTerm):
searchList.sort()
if len(searchList) == 0:
return False
middle = len(searchList) // 2
if searchList[middle].year ==
searchTerm:
return True
elif searchTerm <
searchList[middle].year:
return
binary_search_year(searchList[:middle], searchTerm)
else:
return
binary_search_year(searchList[middle + 1:], searchTerm)
#Below are some lines of code that will test your
function.
#You can change the value of the variable(s) to test your
#function with different inputs.
#
#If your function works correctly, this will originally
#print: True, then False
listOfDates = [date(2016, 11, 26), date(2014, 11, 29),
date(2008, 11, 29), date(2000, 11, 25),
date(1999, 11, 27), date(1998, 11, 28),
date(1990, 12, 1), date(1989, 12, 2),
date(1985, 11, 30)]
print(binary_search_year(listOfDates, 2016))
print(binary_search_year(listOfDates, 2007))
Hello can you help me with this problem? the method liste.sort() that I use just crash...
Python 3 Problem: I hope you can help with this please answer the problem using python 3. Thanks! Code the program below . The program must contain and use a main function that is called inside of: If __name__ == “__main__”: Create the abstract base class Vehicle with the following attributes: Variables Methods Manufacturer Model Wheels TypeOfVehicle Seats printDetails() - ABC checkInfo(**kwargs) The methods with ABC next to them should be abstracted and overloaded in the child class Create three...
please help me write the python code for this problem
Problem 2: Restaurant Tipping IAE IOL (Fall 2015) HR . Problem 2 After many years, you have developed a system for determining exactly how much to tip when eating out at a restaurant: de tip mount bill, good service ADD YOUR COOE MERE return -1. CHANGE OR REMOVE THIS LINE • If the final bill is $30.00 or less, you will leave a tip of exactly $5.00 (regardless of the...
Hi, can you please help me with this question. I need it to be in C++. Please without struct and files. Only with functions bc I didnt learn struct and files yet. Many computer applications, such as Microsoft Excel, can compare date values that occur after January 1, 1900. For example, these programs can determine if 06/06/99 is less than (comes before) 11/01/00. They use January 1, 1900 as their reference point. This becomes day 1. All other dates are...
General Requirements: • You should create your programs with good programming style and form using proper blank spaces, indentation and braces to make your code easy to read and understand; • You should create identifiers with sensible names; • You should make comments to describe your code segments where they are necessary for readers to understand what your code intends to achieve. • Logical structures and statements are properly used for specific purposes. Objectives This assignment requires you to write...
PYTHON I need help with this Python problem,
please follow all the rules! Please help! THANK YOU!
Bonus Question Implement an efficient algorithm (Python code) for finding the 11th largest element in a list of size n. Assume that n will be greater than 11. det find 11th largest numberlissy Given, lissy, a list of n integers, the above function will return the 11th largest integer from lissy You can assume that length of lissy will be greater than 11....
Code is in C#
Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...
Hello! I'm posting this program that is partially completed if someone can help me out, I will give you a good rating! Thanks, // You are given a partially completed program that creates a list of employees, like employees' record. // Each record has this information: employee's name, supervisors's name, department of the employee, room number. // The struct 'employeeRecord' holds information of one employee. Department is enum type. // An array of structs called 'list' is made to hold...
PYTHON please help! im stuck on this homework
question, THANK YOU! please follow the rules!
Give a recursive python implementation of the following function: def check_Decreasing_Order(lissy): Given lissy, a python list of integers, the above function will return True if lissy is sorted in decreasing order, otherwise it will return false. For example, print(check_Decreasing Order([100,50,8, -2])) True print(check_Decreasing_Order([108,50,8,2,35])) False Implementation Requirements: 1. Your implementation must be recursive. 2. If you need more parameters, you may define new functions or helper...
[3] In python, please help me write the functions needed for this problem: Another Way to do Parentheses: For this problem, you will be given a string that contains parentheses, brackets, and curly braces ( (, ), [, ], {,} ) and other characters. As a human you are given a string of any characters, determine if the parentheses, brackets, and braces match. (No trailing or leading parentheses). The function called on an empty string will return True. Parentheses must...
In Java You are to write a program that determines the day of the week for New Year's Day in the year 3000. To do this, you must create your own date class (MyDate) and use the following interface and main program: /** Interface for Date objects to be used by the Year3000 driver program. @author Jon Sorenson */ public interface DateInterface { /** @return the day of the month (1-31) */ public int getDay(); /** @return the day of...