Computer Science An Overview 12th Edition Brookshear Solutions Manual pdf download
Computer Science An Overview 12th Edition Brookshear Solutions Manual pdf 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/invitation-to-computer-
science-7th-edition-schneider-solutions-manual/
Invitation to Computer Science 6th Edition Schneider
Solutions Manual
https://testbankfan.com/product/invitation-to-computer-
science-6th-edition-schneider-solutions-manual/
https://testbankfan.com/product/computer-security-art-and-
science-1st-edition-bishop-solutions-manual/
https://testbankfan.com/product/criminalistics-an-introduction-
to-forensic-science-12th-edition-saferstein-test-bank/
https://testbankfan.com/product/microbiology-an-evolving-
science-4th-edition-slonczewski-solutions-manual/
https://testbankfan.com/product/chemistry-the-central-
science-12th-edition-brown-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
Exploring the Variety of Random
Documents with Different Content
drew his sword on his unarmed antagonist, and wounded him so
severely in the arm, that he was obliged to undergo amputation
the day following.
It is usual for a Peon who has been fortunate at play, to go to
Monte Video and clothe himself anew in the shop of a slop-seller.
While the shopman is looking out the articles he calls for, he
deliberately places his dollars on the counter, in separate piles,
assigning each to its destined purpose. He then retires to a
corner, and attires himself; an unfortunate comrade invariably
attends him, who examines his cast clothes, and, if better than
his own, puts them on. After passing a few days in idleness, he
sets out on his return home, where he appears in his new dress.
[7] Among the many daring and active feats performed by the
Peons, one of the most extraordinary of late years, was the
capture of a tiger by a female of that tribe. She was a mulatto-
woman, brought up in the vicinity of Barriga Negra. She was
accustomed at an early age to ride horses, and prided herself in
doing offices which belonged to the stronger sex, such as
catching cattle with the noose, killing them, &c. Her form was
masculine, and she became so inured to men’s work, that she
was hired as a Peon, and fulfilled that office much to the
satisfaction of her employers. She was noted for selecting spirited
horses, and for riding them at full speed. One day on her return
from labor, as she was passing a rivulet, she observed a large
tiger at no great distance. Surprised that the animal did not steal
away, as is generally the case when he sees a person mounted,
she drew nearer, still keeping her horse’s head from him, so as to
be ready to gallop off if he should make a spring. He was still
inattentive and motionless; the woman observing this, and
thinking he ailed something, after some minutes’ pause backed
her horse until she came within twenty yards of him, loosening at
the same time her noose from the saddle, which she threw most
dexterously over his neck, and immediately galloped away with
him to a considerable distance. Whether maimed or not before,
she knew he must now be dead; she therefore alighted, flayed
him, and carried home the skin as a trophy. The animal was
above the ordinary size, and not smaller than a calf six weeks
old. This exploit was long the talk of the neighbourhood, and I
have heard the woman herself relate the adventure.
[10] The fishery of the baugre here is very considerable, and the
mode of catching the fish, by means of a curved line of boats, by
night, (from each of which is held a flambeau of straw to scare
the fish toward the shore), is singularly picturesque, and might
remind the imaginative spectator of a crescent of wild fire
dancing on the waves. The fish is called at Rio de Janeiro the
mulatto velho; the negroes eat it during Lent, and on Fridays and
Saturdays.
[12] Forty years ago they caught a whale a day; but they now catch
only one in the course of a month.
[13] The oil, in consequence of not being well refined, is black and
sooty.
[23] I may also add their public spirit in resenting injuries done to
individuals, and in supporting the cause of the oppressed; a
singular instance of which I have often heard related. Some
seventy years ago, one of their governors, who was a nobleman,
had an intrigue with the daughter of a mechanic. The whole town
espoused the cause of the injured female, and compelled the
governor, at the peril of his life, to marry her.
[24] Had I approached this city by sea, I might have been enabled
to give a more animated description of its aspect; but I feel it
incumbent on me to adhere to veracity, the first duty of a
traveller, and to describe the impression made on my mind by the
view as I approached by land on my route from S. Paulo.
[25] Several have been established since the time when this
narrative was written.
[26] By way of experiment, I had some fat ewes killed, and the
mutton was acknowledged to be excellent; but the male lambs
are never prepared for the table.
[31] The little lime which they use here is made of shells, and is
brought from Porto das Caixas.
[37] Our mules required at least six penny-worth each per day,
exclusive of their corn.
[39] The finest parts of these tracts, in the best season, are by no
means so rich in grass as an English meadow.
[44] Four vintens are nearly equal to a shilling of our money. When
this rivulet was first washed for gold, the quantity produced by
each gamella amounted in value to that sum. As the cascalho
then lay near the surface, and required very little trouble to get
at, one washer could clear about twelve bowls-full per hour,
which was considered a comparatively rich return.
In the mines they have two methods of estimating the quantity
produced: for example; Quatro Vintens, here mean four vintens
of gold, which is equal to eight of copper; whereas, in Rio de
Janeiro, the same expression implies four vintens of copper.
[47] The negroes are constantly attending to the cascalho from the
very commencement of the washings, and frequently find
diamonds before this last operation.
[51] On the road there are numerous farm houses, which afford
sufficient accommodation for a traveller. They in general belong
to persons resident in Tejuco, where their produce is sold.
[52] In some of the low swampy tracts large serpents are not
uncommon. At Tejueo I was shown the skin of a young one, of
the Boa Constrictor genus. It was twenty-four feet in length, and
about twenty inches in circumference. These formidable reptiles
have been killed forty feet long! The strength of such a serpent is
not easily to be imagined; they have an undulating motion, and
carry their head erect four or five feet from the ground; their
jaws, &c. are capable of inconceivable dilatation.
[54] It may become useful at Villa Rica; but the quantity required
there at present is so trivial as scarcely to merit attention.
[55] If salt were cheaper they might be cured, and would become
an article of commerce, particularly during Lent.
[61] In many parts of the coast, the plant which produces the
barilla would probably florish abundantly, if introduced, and
would form an excellent article of commerce, not only for
exportation, but for home consumption.
[62] There are several rivulets in various parts that bear this name.
[68] Large trees are cut into planks of these dimensions for making
the cases, which are preferred to hogsheads.
[69] The West India sugars are not clayed, consequently much
stronger and fit for refining and making loaves.
It is much to be desired that the very excellent work, written
by Bryan Edwards, upon sugar making, and distilling rum, was
introduced in Brazil.
[71] During the past few years, the Governors of Matto Grosso have
used every effort to shorten the distance from these remote
provinces to the sea ports, by making roads, cutting down
woods, and forming establishments to accommodate passengers,
so that canoes, &c. may be transported over land, and make
straight-forward communications from one river to another, which
has shortened this journey at least two months.
[74] This river being the grand channel of communication from Rio
de Janeiro, Santos, S. Paulo, and other places, to the interesting
districts of Cuiaba, Matto Grosso, the whole of Paraguay, the river
Plata, Potosi, Chiquisaca, and a great part of Peru, I have
preserved the particular detail given in this paper, of its numerous
falls, and the difficulties of its navigation, as it is now well known,
and there is great reason to suppose, that it will soon be much
more frequented.
[76] The Silver from Potosi, which some years has exceeded twenty
millions of dollars, came down the Rio de la Plata to Buenos
Ayres.
[79] It has been found, however, from modern surveys, that those
rocks are by no means so dangerous as they have been
represented.
[80] In Brazil and the Plata the bridle is made of sufficient length to
serve the purpose of a whip.
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.