Lesson 03

advertisement
Viewing Quiz
Lesson 03
BIT 143
Name:___________________________________________
For each of the below questions, write a short sentence or two to express (in your own words) your
answer. Keep the answers short, but use complete, correct, English sentences.
If it helps to clarify the questions, feel free to mentally prefix all the questions with the phrase
"According to the video…"
1. After you’ve watched all the videos, please answer this question:
Of all the videos that you watched, if you could pick one video to be re-recorded by the
instructor outside of class which would you choose? Why?
(Keep in mind the recording outside of class will omit any pauses from the instructor answering
student questions, have less hemming and hawing, etc, and generally be more concise)
< Write your answer here >
VIDEO: NUnit Overview
2. Starting in PCE 03 most-if-not-all of each week’s exercises will have unit tests. Using these unit
tests will allow you to enter your answer (to enter your C# source code), run the tests, and then
see the grade that you would get if you submitted that answer to the instructor.
(None needed – I just wanted to make sure that this was 100% clear  )
3. What is the goal of the Pre-Class Exercises? How does this goal differ from the goal(s) of the
homework assignments?
4. Why does the instructor require due dates for these automatically graded (“auto-graded”) PCEs?
5.
If you get 6 points (or more) as a ‘raw score’ for the PCEs, what happens? Why is the instructor
doing this?
Viewing Quiz
Lesson 03
BIT 143
VIDEO: Quick NUnit/Autograder How-To
1. What is unit testing?
2.
Does testing guarantee that your software works? If not, then why do it?
3. Briefly describe (in English) how would you write a unit test to check that the isPrime method
correctly identifies 3 as being prime?
4.
What are the three basic categories of numbers to test with the isPrime function?
5. In this class, are you required to write your own unit tests from scratch?
6.
What might an exam question on this topic look cover?
7. Within the provided starter projects, which folder/project will your answers (your C# code) go?
8.
Which project/folder contains the unit tests?
Viewing Quiz
Lesson 03
BIT 143
9. Which C# file will you hand in?
(You MUST .ZIP everything you hand in, even if you only hand in this one, single file. *cough*
my Python scripts assume this*cough*)
10. How can you run your own code as a normal console application?
How do you switch back to running the NUnit tests?
11. How can you use the ‘Find In Files’ feature of Visual Studio (including Visual C# Express) in order
to find the code for the exercise that you need to work on next?
12. Which file contains all the tests that are given to you?
13. Each class that contains tests is marked with what attribute/word?
Each method that is a test is tagged with what word/attribute?
14. Prior to running each (and every) test method, what method does NUnit run first?
15. Why is the Assert.That line so important? What does it do?
16. When a parameter is marked with the [Values(0, 1, 2)] attribute, how does NUnit run the tests?
Viewing Quiz
Lesson 03
BIT 143
(Ignore the part that says you need to watch the viewing quiz for the in-class videos – whether you
have to watch them or not was specified earlier this quarter)
VIDEO: Stacks: ADT, Examples
17. What are some example of simple/primitive data types? Where is the memory needed to store
these items allocated?
18. What does ADT stand for? What is the purpose of ADTs in programming?
19. Fill in the blank: “A stack is what’s called a __(1)__ data structure. Meaning that the ___(2)____
thing that you’ve added to the stack is the first thing you’re going to get back out”
20. In a “pure stack” which item(s) are you allowed to examine/get?
21. What does the “push” method do?
22. What does the “pop” method do?
23. Briefly, intuitively summarize what a call stack is, and why it must be a stack (why does it make
sense that the program will only access the top-most stack frame)?
Viewing Quiz
Lesson 03
BIT 143
(The purpose of this question is to make sure that you’ve seen a couple of examples of how to
use a stack, and NOT to be able to explain this particular example in detail!)
24. Briefly, intuitively summarize how does the ‘Undo’/’Redo’ feature use a stack(s)?
(The purpose of this question is to make sure that you’ve seen a couple of examples of how to
use a stack, and NOT to be able to explain this particular example in detail!)
25. How is “Reverse Polish Notation” set up? Give a quick example:
26. How can a stack be used to parse/calculate a mathematical expression written using “Reverse
Polish Notation”?
27. Why is “Reverse Polish Notation” sometimes called a “postfix” notation? What sort of notation
we normally used? What is a “prefix” notation?
VIDEO: Stacks: API, Implementation
28. What does the acronym API stand for? In a nutshell, what is an API?
29. What we will use as the API for the push function?
(Include the return value, function/method name, any parameters, and describe any possible
errors that might happen.)
Viewing Quiz
Lesson 03
BIT 143
30. What we will use as the API for the pop function?
(Include the return value, function/method name, any parameters, and describe any possible
errors that might happen.)
31. What does the peek function do (and how does it differ from pop)? What we will use as the API
for the peek function?
(Include the return value, function/method name, any parameters, and describe any possible
errors that might happen.)
32. What we will use as the API for the isEmpty function?
(Include the return value, function/method name, any parameters, and describe any possible
errors that might happen.)
33. What C# data type(s) will we use to implement our stack class?
34. For our implementation, what does the ‘top’ instance variable mean?
(If it has the value -1 what does that mean? If ‘top’ has the value 0 what does that mean?)
35. Intuitively, describe how our push method will work. Make sure that you describe all of the
following:
How does the method detect that the stack is full?
How does the method detect that the stack is empty?
If the stack is not full, what is done?
Viewing Quiz
Lesson 03
BIT 143
VIDEO: Queue: API, Implementation
36. A queue is referred to as a ______ data structure (hint: the answer is 1 word, 4 letters long, and
it’s an acronym)
37. When we add a new item to the queue, which end is it placed at?
When we remove an new item to the queue, which end is it removed from?
38. What is another word that means “add” to a queue?
What is another word that means “remove” from a queue?
39. What is the problem with a simple, naïve implementation of a queue that uses an array (i.e.,
what is the problem with a non-circular implementation)?
40. If you did use a simple, naïve implementation of a queue (as an array), why is it bad to make
space within the queue by shifting down all the elements in the array?
What is the running time to shift all the elements down by one?
41. What is the basic idea behind a circular queue? What happens when the reference to the back
of the queue reaches the end of the array (assuming that there’s empty space at the front of the
array)?
Viewing Quiz
Lesson 03
BIT 143
42.
C#’s only ternary operator (operator that takes 3 operands) is the ?: operator. Explain
(concisely) what the following line of code does (the parentheses have been color-coded so
they’re easier to visually match.
back = ( (back + 1) == items.Length ) ? 0 : (back + 1);
43. Re-write the following code snippet to use an equivalent if…else statement:
back = ( (back + 1) == items.Length ) ? 0 : (back + 1);
44. Deqeue is very similar to how Enqueue is written. Based on what’s in the slide and what was
described in the audio, write out the Dequeue function here.
(Note – you are not required to get this to compile & run 100% correctly – please feel free to
“code this up” here in Word. The main objective is to make sure that you followed the
description overall)
Download