Question: 1- Write a pseudo-code description for a method of finding the smallest and largest numbers in an array of integers. Compare your pseudo-code to a

1- Write a pseudo-code description for a method of finding the smallest and largest numbers in an array of integers. Compare your pseudo-code to a Java method that would do the same thing.

2- Write a short Java program that outputs all of the possible strings formed using each of the characters c, a, t, d, o, and g exactly once.

3- Draw the recursion trace for the execution of the method PuzzleSolve(3, S, U) (Code Fragment 5.11), where S is empty and U = {a,b,c,d}.

4- Describe a fast recursive algorithm for reversing a singly linked list L, so that the ordering of the nodes becomes opposite to what it was before.

5- Describe a recursive algorithm for solving the Towers of Hanoi puzzle for an arbitrary n (see Creativity Exercise C-5.16 for more details).

6- Give a pseudo-code description for the O(n)-time algorithm for computing the power function, p(x,n). Draw the recursion trace of this algorithm to compute p(2,5).

7- Given a set A = {a1, a2, , an} of n integers, use pseudo-code to describe an efficient method of computing each of the partial sums sk = a1 + a2 + + ak for k = 1,2,,n. What is the running time for this method?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!