Jump to content

How to write pseudocode for these questions? Homework help!


katetseneo

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

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.