Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[ 2 0 % ] Design a recursive algorithm to solve each of the following problems and analyse the worst - case time complexity of

[20%] Design a recursive algorithm to solve each of the following problems and
analyse the worst-case time complexity of your algorithm. [Non-recursive
algorithms will score 0 marks.]
(a) Given an array of numbers A[1..n], find the average of all numbers in the
array. For example, if the given array A is 1.5,2,3.5,-0.5,6.5, the output
of the algorithm should be 2.6.
(b) Given an array of integers A[1..n], reverse the entries in the array. You are
only allowed to use constant amount of extra storage (e.g. if you use
another array of n entries in your algorithm, you score 0 marks). For
example, if the given array A is 10,-2,3,4,5, the output of the algorithm
should be 5,4,3,-2,10.
(b) Given an integer n(0), output all binary strings of length 2n such that
the sum of the first n bits = the sum of the second n bits. For example, if n
=2, then the algorithm should output:
0000,0101,0110,1001,1010,1111
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

How To Make A Database In Historical Studies

Authors: Tiago Luis Gil

1st Edition

3030782409, 978-3030782405

More Books

Students also viewed these Databases questions