Anne
Dawson: CSCI120A_LAB10_FA04.htm
Last
updated: Sunday 14th November 2004, 9:30 PT
This
document is subject to change without notice.
Please
report any errors or omissions in this document:
adawson@coquitlamcollege.com
Special instructions:
For this assignment you may work in teams of 2, or alone. This lab is due at the end of the lab
session.
Fall 2004
Lab
Assignment 10
Step 1
Study the Selection Sort algorithm from the following web page:
http://www.coquitlamcollege.com/adawson/Python_SortingComplexity.htm
You are to write a program which performs a selection sort on a
list of 10 (unique) random integers.
Your program must count the number of comparisons and swaps (i.e.
exchanges) of list elements, and at after completing the sort, displays the
original list, the sorted list, and the numbers of comparisons and swaps.
Note: you do not type in the code of your program until Step 3.
Step 2
From the selection sort algorithm, write the pseudocode for your
program.
Step 3
Using your
pseudocode as a guide, implement the selection sort program.
Your program
should start with a comment block that contains the following information:
# File: lab10.py
# Purpose: Selection sort on a list of unique random
numbers
# Programmer: [your name]
# Partner: [your partner's name]
# Course: CSCI120A
# Date: Wednesday 24th November 2004
# List size: Comparisons:
Swaps:
# List size: Comparisons:
Swaps:
# List size: Comparisons:
Swaps:
# List size: Comparisons: Swaps:
# List size: Comparisons:
Swaps:
# etc.
Step 4
Since your
program is self-testing, you need not supply any test data. However, you should amend and rerun
your program with lists of various sizes and make a note of the number of
comparisons and swaps for each list size.
Type your results in comments at the top of your code. What is the maximum size of list you
can sort?
Step 5
At the end of
the class, save your program file (lab10.py) to your folder on the network in:
CSCI120A\Week12\Lab10
Program points
will be based on the following marking scheme:
Marking
Scheme: CSCI120A - Lab 10 -
Selection Sort Program
Student
name(s):
|
Category |
Points |
Description |
|
Pseudocode |
15 |
As per algorithm |
|
Comments |
10 |
The program is commented appropriately. |
|
Style |
15 |
The source code should use meaningful variable
names (identifiers) and be easy to follow. |
|
Output |
10 |
Screen prompts and outputs should be
user-friendly. |
|
Correctness |
15 |
The program should output correct results. |
|
Completeness |
15 |
The program should be complete. |
|
Analysis |
20 |
Comments in the code explain how the code was analysed
according to list size for comparisons and swaps. |