Find Jobs
Hire Freelancers

Programming answers/ description needed for the question

$10-15 USD

Κλειστή
Αναρτήθηκε πάνω από 3 χρόνια πριν

$10-15 USD

Πληρωμή κατά την παράδοση
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. 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/2 void 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.
Ταυτότητα εργασίας: 27935845

Σχετικά με την εργασία

7 προτάσεις
Απομακρυσμένη Εργασία
Ενεργός/ή 3 χρόνια πριν

Ψάχνεις τρόπο για να κερδίσεις μερικά χρήματα;

Πλεονεκτήματα πλειοδοσίας στο Freelancer

Καθόρισε τον προϋπολογισμό σου και το χρονοδιάγραμμα
Πληρώσου για τη δουλειά σου
Περίγραψε την πρόταση σου
Η εγγραφή και η πλειοδοσία σε εργασίες είναι δωρεάν
7 freelancers δίνουν μια μέση προσφορά $14 USD για αυτή τη δουλειά
Avatar Χρήστη
I, Jignesh Lakhani completed masters from IIT Roorkee, I have very good knowledge of C, C++, data structures, and algorithms. I can complete your work in deadline. feel free to contact me thank you
$20 USD σε 1 ημέρα
4,9 (45 αξιολογήσεις)
6,2
6,2
Avatar Χρήστη
Hello, I read your job offer regarding the c programming and I'm ready to start right away. I am also flexible with whatever budget you have. Accuracy and client's satisfaction is the top priority. Awaiting your response. Thanks!
$10 USD σε 1 ημέρα
4,7 (33 αξιολογήσεις)
4,9
4,9
Avatar Χρήστη
Hi! I am an expert in C, C++ and data structures. I would be easily able to help you regarding any task related to them. Kindly message me to discuss more details. Thank you!
$10 USD σε 1 ημέρα
5,0 (31 αξιολογήσεις)
4,1
4,1
Avatar Χρήστη
Hi; i can help you Now (immediately) send me a message so that we can discuss more thks -------- thanks
$10 USD σε 1 ημέρα
4,9 (10 αξιολογήσεις)
3,3
3,3
Avatar Χρήστη
Hi, I'm an experienced developer and have hands-on experience working on various data structures/algorithm projects. I clearly understand your project requirements and can help me out. Let me know.
$15 USD σε 1 ημέρα
5,0 (1 αξιολόγηση)
2,1
2,1
Avatar Χρήστη
Dear Sir, I hope you are fine. I have just read your job description and understood all requirements properly. I am a professional and experienced Programmer having over 7 years of extensive experience in the IT industry. I can do that task for you with 100% satisfaction as customer satisfaction is my satisfaction. Looking forward to hearing from you. Thank you. Regards, Amaan Malik
$20 USD σε 3 ημέρες
4,8 (2 αξιολογήσεις)
2,0
2,0
Avatar Χρήστη
I know very good C and i can deliver it very fast with a low cost. Also I can provide explanations as it asks in the problems.
$10 USD σε 1 ημέρα
0,0 (0 αξιολογήσεις)
0,0
0,0

Σχετικά με τον πελάτη

Σημαία της OMAN
Mutrah, Oman
4,9
432
Επαληθευμένη μέθοδος πληρωμής
Μέλος από Νοε 17, 2009

Επαλήθευση Πελάτη

Ευχαριστούμε! Σου έχουμε στείλει ένα email με ένα σύνδεσμο για να διεκδικήσεις τη δωρεάν πίστωση σου.
Κάτι πήγε στραβά κατά την προσπάθεια αποστολής του email σου. Παρακαλούμε δοκίμασε ξανά.
Εγγεγραμμένοι Χρήστες Συνολικές Αναρτημένες Δουλειές
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Φόρτωση προεπισκόπησης
Δόθηκε πρόσβαση για Geolocation.
Η σύνδεση σου έχει λήξει και τώρα έχεις αποσυνδεθεί. Παρακαλούμε συνδέσου ξανά.