Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please help me to complete it using python programming language Question 2 (Total 20 marks): Sorting and Recursion a) (5 marks). If you had a
please help me to complete it using python programming language
Question 2 (Total 20 marks): Sorting and Recursion a) (5 marks). If you had a collection of items that needed to be sorted once every 10 seconds and new random items were being added every second, which sorting algorithm would you recommend and why? Justify your answer by discussing your chosen algorithm. b) (3 marks). A pivot is a special value that is chosen to split a data set into two sub- sets. Why is choosing the right pivot important when sorting data using a quicksort? Does pivot selection have an impact on time complexity and memory complexity? c) (3 marks). Give an example of a program where the stability of a sorting algorithm will be important and explain why sorting stability would effect that program. d) (5 marks). Rewrite the following iterative algorithm as a recursive one that does not require a Stack data structure (hint: recursive function calls operate like a stack). Python #Algorithm def reverse_fruits(fruits): stack = DSAStack() for fruit in fruits: stack.append(fruit) while len(stack) > 0: print(stack.pop()) #test code fruits = DSALinkedList() fruits.insertLast('banana') fruits.insertLast('apple') fruits.insertLast('pear') reverse_fruits(fruits) e) (4 marks) is the algorithm more efficient as a recursive function? Why/Why not? Are there even more efficient ways to achieve the same results and if so, howStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started