1

I am having a hard time with writing pseudocode.

Question: Consider an array A[1..n], where n>= 3. Write an algorithm (using pseudocode) that computes the minimum value among all the elements with index a multiple of 3 (e.g. A[3], A[6], A[9], …so on).

for i=1 to A.length
    while n>= 3
       A[n] = A[n*i]

I took an attempt at writing the code. Can somebody provide some insight on what I have written.

5
  • Which part is unclear? Commented Sep 23, 2013 at 20:35
  • 1
    The thing about pseudocode (or how I use pseudocode) is that everything goes. You don't worry too much about syntax, you just try to bring an idea across. This question is not about pseudocode, it's about having no clue how to solve the problem. Commented Sep 23, 2013 at 20:37
  • So basically as long as the idea is correct there can be many ways to write pseudocode? Commented Sep 23, 2013 at 20:54
  • 1
    Yes. The point of pseudocode is that you no longer need to worry about a computer understanding what you mean; it's now a person, and people are much better at understanding ambiguity. Commented Sep 23, 2013 at 21:08
  • Hmm ok, that makes more sense. I was thinking that there was one and only one way of solving it. Tthank you Commented Sep 23, 2013 at 21:14

1 Answer 1

1

It should look like this

min = A[3]    
for i=3 to A.length
    if min > A[i]
       min = A[i]
    i += 3
Sign up to request clarification or add additional context in comments.

1 Comment

It should be if min > A[i].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.