CSCE Computer Science Program

advertisement
Spring 2006
Name __________________________
CSCE Computer Science Program - Assessment Test
In-Class Exam - 2 hours
Instructions: Answer each question on a separate sheet of paper. If you need more paper, see
the instructor. Put your name on each sheet of paper.
Spring 2006
Name __________________________
1. (1) For each of the following applications, identify the most appropriate data structure:
(a) Answering telephone calls in the order of known priorities.
(b) Sending backlog orders to customers in the order that they have been received.
(c) Implementing a calculator for computing simple arithmetic expressions.
Spring 2006
Name __________________________
2. (1) If you have to solve a searching problem for n numbers and the numbers are stored in an
array, what is the most efficient algorithm for searching when the numbers are:
(a) unsorted
(b) sorted
Spring 2006
Name __________________________
3. (2) Define countably infinite set and uncountable set. Is the set of algorithms countably
infinite? Justify your answer. Is the set of functions with domain N (the set of natural numbers)
and range 0,1 countably infinite? Justify your answer. (Hint: consider * and 2N (power set of
natural numbers)) From your answers, what can we conclude about algorithms and problems (or
functions) that we would like to solve (or compute) using algorithms?
Spring 2006
Name __________________________
4. (1) Suppose a recursive algorithm has the recurrence T(n)=3T(n/2)+cn. What is the asymptotic
runtime of this algorithm?
Spring 2006
Name __________________________
5. (1) Give recursive pseudocode for Tree-Insert which inserts a vertex into a binary search tree.
Spring 2006
Name __________________________
6. (2) Consider the following transition table of a deterministic finite automaton.

0
q2
1
q1
q1
q3
q0
q2
q0
q3
q3
q1
q2
(a) Draw the corresponding state diagram.
(b) Decide which of the following strings are accepted:
i.
1001
ii.
11001
iii.
1111
iv.
00
v.
101
vi.
11001101.
(c) Describe the language accepted by the DFA in English.
Spring 2006
Name __________________________
7. (1) What primary feature distinguishes a functional language from an imperative language?
Spring 2006
Name __________________________
8. (1) List three methods of abstraction in an object-oriented language.
Spring 2006
Name __________________________
9. (1) What are the three stages of programming language interpretation?
Spring 2006
Name __________________________
10. (1) What are the two purposes of the environment structure in an environment-based
interpreter?
Spring 2006
Name __________________________
11. (1) Explain the difference between static scope and dynamic scope.
Spring 2006
Name __________________________
12. (1) What feature does the Scheme language have (among other languages) that allows certain
recursive functions to execute in constant space?
Spring 2006
13. (1) Axiomatic semantics are used for what purpose?
Name __________________________
Spring 2006
Name __________________________
14. (1) What is the difference between pass-by-value and pass-by-value-result parameter passing
strategies?
Spring 2006
Name __________________________
15. (1) What two kinds of entities does an object bundle together?
Spring 2006
Name __________________________
16. (1) Explain how a right-recursive context-free grammar rule can be transformed into a
recursive descent parsing function.
Spring 2006
Name __________________________
17. (2) Mention and explain five advantages of using a database management system.
Spring 2006
Name __________________________
18. (2) Why is normalization of relational databases considered important? How many normal
forms are there? Define any two normal forms.
Spring 2006
Name __________________________
19. (2) Why did the relational data model become more popular than network and hierarchical
models? Describe some salient features of relational model. Explain the referential integrity
constraint.
Spring 2006
Name __________________________
20. (2) What is union compatibility? Which relational algebra operations require union
compatibility? Explain how those operations work.
Spring 2006
Name __________________________
21. (2) What is ER model? Show at least three notations used in ER diagrams and for each of
them explain the concept that represents it.
Spring 2006
Name __________________________
22. (1) How do the waterfall and spiral development software development methodologies
differ?
Spring 2006
23. (1) What is a risk mitigation plan?
Name __________________________
Spring 2006
24. (1) Define these software engineering terms:
(a) capability maturity model
(b) rapid prototyping
(c) use case
(d) design pattern
(e) revision control
Name __________________________
Spring 2006
Name __________________________
25. (6) What is a set of rules used for communicating between computer systems over a
network?
Spring 2006
Name __________________________
26. (6) In Unix more than one user can be logged in at once. What do we call this system?
Spring 2006
Name __________________________
27. (6) In contrast to UNIX, a PC is usually a __________system.
Spring 2006
Name __________________________
28. (6) True or false: High-level languages are generally machine dependent.
Spring 2006
Name __________________________
29. (6) Give a Unix command that will give no permission for group and everyone (others) for
your home directory for anything.
Spring 2006
Name __________________________
30. (6) What Unix command do you use to create a new directory?
Spring 2006
Name __________________________
31. (6) True or false: Your program executable files are in ASCII.
Spring 2006
Name __________________________
32. (1) Prove the following identity by using algebraic manipulation and also by using truth
tables.
a b c  abc  abc  abc  a bc
Spring 2006
Name __________________________
33. (1) Given a binary pattern in some memory location, is it possible to tell whether this pattern
represents a machine instruction or a number?
Spring 2006
Name __________________________
34. (1) How does the implementation of pipelining affect the delay and throughput of a
calculation?
Spring 2006
Name __________________________
CSCE Computer Science Program - Assessment Test
Take-Home Exam – est. time 4 hours
Instructions: Turn in the take-home exam to Susan Huskey by 5pm on 4/18/06. Email your
source code for the programs to rdeaton@uark.edu and cwt@uark.edu in a zip archive.
Spring 2006
Name __________________________
1. (9) (a) Describe two of the most significant developments in the history of computing. Justify
your answer. (b) List 5 computer pioneers and describe their contributions.
Spring 2006
Name __________________________
2. (11) How has the Internet affected US politics since the events of “9-11"? Discuss.
Spring 2006
Name __________________________
3. (10) Name and describe the main algorithm behind “google.com" search engine.
Spring 2006
Name __________________________
4. (9) In general, how can we remedy the “digital divide" problem? How can Computer Science
contribute?
Spring 2006
Name __________________________
5. (1) Operating system concepts: (a) Select your favorite user thread library. (For example, you
may choose pthreads, Solaris 2 threads, Windows 2000 threads, Linux threads, or Java threads,
but there are others.) Discuss the implementation and use of this library on at least four points.
For example, you may wish to talk about the multithreading model (e.g., many-to-one, one-toone, many-to-many), the handling of fork and exec and signals, the handling of thread
cancellation, or the use and storage of thread-specific data. You may also discuss how to use the
calls available in the library to create or cancel threads. Some libraries have restrictions that
users of this thread library may have as compared to other thread packages, and you can discuss
those. You answer should consist of approximately four short paragraphs (less than a page total).
Spring 2006
Name __________________________
6. (5): Your task is to write an object-oriented program in Java that simulates a role-playing
game. The generic type of player has four attributes, a name, an honor between 0 and 100
inclusive, a strength, and a class that indicates the type of player. The strength should be
calculated from the honor as two times the square root of honor.
In the game, however, we want more specialized players, i. e. fighters and wizards. The strength
of fighters is increased by some random number between 0 and 50. Wizards have an additional
characteristic, magic, which is a number between 0 and 1. When a wizard casts a spell, he will
increase his honor temporarily, which of course increases his strength. Generate a random
number between 0 and 1, and when compared to the magic of the wizard, either adds 10 to the
honor or not. The honor can exceed its maximum value through this temporary bonus. The
higher the magic, the more likely that the temporary bonus will be added. Throughout this
program, as honor is changed, you will have to recalculate strength.
Create a kingdom of random players. Let the user specify the number of players. Sort them by
increasing honor and store in a text file.
We next have to have a way for players to attack each other. The idea is that one player attacks
another. Wizards get to cast their spell during the battle. The winner of the battle has his honor
increased and the loser has his honor decreased. When a player’s honor reaches zero, he is out of
the game. The winner of the battle will be computed by comparing the player’s strength. In
addition, there will be a random component. Do it this way: Calculate the total strength of both
players. Then, generate a random number between 0 and 1. If this number is less than the
attacking player’s strength divided by the total strength, he wins. Otherwise, the attacked player
wins. The loser’s honor should be decreased by 10, and the winner’s honor increased by 10.
The input/output should go as follows:
Welcome to my game!
Enter i to initialize game, b for battle, d to display players, x to exit:
i
How many Players:
4
1: Name = WBF class = Fighter honor = 32 strength = 31.314
2: Name = ADC class = Wizard honor = 45 strength = 13.416 Magic = 0.509
3: Name = QEG class = Wizard honor = 74 strength = 17.205 Magic = 0.264
4: Name = EIL class = Fighter honor = 88 strength = 68.762
The players have been saved to game.txt.
Enter i to initialize game, b for battle, d to display players, x to exit:
b
Choose two players:
1: Name = WBF class = Fighter honor = 32 strength = 31.314
2: Name = ADC class = Wizard honor = 45 strength = 13.416 Magic = 0.509
3: Name = QEG class = Wizard honor = 74 strength = 17.205 Magic = 0.264
4: Name = EIL class = Fighter honor = 88 strength = 68.762
Enter the attacking player:
2
Enter the defending player:
1
Player 2: Name = ADC class = Wizard honor = 45 strength = 13.416 Magic = 0.509
is attacking
Player 1: Name = WBF class = Fighter honor = 32 strength = 31.314
The winner is 1: Name = WBF class = Fighter honor = 42 strength = 22.961
The loser is 2: Name = ADC class = Wizard honor = 35 strength = 11.832 Magic =
Spring 2006
0.509
Enter i to initialize
d
1: Name = WBF class =
2: Name = ADC class =
3: Name = QEG class =
4: Name = EIL class =
Enter i to initialize
x
Good-bye!
Name __________________________
game, b for battle, d to display players, x to exit:
Fighter honor = 42 strength = 22.961
Wizard honor = 35 strength = 11.832 Magic = 0.509
Wizard honor = 74 strength = 17.205 Magic = 0.264
Fighter honor = 88 strength = 68.762
game, b for battle, d to display players, x to exit:
Spring 2006
Name __________________________
7.
(4) You are to write two programs to solve the following problem. One program should
solve the problem in a procedural way, and the other in a functional way (i.e., no assignment).
The problem: Print on stdout an estimate of PI using a Monte Carlo simulation. The number of
experiments to run is given as a command line argument to your program.
A single experiment is: Generate two random numbers, a and b if a and b are relatively prime
(i.e., gcd(a,b)==1), the experiment is a success otherwise, the experiment is a failure.
The ratio of successful experiments to total experiments is approximately 6/(2).
You are to write your own linear congruential random number generator: r'=(a*r+c)%m where r
is the current random number, r' is the next random number in the random number stream, and a,
c, and m are constants. Define the constants a, c, and m as 16807, 0, and 2147483647,
respectively. You may choose any non-zero number as the initial value of r.
You may use the same language or different languages for the two implementations. Include a
README on how to compile and/or run your programs.
Spring 2006
Comments on this Assessment Test
In Class Exam
Take Home Exam
Name __________________________
Download