100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Computation thinking Homework Thinking ahead 2 answers $8.64
Add to cart

Other

Computation thinking Homework Thinking ahead 2 answers

 257 views  0 purchase
  • Course
  • Institution
  • Book

OCR A LEVEL COMPUTER SCIENCE Computational thinking Homework Thinking ahead 2 answers.

Preview 1 out of 2  pages

  • December 1, 2021
  • 2
  • 2021/2022
  • Other
  • Unknown
avatar-seller
Homework 2 Thinking ahead
Unit 10 Computational thinking

Homework 2 Thinking ahead Answers
1. (a) Using the headings given, specify the inputs, outputs and precondition for the following
problem:

Given a list of integers, return a list containing every number divisible by 7. [4]

Name: sevens

Inputs: A list of integers listInt = (i1, i2, i3,… in)

Outputs: A list of integers list7 = (i1, i2, i3,… im)

Precondition: length of listInt >0

(b) Write a pseudocode algorithm for this function, and a main program which calls the
function and outputs the resulting list. [4]

function sevens(listInt):
n = len(listInt)
list7 = []
for i = 1 to n-1
if listInt[i] mod 7 == 0
list7.append (listInt[i])
endif
next i
return list7
endfunction

listInt = [7,33,35,42,49,50,57]
print("List of elements divisible by 7:", sevens(listInt))

(c) Give two different lists that you could use to test two aspects of this program, and the
expected output. [4]

list1 = [2, 6, 46, 90, 0] Expected output: list7 =[0]

list2 = [2, 6, 46, 90] Expected output: []

list2 = [7, 33, 35, 42, 49, 50, 57] Expected output: list7 = [7, 35,42,49]


2. (a) Explain what is meant by caching, and give an example of when it might be used. [3]
Caching is the temporary storage of programs and data which have recently been
used. This is frequently used to store web pages / instructions/data which the user
/program may need again within a short time.
(b) Explain one benefit and one drawback of caching. [2]
Improves performance/saves bandwidth if the same pages do not have to be reloaded
several times.
Drawback: May retrieve a “stale” copy of a web page if the page has been updated
bysince it was cached.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller STUVIA1233455. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.64. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

53068 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.64
  • (0)
Add to cart
Added