Jump to content

How to write pseudocode for these questions? Homework help!

Featured Replies

How do I write pseudocode where input is a table and output is a list for this example:
Please see the table attached.
It's a table where the first column are students in a classroom and they are ranked based on their performance from the exams.

 

A. I want to write a pseudocode algorithm to determine the rank changes after the exam. Input is the table with n rows, and 5 columns. So far I have this: M[n-1,4]
The output should be a list with the differences in ranks for each student. For example [2,3, -4, 0, -7]

B
How do I write a pseudocode algorithm to determine which student scored at least 90% of the questions they completed. Output should produce a list eg.[0,4]

Thanks for your help.

HigITvK.jpg

You should have probably put this into Homework help section rather than this forum. I also see you haven't made much of a progress in terms of getting the task done, so I can give you some pointers, but can't really do all the job for you.

 

First, you need to read data from each column of the input table and assign it into arrays with n-1 elements, where n is the number of rows in your input data. Since the first element of each column is column name which we don't need, you should start reading your data from the second row and as a result the number of your array elements will be n-1.

 

Then, using some loop like for or while perform calculations and assign result to another array. For example, for task A your for loop will be something like

for(i=1, i < n, i++)
    
    rank_change[i] = rank_after[i] - rank_before[i]

    print (student_name[i], rank_change[i])

For your second task you'll need to add an if operator inside your loop so that it checks the condition questions_correct/questions_completed >= 0.9 and if condition is satisfied prints student's name.

Edited by pavelcherepan

Archived

This topic is now archived and is closed to further replies.

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.