Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

FAST Part 5. [10 marks] Given a file where each line is a single (32-bit) non-negative integer, read in the lines of the file one

FAST
image text in transcribed
Part 5. [10 marks] Given a file where each line is a single (32-bit) non-negative integer, read in the lines of the file one at a time; create a new list out of the original by reading in groups of i lines for i=1,2,3,4, and reversing the order of each group of lines (but the groups themselves stay in the original order.) From this new list, consider the last group of values: use these as circular indices to access and sum modulo 240223 the elements of the new list. Output this sum. If the file is empty, output 0 . For example, if the input is 10 20 30 40 50 60 2 3 15 then the modified list is 1030206050401532 Thus n=9 and the last group is 15,3,2 so we will sum the elements at indices (15%9=6, 3%9=3, and 2%9=2 for a final sum of (15+60+20)%240223=95. For more examples, see the tests in the tests/ directory that have the form lab2-p5-x-in.txt for the input, and the matching lab2-p5-X-out.txt for the expected output

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

Transactions On Large Scale Data And Knowledge Centered Systems Xxxviii Special Issue On Database And Expert Systems Applications Lncs 11250

Authors: Abdelkader Hameurlain ,Roland Wagner ,Sven Hartmann ,Hui Ma

1st Edition

3662583836, 978-3662583838

More Books

Students also viewed these Databases questions

Question

(3) f YZ|x(y, z). Does the value depend on x? Pg45

Answered: 1 week ago