Find Jobs
Hire Freelancers

Urgent solutions needed

$10-30 USD

Lezárt
Kiadva ekkor: több mint 3 évvel ezelőtt

$10-30 USD

Teljesítéskor fizetve
Problem 1 [9pt] Consider the following C program: int SumOfSquares(int n) { if (n <= 0) return 0; else return n*n+SumOfSquares(n-1); } a) (5pt) Write down a tail recursive implementation of function SumOfSquares in C language. You can use helper function in your solution. b) (4pt) An “optimizing” compiler will often be able to generate efficient code for recursive functions when they are tail-recursive. Refer to activation record, briefly explain how a compiler may “reuse” the same activation record for your solution in a). Problem 2 [6pt] In early implementations of Fortran language, a compiler may choose to use static allocation (i.e., allocation in the static area) for local variables and parameters, effectively arranging for the variables of different invocations to share the same locations, and thereby avoiding any run-time overhead for creation and destruction of stack frames. However, such an implementation changes the meaning of recursive function calls. Write down a simple example and explain how its meaning changes under the “Fortran” semantics as stated above, compared with standard semantics found in language like C, Python, Java. Problem 3 [6pt] Suppose as a language designer, you plan to implement a feature called “output-only” parameters. The expected semantics is that all output-only parameters are uninitialized when the callee starts execution; they can be used (both read and write) as other kinds of parameters within the callee; finally, the corresponding actual parameter in the caller is updated to the final values of the “output-only” parameters. Briefly describe one possible implementation of such “output-only” parameters. Problem 4 [16pt] Consider the following C-like program. Write down what will be printed out when the parameters are passed (1) by value, (2) by reference, (3) by value return and (4) by name. For each answer, briefly explain how did you derive it. Answers without a brief explanation will receive ZERO points. int x=5, y=6; void foo(int a, int b) { x = a+b; b = a+a; } main () { foo(x,y); print x, y; } Problem 5 [13pt] Consider the following code snippet with exceptions. Note that the main function calls foo in the nested try block. 1/2void foo () { try { throw new Exception1(); print ("A"); throw new Exception2(); print ("B"); } catch(Exception1 e1) { print "handler1"; } print ("C"); throw new Exception2(); } void main () { try { try { foo(); print ("D"); } catch(Exception1 e1) { print "handler2"; } } catch(Exception2 e2) { print "handler3"; } } a) (6pt) Write down what will be printed out by the program and briefly justify your answer. b) (7pt) Instead of the “replacement” semantics of exception handling used in modern languages (i.e., the semantics introduced in lecture), a very early design of exception handling introduced in the PL/I language uses a “binding” semantics. In particular, the design dynamically tracks a sequence of “catch” blocks that are currently active; a catch block is active whenever the corresponding try block is active. Moreover, whenever an exception is thrown, the sequence of active “catch” blocks will be traversed (in a first-in-last-out manner) to find a matching handler. Furthermore, execution will resume at the statement following the one that throws exception, rather than the next statement after the matching “catch” block as we have seen in the “replacement” semantics. Write down what will be printed out by the program if the language uses the “binding” semantics, and briefly justify your answer.
Projektazonosító: 27960440

A projektről

3 ajánlat
Távolról teljesíthető projekt
Aktiválva: 3 évvel ezelőtt

Szeretne pénzt keresni?

A Freelancer oldalán történő árajánlatadás előnyei

Határozzon meg költségvetést és időkeretet
Kapja meg fizetését a munkáért
Vázolja ajánlatát
Ingyen regisztrálhat és adhat árajánlatot munkákra
3 szabadúszó adott átlagosan $30 USD összegű árajánlatot erre a munkára
Felhasználó avatár
Hi, How are you today? Thank you for posting this project, and I'm very happy to bid your project. I've read carefully your project details. I have rich experiences related with your project. Your satisfaction with the project is my top priority! If you give me a chance to work with you, then I will do my best to reach your requirements!.! I'm waiting for your kind response. Please send msg over chat. Let's go. I will do my best for you. Best Regards.
$19 USD 1 napon belül
5,0 (26 értékelés)
4,0
4,0
Felhasználó avatár
Hi Dear, I read your description carefully. I understood what you require me to do and I am filled with confidence that I can complete your project wonderfully. I have experience over 5+ years with C/C++/C# and etc. I ensure: => The Best Quality, => The Shortest Time. If you give me a chance, I will do my best to complete this project for us. I can complete this project with the best quality in time. I hope your kind reply. Best Regards. Chian Y.
$20 USD 1 napon belül
5,0 (6 értékelés)
3,1
3,1
Felhasználó avatár
Hello, I hope that you find my profile as the right one for you. I have been coding java since 2013. Data structures and algorithms are daily job for me. Also, I am a programming instructor, teaching C, C++, Java and data structures & algorithms courses. We can discuss about price if you inform me exactly about what you need, so maybe I can propose another price. Thank you!
$50 USD 1 napon belül
5,0 (2 értékelés)
2,3
2,3

Az ügyfélről

OMAN zászlója
Mutrah, Oman
4,9
433
Fizetési mód hitelesítve
Tagság kezdete: nov. 17, 2009

Ügyfél-hitelesítés

Köszönjük! E-mailben elküldtük a linket, melyen átveheti ajándék egyenlegét.
E-mailje elküldése során valami hiba történt. Kérjük, próbálja újra.
Regisztrált Felhasználók Összes Közzétett Munka
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Előnézet betöltése
Hozzáférést adott a helymeghatározáshoz.
Belépési munkamenete lejárt, és kijelentkeztettük. Kérjük, lépjen be újra.