(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including...
Question:
(a) Use the following text to derive distributions for rat and chased. Use a five-word window, including open- and closed- class words, ignore case, punctuation and sentence boundaries and weight contexts by frequency. The cat chased a rat. A big rat chased the big dog. [4 marks] (b) Show unlabelled dependency links for each sentence and give distributions for rat and chased using contexts derived from single dependency links. [5 marks] (c) In general, what type of differences will arise in distributions if dependency links are used instead of word windows as context? [4 marks] (d) Outline one or more experiments to determine whether distributional information could be used (a) A two-state Markov process may emit a '0' in State 0 or a '1' in State 1, each with probability , and return to the same state; or with probability 1 it emits the other symbol and switches to the other state. Thus it tends to be "sticky" or oscillatory, two forms of predictability, depending on . '1' '0' '1' '0' State 0 State 1 Two-State Markov Process (i) What are the state occupancy probabilities for 0 < < 1? [2 marks] (ii) What are the entropy of State 0, the entropy of State 1, and the overall entropy of this source? Express your answers in terms of . [2 marks] (iii) For what value(s) of do both forms of predictability disappear? What then is the entropy of this source, in bits per emitted bit? [2 marks] (b) Consider a binary symmetric channel with error probability p that any bit may be flipped. Two possible error-correcting coding schemes are available. (i) Without any error-correcting coding scheme in place, state all the conditions that would maximise the channel capacity. Include conditions on the error probability p and also on the probability distribution of the binary source input symbols. [2 marks] (ii) If a (7/4) Hamming code is used to deliver error correction for up to one flipped bit in any block of seven bits, provide an expression for the residual error probability Pe that such a scheme would fail. [2 marks] (iii) If instead repetition were used to try to achieve error correction by repeating every message an odd number of tim positive integer m followed by majority voting, provide an expression for the residual error probability Pe that the repetition scheme would fail. [2 marks] (c) Gabor wavelets are an important class of complex-valued functions for encoding information with maximal resolution simultaneously in the frequency domain and the signal domain. Using an expression for their functional form, explain: (i) their spiral helical trajectory as phasors, shown here with projections of their real and imaginary parts; (ii) the Uncertainty Principle under which they are optimal; (iii) the spaces they occupy in the Information Diagram; (iv) some of their uses in pattern encoding and recognition.
(a) Huffman trees enable construction of uniquely decodable prefix codes with optimal codeword lengths. The five codewords shown here for the alphabet {A,B,C,D,E} form an instantaneous prefix code. (i) Give a probability distribution for the five letters that would result in such a tree. (ii) Calculate the entropy of that distribution. (iii) Compute the average codeword length for encoding this alphabet, and relate your results to the Source Coding Theorem. ? ? ? ? A B C D E 00 01 10 110 111 0 0 0 0 1 1 1 1 [3 2 marks] (b) What does it mean for a function to be "self-Fourier"? Show that the Gaussian function is self-Fourier. Name two other functions of importance in information theory that are self-Fourier, and in both cases mention a topic or theorem exploiting this property. [6 marks] (c) (i) In the FFT algorithm, if a discrete data sequence consists of N sample values (nominally N is some power of 2), what complex number is the primitive Nth root of unity which, raised to various powers, generates all the complex numbers needed to perform a discrete Fourier transform? [2 marks] (ii) If all the Nth roots of unity are known, by what mechanism are sequences of them selected that are needed for the k th frequency component? [2 marks] (d) Define the Kolmogorov algorithmic complexity K of a string of data. What approximate relationship is expected between K and the Shannon entropy H for the same source? Give a reasonable estimate of the Kolmogorov complexity K of a fractal, and explain why it is reasonable. [4 marks]
(a) For an inner product space V = R 4 with Euclidean norm and a set of vectors demonstrate both whether the vectors {x, y, z, w} form an orthogonal system, and whether they form an orthonormal system. [4 marks] (b) Let f[n] for n = 0, 1, 2, , N 1 be a discrete data sequence of N complex values, where N = 2Z is some integer power of 2. (i) Define the Discrete Fourier Transform (DFT) of f[n], a discrete sequence F[k], as a series using complex exponentials. In terms of N, how many complex multiplications would be required to compute F[k] explicitly? Then define W, the primitive Nth root of unity, and now re-express your series for F[k] in terms of W. [4 marks] (ii) Now express your DFT sequence F[k] using a series with only N/2 terms, by capturing the second half of the series within the first half, and show that fewer complex multiplications are required. [4 marks] (iii) Now show that separating F[k] into two new sequences of half-length, each of which computes only N/2 coefficients F[k], leads to a very efficient recursive form. How many times can this halving process be repeated? Ultimately how many complex multiplications are therefore required for this Fast Fourier Transform (FFT)? For 'big data' applications requiring a DFT on a billion data values, what speed-up factor can be expected by using an FFT instead of explicitly computing a DFT? [4 marks] (c) Piecewise continuous and absolutely integrable functions f(x), g(x) : R C have Fourier transforms F() and G(), respectively. Let h(x) = (f g)(x) be the convolution of f(x) and g(x): h(x) = Z f(x y)g(y)dy Prove that H(), the Fourier transform of h(x), is simply the product: H() = 2F()
(a) (i) State the central limit theorem. [2 marks] (ii) Consider a binomially distributed random variable T with parameters Bin(n,p) where n is a positive integer and 0 < p < 1. Using the central limit theorem derive an approximation to the probability P(T > d) where d (0, n) and where n is sufficiently large. [4 marks] (b) Let (Xn)n1 be a Markov chain on the states {0, 1, 2} with transition matrix P = 0 0 1 0 1 1 0 where 0 < < 1. (i) Draw the state space diagram for the Markov chain Xn. [2 marks] (ii) Explain why Xn is an irreducible, recurrent and aperiodic Markov chain. [6 marks] (iii) Define an equilibrium distribution = (0, 1, 2) for the Markov chain Xn and determine . [6 marks]
Describe an O(n log(n)) algorithm based on a variation of merge sort to fifind the
closest pair of a given set of points lying in a plane. You may assume that the set
of points is given as a linked list of (x, y) coordinates. [8 marks]
Carefully prove that your algorithm can never take longer than O(n log(n)).
[6 marks]
Modify, with explanation, your algorithm to fifind the pair of points with minimum
Manhattan distance. The Manhattan distance between points (x1, y1) and (x2, y2)
is |x1 x2| + |y1 y2|. [6 marks]
1
[TURN OVERCST.2000.6.2
2 Computer Design
Why are the following statements fallacies?
(a) MIPS is an accurate measure for comparing performance among computers.
[5 marks]
(b) A benchmark is a typical program which accurately predicts the performance
of all other applications. [5 marks]
(c) Complex instruction set computers minimise the semantic gap between
machine code and high-level languages, thereby making applications run more
quickly. [5 marks]
(d) Data caches always improve processor throughput. [5 marks]
3 Digital Communication I
Compare circuit switching and packet switching, paying attention to channel
characteristics and resource effiffifficiency. [7 marks]
What is wave division multiplexing (WDM)? Is it more like circuit switching or
packet switching and why? [7 marks]
Wave length conversion is the process, either optical or optical-electronic-optical,
of receiving a signal on one wavelength and transmitting on another.
How does wave length conversion ease the problem of routing optical carriers in a
network? [3 marks]
"The huge capacity of WDM systems will mean that IP becomes redundant."
Discuss. [3 marks]
2CST.2000.6.3
4 Computer Graphics and Image Processing
Give an algorithm for drawing the part of a circle which lies in the fifirst octant.
Assume that the circle has integer radius and is centered at the origin. Assume
that you have a function setpixel(x, y) which turns on pixel (x, y). [10 marks]
Derive a matrix, or a product of matrices, to perform a clockwise 2D rotation of
arbitrary angle, , about an arbitrary point, (xc, yc). [4 marks]
Provide an algorithm to ascertain whether the Bezier curve defifined by P1P2P3P4
lies within some tolerance, , of the straight line segment, P1P4, which joins the
Bezier curve's end points. Your algorithm must return false if the Bezier curve is
outside the tolerance; it must return true if the curve is well inside the tolerance;
it may return either true or false if the curve is inside, but not well inside, the
tolerance. [6 marks]
SECTION B
5 Comparative Programming Languages
Give a brief summary of the main syntactic constructs found in the programming
language Smalltalk. Other languages often have the conditional constructs
if-then-else and while. Show how these two constructs can be defifined in Smalltalk.
[8 marks]
Illustrate the use of Smalltalk by showing how you would defifine a method to
compute the factorial of an integer. [8 marks]
Although Smalltalk was originally designed to be an interpretive language, modern
implementations are dramatically more effiffifficient. Brieflfly outline what techniques
might have been used to make this improvement. [4 marks]
3
[TURN OVERCST.2000.6.4
6 Compiler Construction
Describe how a parse tree can be translated into a sequence of assembly language
instructions based on a pattern matching graph derived from a set of tree rewriting
rules where each rule has a cost and a corresponding fragment of code. Illustrate
your answer using the following rules:
Ri = Kk LDI Ri,Kk Cost 2
Ri = add(Ri,Kk) ADDI Ri,Kk Cost 3
Ri = add(Ri,Rj) ADD Ri,Rj Cost 3
Ri = add(Ri,add(Rj,Kk)) ADD Ri,Rj,Kk Cost 4
applied to the following parse tree:
add(K1,add(add(K2,add(K3,K4)),add(K5,K6)))
[15 marks]
Discuss the advantages and disadvantages of this approach to code generation.
[5 marks]
7 Prolog for Artifificial Intelligence
One of the regulations of the International Rugby Board (IRB) states that for a
player to be eligible to play for a given country, the player's father or mother or
grandfather or grandmother must have been born in that country. Assume that
there is a complete genealogical database consisting of Prolog clauses of the form
person(P, B, F, M), where P is a person's name, B is the country of P's birth, F is
their father's name and M is their mother's name. For example, the clause
person(bruce, australia, rhodri, bronwyn).
might appear in such a database. Further assume that names in the database are
constructed so as to refer uniquely to individuals. Write Prolog clauses defifining
the predicate eligible such that goals of the form eligible(P,C) succeed if and only if
person P is eligible to play for country C according to the above regulation.
[10 marks]
Given a list of players on a given country's team, defifine a predicate checkteam
that will check each member of the team for eligibility according to the eligible
predicate, and furthermore check that each player appears on the list only once.
The checkteam goal will fail if any player is ineligible or if any player is listed more
than once. [10 marks]
4CST.2000.6.5
8 Databases
Describe the basic architecture of the ODMG standard for Object Data
Management. [10 marks]
What support is provided for transactions? What locking modes are available, and
how are they used by the database runtime systems? [4 marks]
The query language OQL is recognised as a standard by the Object Management
Group (OMG). To what extent is it similar to SQL, and in what ways does it
diffffer? [6 marks]
SECTION C
9 Semantics of Programming Languages
What does it mean to say that two confifigurations of a labelled transition system
are bisimilar? [3 marks]
Describe a labelled transition system for a language of communicating processes
with input prefifixing (c(x). P), output prefifixing (
ch Ei . P), an inactive process (0),
choice (P + P0 ), parallel composition (P|P0 ) and channel restriction ( c . P). You
may assume there is a relation E n which defifines when an integer expression E
evaluates to an integer n. [7 marks]
For each of the following pairs of processes, say whether or not they are bisimilar.
Justify your answer in each case.
(a)
ch 1i .((
ch 2i . 0) + (
ch 3i . 0)) and (
ch 1i . ch 2i . 0) + (
ch 1i . ch 3i . 0) [4 marks]
(b) P and c .((c(x). 0)|(
ch 1i . P)), where c does not occur in P
[6 marks]
10 Foundations of Functional Programming
Give as simple a set of rules as you can for transforming lambda calculus to a form
where there are no bound variables mentioned, but where there are many instances
of the three standard combinator constants S, K and I. [6 marks]
Describe tree-rewrites suitable for reducing expressions written in terms of
combinators. [6 marks]
Explain how you might deal with the issue of keeping track of the values of bound
variables if you were to interpret lambda calculus directly. [8 marks]
5
[TURN OVERCST.2000.6.6
11 Logic and Proof
For each of the given pairs of terms, give a most general unififier or indicate why
none exists. (Here x, y, z are variables while a, b are constant symbols.)
h(x, y, x) and
h(y, z, u)
h(x, y, z) and
h(f(y), z, x)
h(x, y, b) and
h(a, x, y)
h(x, y, z) and
h(g(y, y), g(z, z), g(u, u))
[4 marks]
A standard unifification algorithm takes a pair of terms t1 and t2 and returns a
substitution such that t1 = t2. Show how this algorithm can be used to fifind
the unififier of several (n > 2) terms t1, t2, . . . , tn: a substitution such that
t1 = t2 = = tn. Indicate how the unififier is constructed from the unififiers
of n 1 pairs of terms. (Assume that all required unififiers exist and ignore the
question of whether the unififiers are most general.) [6 marks]
Prove using resolution the formula
(a) State what is meant by a directed graph and a strongly connected component.
Illustrate your description by giving an example of such a graph with 8 vertices
and 12 edges that has three strongly connected components. [5 marks]
(b) Describe, in detail, an algorithm to perform a depth-fifirst search over such a
graph. Your algorithm should attach the discovery and fifinishing times to each
vertex and leave a representation of the depth-fifirst spanning tree embedded
within the graph. [5 marks]
(c) Describe an O(n) algorithm to discover all the strongly connected components
of a given directed graph and explain why it is correct. You may fifind it useful
to use the concept of the forefather (v) of a vertex v which is the vertex, u,
with highest fifinishing time for which there exists a (possibly zero length) path
from v to u. [10 marks]
2 Computer Design
(a) What is a data cache and what properties of data access does it exploit?
[5 marks]
(b) What is a direct mapped cache and under what conditions will it exhibit poor
performance? [5 marks]
(c) Under what circumstances might a word of data in main memory be
simultaneously held in two separate fifirst-level cache lines? [5 marks]
(d) A translation look aside buffffer is a specialised cache. What does it typically
store and why is it often a factor of 1000 smaller than a data cache? [5 marks]
2CST.2001.6.3
3 Digital Communication I
(a) Defifine the terms circuit and packet in the context of communication systems.
[5 marks]
(b) What sort of guarantee does circuit switching provide? [5 marks]
(c) What advantages does packet switching provide over circuit switching?
[5 marks]
(d) Which of frequency division multiplexing, time division multiplexing and code
division multiplexing lend themselves to circuit switching? Which to packet
switching? Explain why or why not in each case. [5 marks]
4 Computer Graphics and Image Processing
(a) Describe the z-buffffer polygon scan conversion algorithm. [10 marks]
(b) In ray tracing, once we have determined where a ray strikes an object, the
illumination at the intersection point can be calculated using the formula:
I = Iaka +X
i
Iikd(Li N) +X
i
Iiks(Ri V)n
Explain what real effffect each of the three terms is trying to model and explain
what each of the following symbols means, within the context of this formula:
I, Ia, i, Ii , ka, kd, ks,Li, N, Ri, V, n
[10 marks]
3
[TURN OVERCST.2001.6.4
SECTION B
5 Comparative Programming Languages
(a) Brieflfly explain the concept of coroutines as used in BCPL and outline
the effffect of the library functions createco(f, size), deleteco(ctpr),
callco(cptr, val) and cowait(val). [10 marks]
(b) Outline how you would design a coroutine to merge, in increasing order, two
infifinite streams of increasing integers supplied by two other coroutines.
[5 marks]
(c) Brieflfly outline how you would implement an analogous merging mechanism in
an object-oriented language, such as Java, that does not provide a coroutine
mechanism. [5 marks]
6 Compiler Construction
(a) Describe one possible structure (e.g. ELF) of an object fifile. Illustrate your
answer by considering the form of object fifile which might result from the
following C program.
int a = 1, b = -1;
extern int g(int);
extern int c;
int f() { return g(a-b) + c; }
It is not necessary to consider the exact instruction sequence, just issues
concerning its interaction with the object fifile format. [10 marks]
(b) Describe how a linker takes a sequence of such programs and produces an
executable fifile. [4 marks]
(c) Compare and contrast static and dynamic linking in a system using your object
fifile format. [6 marks]
4CST.2001.6.5
7 Prolog for Artifificial Intelligence
A weighted binary tree can be defifined using compound terms in the following way.
A node of the tree is represented by the term n(V, L, R), where V stands for the
value of the node, and L and R stand for the left and right branches, respectively.
A terminal node has the R and L components instantiated to the null list.
Given an input tree T, write a Prolog program that constructs a tree of the same
shape as T, but in which the value of each node has been set to the value of the
maximum value node in T.
[Note: Maximum marks are available only for programs that perform this task in
one recursive descent of the input tree, and which use no more than four clauses.]
[20 marks]
5
[TURN OVERCST.2001.6.6
8 Databases
The environmental agency is setting up an SQL database to monitor long-term
trends in the climate. Data are collected from observatories of a number of difffferent
kinds.
Flood risk is of particular concern. Each water authority measures river levels and
rates of flflow hourly at major points, and records reservoir levels daily.
In addition, the agency maintains weather stations both inland and at sea. These
record precipitation (rainfall etc.), temperature, sunshine, air pressure and wind.
Values of new precipitation, temperature, pressure, and wind speed and direction
are taken hourly; gusts of over 60 m.p.h. are noted whenever they occur.
Maximum and minimum temperature and pressure, the total number of hours of
sunshine and the total precipitation are recorded daily. Inland stations can be
grouped by water authority.
By default these primary data will be relegated to archive after 2 years. Selected
information is retained permanently in a data warehouse. This serves two purposes.
First, it holds monthly summary data consisting of the maximum (and minimum
as appropriate) day value for each statistic, together with the monthly totals of
sunshine and precipitation. The warehouse also keeps detailed information relating
to periods of extreme weather from the relevant observatories, with one or more
keywords describing the nature of the incident (flflood, blizzard, hurricane etc.) and
an optional comment.
Write notes to assist in the design of the schema for the relational data warehouse,
including any diagrams that you fifind helpful. Explain how your design will enable
meteorologists to fifind relevant past records, noting any assumptions that you make
about the nature of the data.
[You should not go into unnecessary detail about the structure of the primary
database. You may assume that expert meteorologists will select the data for the
warehouse.]
[20 marks]
6CST.2001.6.7
SECTION C
9 Semantics of Programming Languages
Write short notes on four of the following fifive topics.
(a) The relationship between three forms of operational semantics of the Language
of Commands (LC) given by
an evaluation relation h P, si hV, s0 i
a transition relation h P, si hP0 , s0 i
a transition relation between the confifigurations
h c, r, si of the
SMC-machine
(b) The notion of semantic equivalence of LC phrases and its congruence property.
(c) Call-by-name and call-by-value rules for evaluating function applications in the
Language of Functions and Procedures (LFP) and the relationship between the
evaluation relations for LFP based upon each of them.
(d) The notion of bisimilarity of two confifigurations in a labelled transition system.
(e) The rules defifining the possible labelled transitions of parallel composition
(P1|P2) and restriction ( c . P) in the Language of Communicating Processes
(LCP).
[5 marks each]
7
[TURN OVERCST.2001.6.8
10 Foundations of Functional Programming
The following are some concepts that have flflourished in the context of functional
programming but which have (so far) been less heavily used in main-stream
languages even when they have been available:
(a) polymorphic types
(b) type reconstruction
(c) higher-order functions
(d) lazy evaluation
(e) continuations
For each case give a brief explanation of the facility referred to, suggest a
circumstance in which it might be useful and comment on how immediately relevant
to non-functional languages it seems.
[4 marks per part]
8CST.2001.6.9
11 Logic and Proof
(a) In the context of clause-based proof methods, defifine the notion of pure literal
and describe what should be done if the set of clauses contains pure literals.
[3 marks]
(b) Use the Davis-Putnam method to discover whether the following set of clauses
is satisfifiable. If they are satisfifiable, show a satisfying interpretation.
{P, R} {P, R} {P, Q} {Q, R} {P, Q, R}
[6 marks]
(c) The three-fifingered inhabitants of the planet Triterra build base-3 computers.
A Triterran named Randal Tryant has found a way of verifying base-3
combinational logic. His Ordered Ternary Decision Diagrams (OTDDs) are
the same as a technology used on planet Earth except that all variables and
expressions range over the values 0, 1 and 2 instead of just 0 and 1.
(i) Describe how a full ternary decision tree can be reduced to an OTDD
without regard for effiffifficiency. [2 marks]
(ii) Sketch an effiffifficient algorithm to convert a ternary expression directly to an
OTDD without constructing the full decision tree. For a typical ternary
connective use modulo-3 multiplication, written as . [6 marks]
(iii) Demonstrate your algorithm by applying it to the ternary expression
((i i) j) 2. [3 marks]
9
[TURN OVERCST.2001.6.10
12 Complexity Theory
(a) Show that any language that can be accepted by a nondeterministic machine
in time f(n) can also be decided by a deterministic machine in space O(f(n)).
[4 marks]
(b) Show that any language that can be accepted by a nondeterministic machine
in space f(n) can also be decided by a deterministic machine in time
O(c(f(n)+log n) ), for some constant c. [6 marks]
(c) Explain what the above results tell us about the inclusion relationships among
the complexity classes:
NL, co-NL, P, NP, PSPACE and NPSPACE
[4 marks]
(d) It has been proved that the graph reachability problem is in co-NL. What
further inclusions can you derive among the above complexity classes using
this fact? Explain your answer. [6 marks]
(a) Suppose you have a randomised approximation algorithm for a maximisation
problem such that, for any > 0 and any problem instance of size n, the
algorithm returns a solution with cost C such that
Pr[C (1 1/) C] 1/n exp(1/),
where C is the cost of the optimal solution. Can you use your algorithm to
obtain a PTAS or FTPAS? Justify your answer. [6 marks]
(b) We consider the following optimisation problem. Given an undirected graph
G = (V, E) with non-negative edge weights w : E R+, we are looking for an
assignment of vertex weights x : V R such that: (i) for every edge {u, v} E,
x(u) + x(v) w({u, v}), (ii) P vV x(v) is as small as possible.
(i) Design a 2-approximation algorithm for this problem. Also analyse the
running time and prove the upper bound on the approximation ratio.
Note: For full marks, your algorithm should run in at most O(E2 ) time.
Hint: One way to solve this question is to follow the approach used by the
greedy approximation algorithm for the VERTEX-COVER problem.
[8 marks]
(ii) Can this problem be solved exactly in polynomial-time? Either describe
the algorithm (including a justifification of its correctness and why it is
polynomial time) or prove that the problem is hard via a suitable reduction.
[6 marks]
You are tasked with implementing a recursive function void distanceFrom(int key) on the IntList clasS (provided). The function will first search through the list for the proVided key, and then, recursively, change all previous values in the list to instead be their distance from the node containing the key value. Do not update the node containing the key value or any nodes after it. If the key does not exist in the list, each node should contain its distance from the end of the list. Example 11 list: 5->7->3->2->1->4 list.distanceFrom (2); list: 3->2->1->2 ->1->4 Example 2 list: 5->7->3->2->1->4 list.distanceFrom (6); list: 6->5->4-53->2->1 The function must be recursive, you are not allowed to use any kind of loop. You also may NOT use global or static variables.
#include
testi.distancerroOm(6), cout << "After: " << test1 << endl; I/ Test exists function if (testNum == 2){ Intlist test2 test2.push_front(-3); test2.push_front[8); test2.push_front(10); test2.push_front(-42); test2.push_front(3); test2.push_front(58); cout << "Key is -3" << endl; cout << "Before:" << test2 << endl; test2.distanceFrom(-3); cout << "After: " << test2 << endl; return 0; IntList.h
FitndefNTUISIH_ #defineINTLIST_H #include
private: IntNode *head; public: * Initializes an empty list. Intlist): head (nullptr) 0 /* Inserts a data value to the front of the list. void push_frontint val) { if (head) { head = new IntNode(val); else { IntNode *temp = new IntNode(val); temp->next = head; head temp; /* Outputs to a single line all of the int values stored in the list, each separated by a space. This function does NOT output a newline or space at the end.
* Outputs to a single line ll of the int values stored in the list, each separated by a space. This function does NOT output a newline or space at the end. friend ostream & operator< <(ostream &out, const IntList &rhs) { if (rhs.head){ IntNode "Curr = rhs.head; out << curr->data; for (curr = Curr-> next; curr; curr = curr->next) rn out * Update all nodes previous to the node containing the passed in integer to be the distance from that node (1 for the node directly preceding it) No return value. Works by callinga recursive function (defined below). void distanceFrom(int);
(1 for the node directly preceding it) No return value. Works by calling a recursive function (defined below). void distanceFrom(int); private: * Recursive helper functions that will (1) find the key passed in and then (2) recursively update the nodes preceding it to contain their distance from the node containing the key. If the key is not found, update with the distance from the end, with the last node having the value of 1. / int searchAndModify(IntNode , int; #endit IntList.cpp (help with this part) #include "Intlist.h void IntList::distanceFromint key) {
(2) recursively update the nodes preceding it to contain their distance from the node containing the key. If the key is not found, update with the distance from the end, with the last node having the value of 1. int searchAndModify(intNode , int); #endif Intlist.cpp (help with this part) #include "IntList.h" void IntList:distanceFrom(int key) { int Intlist:searchAnd Modify(IntNode "cur, int key) { return 0;
import java.io."; import java.util.Scanner, public class CrimeStats { private static final String INPUT_FILE = "seattle-crime-stats-by-1990-census-tract-1996-2007.csv"; private static final String OUTPUT FILE = "crimes.bxt"; public static void main(String] args) {int totalCrimes = 0;// read all the rows from the csv file and add the total count in the totalCrimes variable try { Scanner fileScanner = new Scanner(new File(INPUT_FILE); String line = fileScanner.nextLine|); l/ skip first line while (fileScanner.hasNext0) { String| tokens = fileScanner.nextLine).split(", "); if (tokens.length = = 4) { totalCrimes + Integer.parselnt(tokens[B].trim0);}} fileScanner.close0; } catch (FileNotFoundException e){ System.out.printin('Unable to read data from file:" + INPUTFILE); System.exit(1); } try { PrintWriter writer = new PrintWriter(new FileWriter(OUTPUT_FILE); writer.write(String.format("Total Crimes: %d", totalCrimes); writer.flush0; writer.close0: System.out.printin("File :" +OUTPUT_FILE + " updated successfully."); } catch (1OException e) { System.outprintin("'Unable to write to file: " + OUTPUT_FILE); }} Unable to read data from file: seattle-crime-stats-by-1990-census-tract-1996-2007.csv CAUsersmikec AppData\ Local\NetBeans\ Cache\8.2rc)executor-snippets un.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds) I keep getting this error how doi fix it
kindly answer all the question
Chemistry The Central Science
ISBN: 978-0321696724
12th edition
Authors: Theodore Brown, Eugene LeMay, Bruce Bursten, Catherine Murphy, Patrick Woodward