Question: Problem 5. In class we implemented a function sort_in_place that takes a list of numbers and sorts them using a bubble sort method. It returns
Problem 5. In class we implemented a function sort_in_place that takes a list of numbers and sorts them using a bubble sort method. It returns the original list in sorted order and does not use any other lists for the intermediate computations. Write a function to sort (in place) the list of numbers as follows: first positive numbers in increasing order and then negative numbers in increasing order.
Example: input: x = [2, 6, -6, -3, 1, 19]
output: x = [1, 2, 19, -6, -3]
You can define auxiliary functions if you need but you are not allowed to use lists (or any container structure like tuples, sets, dictionaries) as temporary variable. Imagine that the list is just too large and there is not enough space for another list. You may, of course use temporary variables but not containers.
Problem 6. A DNA sequence contains 4 nucleotide bases: A, C, G and T. For example, x = TTAC. One sequence can be complementary to another sequence, meaning that they have the base on each position in the complementary (A to T, C to G) and in the reverse order. For example, the complementary sequence to TTAC is GTAA.
Write a function complementary(x, y) that take as input two DNA sequences (encoded as strings, same length) and returns True if these sequences are complementary.
For both problems 5 and 6 you may define additional functions if needed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
