cs102 lab5
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/labs/l5.html
-
For this lab you must submit all source code (python
files), and, if applicable, the result(s) of running the program on (a few)
test cases. This should be sent in via BLACKBOARD (not directly by email).
The source code must
be well presented (indenting, spaces, reasonable variable/function names,
etc.) and must include comments (as a rough guideline - aim to have nearly as
many comments as lines of code). Any questions asked should be answered by
typing into a plain text (.txt) file which should also
be uploaded via blackboard.
-
This material should be uploaded
before
the deadline of 5pm
Friday February 25th, 2011. You will lose 20% for each day
(or part of day) the lab is late.
-
Plagiarism (the unattributed copying of work from other sources
(internet, fellow students,....)) will not be tolerated. Please see
http://www.nuigalway.ie/engineering/documents/plagiarism_guide_students
_v4.pdf. You risk getting zero for your lab if it is found to be
plagiarized.
-
Adapt (change) the binary search program
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/progs/
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/progs/binsR.py
so that if there are multiple occurrences of a particular data value,
it will find all these occurrences. So, your program (which must be
recursive) will print out
-
The position of each occurrence.
-
The total number of occurrences.
Test your program on the (ordered) list of numbers at
http://www.maths.nuigalway.ie/~gettrick/teach/cs102/list.txt,
by searching this list for the numbers 42, 211, 332 and 493.
-
Write a recursive program that calculates, given as input a
positive integer n, the sum of all the numbers up to (and including)
n.
©
NUI, Galway