subject

We say that a sequence of numbers is a palindrome if it is read the same backward or forward. For example, the sequence: 6, 15, 6, 3, 47, 3, 6, 15, 6 is a palindrome.

Implement the following function:
def construct_a_longest_palindrome (numbers_bank)

When given numbers_bank, a non-empty list of integers, it will create and return a list containing a longest possible palindrome made only with numbers from numbers_bank

Notes:
1. The longest palindrome might NOT contain all of the numbers in the sequence.
2. If no multi-number palindromes can be constructed, the function may return just one number (as a single number, alone, is a palindrome).
3. If there is more than one possible longest palindrome, your function can return any one of them.

For example, if numbers_bank=(3, 47, 6, 6, 5, 6, 15, 3, 22, 1, 6, 15). Then the call construct_a_longest_palindrome (numbers_bank) could return: [6, 15, 6, 3, 47, 3, 6, 15, 6] (Which is a palindrome of length 9, and there is no palindrome made only with numbers from numbers_bank that is longer than 9).

Implementation requirements:

1. You may use one Array Queue, one ArrayStack, and one ChaniningHashTableMap.
2. Your function has to run in expected (average) linear time. That is, if numbers_bank is a list with n numbers, your function should run in O(n) average case.
3. Besides the queue, stack, hash table, and the list that is created and returned, you may use only constant additional space. That is, besides the queue, stack, hash table, and the returned list, you may use variables to store an integer, a double, etc. However, you may not use an additional data structure (such as another list, stack, queue, etc.) to store non-constant number of elements.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:40
Writing a modular program in visual c++. i am new to this and not sure what i am missing. i am getting the following error: baddate.cpp: in function ‘int main()’: baddate.cpp: 50: 3: error: ‘else’ without a previous ‘if’elsehere are the instructions and code: writing a modular program in c++in this lab, you add the input and output statements to a partially completed c++ program. when completed, the user should be able to enter a year, a month, and a day. the program then determines if the date is valid. valid years are those that are greater than 0, valid months include the values 1 through 12, and valid days include the values 1 through 31.notice that variables have been declared for you.write the simulated housekeeping() function that contains the prompts and input statements to retrieve a year, a month, and a day from the user.include the output statements in the simulated endofjob() function. the format of the output is as follows: month/day/year is a valid date.ormonth/day/year is an invalid date.execute the program entering the following date: month = 5, day = 32, year = 2014. record the output of this program.execute the program entering the following date: month = 9, day = 21, year = 2002. record the output of this /* program name: baddate.cppfunction: this program determines if a date entered by the user is valid.input: interactiveoutput: valid date is printed or user is alerted that an invalid date was entered*/#include bool validatedate(int, int, int); using namespace std; int main(){// declare variablesint year; int month; int day; const int min_year = 0, min_month = 1, max_month = 12, min_day = 1, max_day = 31; bool validdate = true; // this is the work of the housekeeping() method// get the year, then the month, then the daycout< < "enter the year"< > year; cout< < "enter the month"< > month; cout< < "enter the day"< > day; // this is the work of the detailloop() method// check to be sure date is validif(year < = min_year) // invalid yearvaliddate = false; else if (month < min_month || month > max_month) // invalid monthvaliddate = false; else if (day < min_day || day > max_day) // invalid dayvaliddate = false; // this is the work of the endofjob() method// test to see if date is valid and output date and whether it is valid or notif(validdate == true); {// output statementcout<
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
Helen is having a meeting with her colleagues in her company. they are working on the goals and objectives for the coming year. they want to ensure that these goals and objectives of the processes involved are properly evaluated. which system can helen and her colleagues apply to evaluate this? helen and her colleagues require a blank to evaluate the goals and objectives.
Answers: 2
You know the right answer?
We say that a sequence of numbers is a palindrome if it is read the same backward or forward. For ex...
Questions
question
Mathematics, 01.04.2020 06:42
question
Mathematics, 01.04.2020 06:42
question
Mathematics, 01.04.2020 06:42
question
Mathematics, 01.04.2020 06:42
question
English, 01.04.2020 06:43
Questions on the website: 13722363