Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Mastery Exam Questions - Computer Program for Science | CSC 107, Exams of Computer Science

Material Type: Exam; Professor: Hertz; Class: Computer Program for Science; Subject: Computer Science; University: Canisius College; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 08/19/2009

koofers-user-wtu
koofers-user-wtu 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSC 107L – Programming For Science
Mastery Exam
Directions:
1) This exam is to be done individually and is open book and open notes, but closed
Internet. Any communication between students is considered de facto cheating
and any students involved will automatically fail this lab. Any questions you may
have should be directed to the instructor.
2) Read the instructions for each problem carefully. Questions explicitly state the
code you need to write. If you are unsure about whether you need to write
something, ask the instructor.
3) You should start by typing in (including the period):
cp ~hertzm/masteryPractice/* .
You will find all the files you need for this practice. You may be asked to write C
programs from scratch.
4) Each question is independent and you can solve the problems in any order you
wish. Since the questions are weighted equally, you may wish to solve the
easiest/quickest problems first.
5) There are different levels of completion of each question: it compiles, it runs but
crashes, it runs without crashing but gets the wrong answer, and it runs and gets
the correct answer. These are worth 20%, 20%, 20%, and 40%, respectively.
Commenting your code is appreciated, but will not be graded. You can only earn
credit for code you modify and submit.
6) At the end of class, e-mail your .c files to me.
pf3

Partial preview of the text

Download Mastery Exam Questions - Computer Program for Science | CSC 107 and more Exams Computer Science in PDF only on Docsity!

CSC 107L – Programming For Science

Mastery Exam

Directions:

1 ) This exam is to be done individually and is open book and open notes, but closed

Internet. Any communication between students is considered de facto cheating

and any students involved will automatically fail this lab. Any questions you may

have should be directed to the instructor.

2 ) Read the instructions for each problem carefully. Questions explicitly state the

code you need to write. If you are unsure about whether you need to write

something, ask the instructor.

3 ) You should start by typing in ( including the period):

cp ~hertzm/masteryPractice/*.

You will find all the files you need for this practice. You may be asked to write C

programs from scratch.

4 ) Each question is independent and you can solve the problems in any order you

wish. Since the questions are weighted equally, you may wish to solve the

easiest/quickest problems first.

5 ) There are different levels of completion of each question: it compiles, it runs but

crashes, it runs without crashing but gets the wrong answer, and it runs and gets

the correct answer. These are worth 20%, 20%, 20%, and 40%, respectively.

Commenting your code is appreciated, but will not be graded. You can only earn

credit for code you modify and submit.

6 ) At the end of class, e-mail your .c files to me.

Question #1 (use files from the question1 directory)

In this question, you will use arrays to simulate the perfect shuffling of a deck of

cards. A “perfect” shuffle is one where the deck is split in exactly half and then you

alternate adding a card from each of the two halves. A more formal description of this

algorithm:

algorithm shuffle(int[] deck ) int first [6], last [6]; int i ; for i = 0 to 5, inclusive, increasing by 1 each iteration set the i th^ element in first to i th^ element in deck set the i th^ element in last to ( i + 6 ) th^ element in deck end for for i = 0 to 11, inclusive, increasing by 2 each iteration set the i th^ element in deck to ( i /2 ) th^ element in first set the ( i +1 ) th^ element in deck to ( i /2 ) th^ element in last end for

You will write your shuffle function in the deck.c file I provide. This class already

includes a main function that creates the deck array and calls shuffle. Your function

does not need to return anything. You do NOT need to write anything other than the

shuffle function.

The main class already contains code that create an array, prints out its contents and then

shuffles the “deck” 10 times. After each shuffle, it prints out the state of the deck. You

do not need to modify main. The instructor’s solution printed out:

2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC

2C 8C 3C 9C 4C 10C 5C JC 6C QC 7C KC

2C 5C 8C JC 3C 6C 9C QC 4C 7C 10C KC

2C 9C 5C QC 8C 4C JC 7C 3C 10C 6C KC

2C JC 9C 7C 5C 3C QC 10C 8C 6C 4C KC

2C QC JC 10C 9C 8C 7C 6C 5C 4C 3C KC

2C 7C QC 6C JC 5C 10C 4C 9C 3C 8C KC

2C 10C 7C 4C QC 9C 6C 3C JC 8C 5C KC

2C 6C 10C 3C 7C JC 4C 8C QC 5C 9C KC

2C 4C 6C 8C 10C QC 3C 5C 7C 9C JC KC

2C 3C 4C 5C 6C 7C 8C 9C 10C JC QC KC