Embed presentation
Download to read offline
![Q1. Write a python function that get's a list as an input and the median of its values. Median is the
middle number when you sort the list. If the list has even number of elements, median will be the
average of the two numbers in the middle Example: median of [5,4,8,2,9,1,3] is 4 and median of [4
,5,2,1,8,9] is (4+5)/2 or 4.5 . You can use python's own sorting algorithm. def find median (1st):
Q2. Write a python function that gets n and returns the nth value in the Pell sequence. Pell
sequence is defined by P(n)=2P(n1)+P(n2) while P(0)=0 and P(1)=1. Use your code to generate
and provide the first 10 values of Pell sequence. def pell (n): Section 2 - function Analysis ( 30
marks) Q3. Run an analysis of the function developed in Q2 and find its T(n) and big O
perforamance. Is finding the nth element of Pell sequence faster than bubble sort? Is it faster than
finding the nth element of the Fibonacci series?](https://image.slidesharecdn.com/q1writeapythonfunctionthatgetsalistasaninputan-230320111459-094c8a61/85/Q1-Write-a-python-function-that-gets-a-list-as-an-input-an-pdf-1-320.jpg)
The document outlines tasks to write Python functions: one for calculating the median of a list, and another for generating the nth value of the Pell sequence. It also requests a function analysis examining the performance of the Pell sequence function compared to bubble sort and Fibonacci series. The content is geared towards assessing algorithm efficiency and implementation in Python.
![Q1. Write a python function that get's a list as an input and the median of its values. Median is the
middle number when you sort the list. If the list has even number of elements, median will be the
average of the two numbers in the middle Example: median of [5,4,8,2,9,1,3] is 4 and median of [4
,5,2,1,8,9] is (4+5)/2 or 4.5 . You can use python's own sorting algorithm. def find median (1st):
Q2. Write a python function that gets n and returns the nth value in the Pell sequence. Pell
sequence is defined by P(n)=2P(n1)+P(n2) while P(0)=0 and P(1)=1. Use your code to generate
and provide the first 10 values of Pell sequence. def pell (n): Section 2 - function Analysis ( 30
marks) Q3. Run an analysis of the function developed in Q2 and find its T(n) and big O
perforamance. Is finding the nth element of Pell sequence faster than bubble sort? Is it faster than
finding the nth element of the Fibonacci series?](https://image.slidesharecdn.com/q1writeapythonfunctionthatgetsalistasaninputan-230320111459-094c8a61/85/Q1-Write-a-python-function-that-gets-a-list-as-an-input-an-pdf-1-320.jpg)