Computer Science An Overview 12th Edition Brookshear Solutions Manual instant download
Computer Science An Overview 12th Edition Brookshear Solutions Manual instant download
https://testbankfan.com/product/computer-science-an-
overview-12th-edition-brookshear-solutions-manual/
https://testbankfan.com/product/computer-science-an-overview-12th-
edition-brookshear-test-bank/
https://testbankfan.com/product/computer-science-an-overview-11th-
edition-brookshear-test-bank/
https://testbankfan.com/product/family-therapy-an-overview-9th-
edition-goldenberg-test-bank/
https://testbankfan.com/product/strategic-management-a-competitive-
advantage-approach-concepts-16th-edition-david-test-bank/
Psychiatric Mental Health Nursing Concepts of Care in
Evidence Based Practice 8th Edition Townsend Test Bank
https://testbankfan.com/product/psychiatric-mental-health-nursing-
concepts-of-care-in-evidence-based-practice-8th-edition-townsend-test-
bank/
https://testbankfan.com/product/pathophysiology-4th-edition-ellen-
test-bank/
https://testbankfan.com/product/elementary-statistics-6th-edition-
larson-test-bank/
https://testbankfan.com/product/economics-principles-for-a-changing-
world-4th-edition-chiang-test-bank/
https://testbankfan.com/product/federal-tax-research-10th-edition-
sawyers-solutions-manual/
Operations Management for MBAs 5th Edition Meredith
Solutions Manual
https://testbankfan.com/product/operations-management-for-mbas-5th-
edition-meredith-solutions-manual/
Chapter Six
PROGRAMMING LANGUAGES
Chapter Summary
This chapter begins with a short history of programming languages. It presents the classification of
languages by generations and also points out that such a linear classification scheme fails to capture
the true diversity of languages today. To support this claim, the chapter introduces the declarative,
functional, and object-oriented paradigms as alternatives to the more traditional imperative
approach. There are separate sections later in the chapter on both the object-oriented and declarative
paradigms.
The chapter also presents some common structures found in third-generation imperative and
object-oriented languages, drawing examples from Ada, C, C++, C#, FORTRAN, and Java. Topics
covered include declaration statements, control statements, functions, and parameter passing. An
additional section extends this study to include topics associated with object-oriented languages.
To bridge the gap between high-level languages and machine language, this chapter discusses
the rudiments of language translation, including the basic steps of lexical analysis, parsing, and
code generation.
Optional sections introduce parallel programming, and explore declarative programming via
logic programming and the language Prolog.
Comments
1. This chapter is intended to serve one of two roles, depending on the programming background of
the audience. For those with previous programming experience, the chapter can be approached as
an introduction to the subject of language design and implementation. For those with no
programming experience, the chapter can serve as a generic introduction to programming
languages or a context in which a particular language can be emphasized.
2. I encourage you not to get bogged down in the details of this chapter. Discourage your students
from approaching the material in the context of memorizing facts about specific languages. Their
goal should be to answer questions such as "Identify some different programming paradigms,"
"Describe three generic control structures and indicate how they might be expressed in a high-level
programming language," and "Describe the difference between data type and data structure."
3. Although the section on declarative programming is optional, I encourage you to give it some
time in your class. It is important that beginning students be exposed to alternatives.
4. An area in programming language research is the identification of useful control structures and
the development of syntactic structures to represent them. Along these lines I like to use the
example of trying to find a particular value in an array using the equivalent of a "for" statement. The
problem is to exit the loop structure as soon as the target value is found without traversing more of
the array. This leads to the role of such statements as the "break" in C and its derivatives or "EXIT"
in FORTRAN.
33
2. Suppose the value of x is stored in the memory cell whose address is XY and the program begins
at address 00.
2100
31XY
2003
B110
2201
5112
31XY
B006
3. We'll represent the addresses of LENGTH, WIDTH, and HALFWAY by XX, YY, and ZZ,
respectively.
10XX
11YY
6001
30ZZ
4. Suppose the values W, X, Y, and Z are stored at locations WW, XX, YY, and ZZ, respectively.
Moreover, we use VV as an address.
2000
11XX
12YY
B1VV
11WW
VV: 5012
30ZZ
5. The answer to both questions is that this information is needed before the machine code for
manipulating the data can be generated. (To add two binary values uses a different op-code than
adding two floating-point values.)
6. Imperative paradigm: Programs consist of a sequence of commands.
Object-oriented paradigm: Programs are organized as active elements called objects.
Functional paradigm: Programs consist of nested functions.
Declarative paradigm: Programs consist of declarative statements that describe properties.
7. The smallest of the four values w, x, y, and z.
8. The string dcababcd.
9. The major item of data would be the account balance. The object should be able to respond to
deposit and withdrawal messages. Other objects in the program might be saving account objects,
mortgage objects, and credit card account objects.
10. An assembly language is essentially a mnemonic form of a machine language.
11. A simple approach would be to assign mnemonics to the opcodes, using R1, R2, and so on to
represent the registers, and separating the fields in each instruction with commas. This would
produce instructions such as ST R5, F2; MV R4, R5; and ROT R5, 3.
12. This approach is not self-documenting in the sense that it does not indicate that the value of
AirportAlt will not change in the program. Moreover, it allows the value to be changed by an
erroneous statement.
13. The declarative part of the program contains the programmer-defined terminology; the
procedural part contains the steps in the algorithm to be executed.
14. A literal is a specific value appearing as itself; a constant is a name for a fixed value; a variable is
a name whose associated value can change as the program executes.
34
15. a. Operator precedence is a priority system given to operations that determines the order in
which operations will be performed unless otherwise specified.
b. Depending on operator precedence the expression could be equal to either 24 or 12.
16. Structured programming refers to an organized method of developing and expressing a
program with the goal being to obtain a well-organized program that is easy to read, understand,
and modify.
17. In the first case the symbol represents a comparison; in the second case it represents data
movement.
18.
19. x = 2
while (x < 8):
. . .
x = x + 2
20. Music is normally written in an imperative language containing loops and "go to" control
structures.
21.
22. case(W)
5: Z = 7
6: Y = 7
7: X = 7
35
23. if (X > 5):
X = X + 2
else:
X = X + 1
24. a. if and switch structures
b. while, repeat, and for structures as well as recursion
c. the assignment statement
25. A translator merely converts a program form one language to another. An interpreter executes
the source program without producing a translated copy.
26. If the required coercion was allowed the value 2.5 would probably be truncated to 2.
27. All operations (including assignments) must be performed without coercion.
28. It would require time to copy the data as well as memory space to hold the copy.
29. When passing by value, the sequence 7, 5 would be printed. When passing by reference the
sequence 7, 7 would be printed.
30. When passing by value the sequence 5, 9, 5 would be printed. When passing by reference, the
sequence 9, 9, 9 would be printed.
31. 5, 9, 9
32. a. Passing parameters by value protects the calling environment from being altered by the
function being called.
b. Passing parameters by reference is more efficient than passing them by value.
33. Depending on the order of execution, X could be assigned either 25 or 13.
34. It is not clear which of the statements in the first program should be modified, but merely
changing the value of the constant NumberOfEmp in the alternate version would update the
program without difficulty.
35. a. A formal language is defined by its grammar, whereas the grammar of a natural language is
merely an attempt to explain the structure of a natural language.
b. Programming languages such as C, C++, Java, and C# are formal languages. Examples of
natural languages include English, Spanish, Italian, etc.
36.
39. Answers will vary. The top level diagram might indicate that the date can be expressed in
different ways. Then, other diagrams would reveal the details of each approach.
36
40. A string would have the structure of "yes no," or the word yes followed by a "sentence" followed
by the word no.
41. This one is a bit tough for beginning students. The point is for them to experience the reality that
the tools applied when solving a problem can actually restrict one's ability to find the solution. In
this case the problem is to describe the grammatical structure of a simple language. However, the
tool is the concept of a syntax diagram that only allows the description of context-free languages,
whereas the set to be described does not form a context-free language. Encourage your students to
think about this. An extension to the problem would be to ask your students what features could be
added to syntax diagrams that would allow such languages to be described.
42. Any string of the form xnyxn , where n is a nonnegative integer.
43.
44.
45. When performing either assignment statement, the value of X will already be in a register as a
result of the comparison performed earlier. Thus, it need not be retrieved from memory.
46. Y = 5
Z=9
47. X = 5
48. Both types and classes are templates used to describe the underlying composition of "variables."
Types, however, are predefined whereas classes are defined by the programmer within the "written
program." (We put written program in quotes because the class definition could be imported from a
pre-written package as in Java's API.) More about types versus classes is discussed in Section 7.7.
49. There are numerous answers. The idea is for students to isolate basic properties of buildings
within a single class and then use inheritance to describe more specialized classes such as houses,
hotels, grocery stores, barns, etc. Some students may find that multiple levels of inheritance are
helpful.
50. The public parts of a class are those parts that are accessible from the outside; the private parts
are those that are not accessible from the outside.
51. Answers will vary.
52. There may be numerous objects representing people. Some would be quests whereas others
would be hotel employees (a good place for inheritance). Other objects might include a
receptionist's desk, a seating area, and perhaps an elevator.
37
53. A programming language monitor is a construct that provides controlled access (usually mutual
exclusion) to a data item.
54. Concurrent processing can involve multiple threads of execution sharing and coordinating
resources. Programming languages with concurrency support provide easier ways for developers to
create and coordinate threads, share data between threads, provide mutual exclusion where
required, and prevent common concurrent programming errors.
55. One solution would be
56. No. The following resolution pattern produces the empty clause.
57. Assuming that the sibling relationship is amended so that a person cannot be his or her on
sibling as proposed in the answer to Question/Exercise 3, the additional relationships could be
defined as:
uncle(X, Y) :- male(X), sibling(X, Z), parent(Z, Y).
aunt(X, Y) :- female(X), sibling(X, Z), parent(Z, Y).
grandparent(X, Z) :- parent(X, Y), parent(Y, Z).
cousin(X, Y) :- sibling(W, Z), parent(W, X), parent(Z, Y).
parents(X, Y, Z) :- X \= Y, parent(X, Z), parent(Y, Z).
58. The last two statements translate to “David likes people who like sports” and “Alice likes things
that David likes.” Prolog will conclude that Alice likes sports, music, and herself. (Alice likes things
that David likes, David likes people who like sports, and Alice likes sports. Therefore, Alice likes Alice.)
59. Due to truncation errors, X may never be exactly equal to 1.00 so the loop may never terminate.
38
Random documents with unrelated
content Scribd suggests to you:
people murmuring or misimploying their time. Formerly two jesuits
were in each parish; but since their great increase there is only one,
till they get more from Europe.
The Indians are not sufferd to drink wine, or any spirituous liquor.
Herein the good priests copy the law of Mahomet, who likewise
forbid his disciples the use of wine; lest being spirited up, they
should rebel, shake off their yoke, and overturn the empire he had
founded.
The jesuits marry their men and women young, to fulfil perhaps the
first commandment given to Adam, Increase and multiply, or for
other wise ends. The first precepts the children learn, are to fear
God and the jesuit; to be humble and patient, and not in love with
this world.
The whole Mission can draw together 60,000 men in a week’s time.
Their pretense for keeping up so great a number is, because the
Portuguese Paulists sometimes make excursions and take away their
people: but the Spaniards laugh at this, well knowing that the jesuits
keep these standing forces to prevent any foreign power giving
disturbance to their colony.
Their omitting to teach the Indians the Spanish tongue, and
forbiding them to converse at all with that nation when they are
sometimes sent to work in the towns for the king of Spain’s service,
is plain they mean to keep their government to themselves. For
when any stranger, as these two Frenchmen, are driven there by
accident, they are shut up while they stay. And when the Spaniards
themselves passing up the river Paraguay have occasion to touch
upon their settlement, they dare not go beyond their church walls:
and when they beg leave to see the town, the jesuit is sure to walk
with them, and all the Indians are taught to keep in, and shut their
doors. They have other precautions, one of which is, to send out
good detachments of troops to clear their frontiers from St. Gabriel’s
isles to the Maldonad hills, and hinder all communication with their
country, for the sake of their gold and silver mines; of which we shall
give two instances. The Falmouth of St. Malo being lost in 1706 near
the Flores islands, some of these troops plunderd part of her cargo;
which they afterwards restored by the interposition of the governer
of Buenos Ayres. Two years after this, the Atlas was cast away at the
Castiles, and the crew having saved some of their best effects, were
marching over the country to the Maldonades, thinking to get home
again by sea; but were met by the Indians, who took all from them.
However, they had luckily buryd their silver upon the coast, to the
value of several thousand dollars, which they afterwards took along
with them.
At the foot of the Maldonad mountains are good mines, which were
discoverd by Pacheco, who lived at Buenos Ayres and was formerly
miner of Potosi in Peru: they are about seventy mile from the port,
and forty from Montevide. The governer of Buenos Ayres being
acquainted with it, sent workmen with Pacheco, who dug up the
place and returnd with a good quantity of gold ore. But Valdes
Inelau the governer being bribed by the father of the Mission, gave
out that he had made trial of the ore, and it would not answer the
charge and trouble. However Pacheco kept what he had got, and
saw it was only a trick of the jesuits, to prevent any new settlement
near their dominions.
Some of the said ore was lately tryd in France, but yielded little,
being taken from neat the surface. But Pacheco, who is known to be
as good a miner as any, says, there is no richer earth in America
than that place affords: and doubts not the rivers thereaway are
fertile of gold dust, as those near the Paulists. The young Indians in
the parish of St. Dominic, have several times brought gold to Buenos
Ayres, which they got privately from the Mission; from whence we
may infer there is a good deal of it.
From the foregoing particulars, ’tis evident that the jesuits affect
sovereignty and arbitrary rule; and the three chief objects of their
desire are power, splendor and riches. Their method of educating
and governing their people, from whose industry arises all they
enjoy, allowing them the bare necessaries of life; their care to
prevent any communication with the Spaniards; their caution when
any stranger comes to their Mission by accident; their standing
forces, and scowring their borders to prevent any new settlement
near their limits; are all manifest arguments that they design to
continue independent: and not only conceal what revenues they
have, but many other advantages they are not yet quite possest of.
Some casuists will say, that all these nations round Paraguay belong
to his Spanish majesty as king of the Indies; Paraguay it self being
possest by the Spaniards in 1540, and governd by the viceroy of
Peru. According to these gentlemen, the true divine right is the right
of conquest: so that all these Indians are his natural born subjects,
and should obey him alone. They ought freely to parcel out their
land, and dispose of their own crop, and otherwise injoy the fruit of
their labor, whether in the mines or manufactures: this would make
it a regular colony, and cause a general circulation of trade and
money. Doubtless the poor Indians would be glad of all this: but the
wise fathers argue a different way, That since they have got them
under subjection, and brought them into great rule and order, they
have at present a fair title to their allegiance: especially since all this
is done without cruelty or force of arms. ’Tis true, the Indians can
call nothing their property, but give up all as the inheritance of two
and forty ecclesiastical kings ruling two million of good natured loyal
subjects.
The jesuits ought to pay the king a yearly subsidy of so much a head
for every Indian through their settlement, according to the capitation
tax. But this, if paid, is sufficiently returnd by the wages the Indians
receive, when they work for the king, who at the year’s end is often
made debtor to the Mission. For, in the first place, the jesuits dont
give in the number of half their families to be taxt. Then the
governer of Buenos Ayres, who ought once in five years to visit all
their Mission, and take an exact list, is stopt in his journey, and
gratifyd for his trouble: so that he finds it better to take their own
list. And lastly, when 500 Indians are imployd in the king’s service,
the good fathers charge him 1000.
Thus is his Catholic majesty served, not only in the south Indies, but
in all other parts of America; where his revenues are half sunk in
feignd imployments and imaginary applications. As for the
settlement of the jesuits, I shall only make this observation upon it,
That all people are more naturally led than driven; and the same
policy that founded this government will probably maintain it, if the
fathers keep a succession out of their own society. If ever they make
a present of this colony to a foreign power, it must be that of
France: for the Spaniards and Portuguese are hated by all the
Americans for their tyranny and pride: and no other Romish power
except France, would be able to defend and support its title.
MEMORANDUM.
FINIS.
Transcriber’s Note:
Page iv, Errata incorporated into book.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
testbankfan.com