Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Follow the guidelines for writing pseudocode: C/Java/Python instructions are fine. But do not write object-oriented additions. Do not declare or use any class. Declare only

Follow the guidelines for writing pseudocode:

  1. C/Java/Python instructions are fine. But do not write object-oriented additions. Do not declare or use any class. Declare only procedures (if necessary) and explain in words what each procedure does, and what is the use of each parameter.

  2. One instruction per line

  3. from C, do not use !, :, ?, or double assignment. As a general rule, this is not the place to be too smart

  4. Match the brackets with a horizontal line

  5. Number the lines of pseudocode

  6. Write down if your array is indexed 0...n1 or 1...n.

  7. It can help the grader if you describe in English the idea of the algorithm, or examples of instances on which you run your algorithm.image text in transcribed

Problem 2 (40 pts) We are given as input two arrays A and B (with range 1, 2, ..., n) and we must output an array C defined by C[k] = (=1 A[j]). (51B[j]). For example, if the input A [1, 2, 2, 33, 15) and B (10,7,8, 1, 11], then C = [10,51, 125,988, 1961). Write pseudocode for an algorithm to accomplish this task with worst- case running time of O(n). You do not have to argue correctness (but, obviously, your method must be correct), but must justify the running time. Problem 2 (40 pts) We are given as input two arrays A and B (with range 1, 2, ..., n) and we must output an array C defined by C[k] = (=1 A[j]). (51B[j]). For example, if the input A [1, 2, 2, 33, 15) and B (10,7,8, 1, 11], then C = [10,51, 125,988, 1961). Write pseudocode for an algorithm to accomplish this task with worst- case running time of O(n). You do not have to argue correctness (but, obviously, your method must be correct), but must justify the running time

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

Step: 3

blur-text-image

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

Students also viewed these Databases questions