Assignment #1
Pencil & paper: Weiss 1.7 (a)(b), 1.8(a)(b),
1.11(a)
Programming: The principal objective of this assignment is to
learn to use the Project facility of the Microsoft Visual Studio
and Visual C++. If you don't know how to use the Visual Studio (or equivalent
IDE), see the document on Compilers and IDEs referenced on the course Web
page.
The exercise is to write a program to solve the selection problem
using the first algorithm described in Section 1.1 of your text. You must
use the following architecture:
-
The driver program, called Selection.cpp. It reads the size n and
then n integers, storing them in an integer array, then finds the kth
largest number using Select(). It prints this number.
-
A function int Select (int n, int k, int a[ ] ) in file Select1.cpp,
with header file Select1.h. This implements the selection algorithm.
It returns the kth largest element.
-
A function BSort(int n, int a[ ] ) that sorts a[ ] using the bubble
sort algorithm.
You must create a Project with these three files:
-
Selection.cpp
-
select1.cpp (with Select() and BSort())
-
select1.h (with prototypes for Select() and BSort() )