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, 22.06.2019 23:30
Select all that apply. which of the following are proofreading options included in microsoft word? spell check find replace grammar check formatting check
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
[java] create an application called registrar that has the following classes: a. a student class that minimally stores the following data fields for a student: - name - student id number - number of credits - total grade points earned and this class should also be provides the following methods: - a constructor that initializes the name and id fields - a method that returns the student name field - a method that returns the student id field - methods to set and retrieve the total number of credits - methods to set and retrieve the total number of grade points earned. - a method that returns the gpa (grade points divided by credits) b. an instructor class that minimally stores the following data fields for an instructor: - name - faculty id number - department the following methods should be provided: - a constructor that initializes the name and id fields - methods to set and retrieve the instructor’s department. c. a course class that minimally stores the following data for a course: - name of the course- course registration code- maximum number of 35 students- instructor- number of students- students registered in the course (an array)the following methods should also be provided: - a constructor that initializes the name, registration code, and maximum number of students- methods to set and retrieve the instructor- a method to search for a student in the course; the search should be based on an id number.- a method to add a student to the course. if the course is hill, then an exception with an appropriate message should be raised (try creating your own exception class for this). also, be sure that the student is not already registered in the course. the list of students should be in the order that they registered.- a method to remove a student from the course. if the student is not found, then an exception with an appropriate message should be raised (use the same exception class mentioned a method that will allow course objects to be output to a file using object serialization- a method that will allow course objects to be read in from a file created with object serializationyou will note that the student and instructor classes described above have some commonality. create aperson class that captures this commonality and uses it as a base class for student and instructor. this class should be responsible for the name and id fields and also provide atostring method that returns a string of the form name, id. this will be the inheritedtostring method for the student and instructor classes.1. draw a uml diagram for diss application.2. implement the previous classes in java. write a main program that can serve as a test class that tests all of the methods created and demonstrates that they are working
Answers: 2
question
Computers and Technology, 23.06.2019 12:00
3. when you right-click a linked spreadsheet object, what commands do you choose to activate the excel features? a. linked worksheet object > edit b. edit data > edit data c. linked spreadsheet > edit d. object > edit data
Answers: 2
question
Computers and Technology, 24.06.2019 08:30
Intellectual property rights are exclusive rights that protect both the created and the creation. ipr offers exclusively what benefits to the person or people covered by it
Answers: 3
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, 10.04.2020 03:36
question
History, 10.04.2020 03:36
question
Mathematics, 10.04.2020 03:37
question
Mathematics, 10.04.2020 03:37
question
Mathematics, 10.04.2020 03:37
Questions on the website: 13722362