DATA STRUCTURES, ANALYSIS OF ALGORITHMS AND COMPUTATIONAL COMPLEXITY
a) Draw the BST after the insertion of the keys.
b) Code an ITERATIVE function called "find" in the language of your choice. The function should return a pointer to the node containing a specified key. If the key is not found, then return NULL. Also, declare your data structure. The signature (prototype) in C: tree_ptr find(int x, tree_ptr p).
c) Code a RECURSIVE version of the function.
COMPUTER ARCHITECTURE AND OPERATING SYSTEMS
Producer: Consumer:
while (true) { while (true) {
while (counter == N) {} // empty loop body while (counter == 0) {} // empty loop body
buffer[in] = ch; // produced character ch = buffer[out]; // consumed character
in = (in + 1) % N; out = (out + 1) % N;
counter = counter + 1; counter = counter - 1;
} }
Assume that global shared variables have current values: N=2, counter=1, out=0, in=1. Describe an execution sequence such that the Producer thinks the buffer is full when, in fact, the buffer is not full, thus illustrating the faulty code. Use any combination of description, diagrams, charts, etc. to help describe the execution sequence.
PROGRAMMING LANGUAGES AND COMPILER DESIGN
b) What are the particular advantages or disadvantages of interpretation versus compilation?
c) Are all languages either compiled or interpreted? Explain.
d) Some languages support multiple-inheritance and others (like Java) do not. Explain the advantages and disadvantages of multiple inheritance.
http://server http://server.company.com http://server.company.com/ http://server.division.com/dir1/dir2/myfile http://server.division.com/myfile.cgi https://server.division.company.com:80/dir1/dir2/myfile.html rmi://server.company.com/dir1/myobject
Notes:
1. server, division, company, com, dir1, dir2, myfile, myobject are examples
of the terminal id.
2. Port number (e.g. 80) is an optional num (introduced by a ":"), with at most one number following the server name.
3. Protocol (e.g. http) is mandatory.
4. Assume each server is one or more id, and is "." separated.
5. A list of directories is zero or more id, and is "/" separated, followed by an optional file name.
6. A file name may have an optional suffix (cgi or html) and, in this case only, would a "." appear in the file name.
Construct a grammar for this subset of the URL language.
a) Prove the grammar is ambiguous using the string "aaabbaa".
b) Use standard transformations to remove the common prefixes in the grammar.
c) Is the revised grammar ambiguous? Prove/disprove.
[-]
/ \
[-] [-]
/ \ / \
[a] [b] [c] [-]
/ \
[-] [f]
/ \
[d] [e]
a) Write the expression, using parentheses, which corresponds to the above DAG.
b) Write the optimized standard intermediate code assuming r=1 and count the number of statements. "Optimized" means that the number of statements should be minimal. The result should reside in register R0.
c) What is the minimum value of r required to achieve the fewest number of statements? That is, increasing r has no effect on the the number of required statements. Briefy explain.