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).
Requirements:
1. You may use one ArrayQueue, one ArrayStack, and one ChaniningHash TableMap.
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, 21.06.2019 22:30
Aprovides legal protection for something an individual has created
Answers: 1
question
Computers and Technology, 22.06.2019 06:00
Write a function that draws a pool ball. this function should take as parameters, the color, the number that should go on the pool ball, and the location of the center of the pool ball. the radius of the pool balls should be pool_ball_radius, and the font of the number should be pool_ball_font. the text of the pool ball font should be white. drawpoolball(color.orange, 5, 100, 100); drawpoolball(color.green, 6, 50, 200); drawpoolball(color.red, 3, 150, 350); drawpoolball(color.blue, 2, 250, 140); to center the numbers on the pool ball, you should use the getwidth() and getheight() methods. you are allowed to call these methods on your text object, such as txt.
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Pl i need the answer now ! which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 1
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, 03.07.2019 02:40
question
Mathematics, 03.07.2019 02:40
question
Mathematics, 03.07.2019 02:40
question
Mathematics, 03.07.2019 02:50
Questions on the website: 13722363