Computer Science > EXAM > Arizona State UniversityCSE 340CSE340_S14_Final_Solution (All)

Arizona State UniversityCSE 340CSE340_S14_Final_Solution

Document Content and Description Below

Arizona State University Computer Science and Engineering CSE 340 - Spring 2014 Final Exam. Solution NAME: The following should be signed when you hand in your paper. I give my word of honor and... solemnly swear that I did not violate the academic integrity policy in answering the questions of the exam Read everything carefully. Some statements can be tricky. Not all questions have equal weight. 1[ 5 points ] Consider the following C declarations: struct G; // declaration struct F { int y; struct D* next; }; struct E { int x; struct F next; }; struct D { int x; struct E next; }; struct H { int x; int (*next)(struct G); // pointer to a function that takes // struct G as parameter and returns int }; struct G { // definition float x; struct H next[10]; }; Assume that the size of a structure is the sum of the sizes of its fields and an int fields requires 6 bytes of space, a pointer field requires 4 bytes of space and a float field requires 8 bytes of space. Write your answer in the box: 1. sizeof(D) = 22 (int + struct E) 2. sizeof(E) = 16 (int + struct F) 3. sizeof(F) = 10 (int + pointer) 4. sizeof(G) = 8 (float) + 10*10 (array of struct H) = 108 5. sizeof(H) = 10 (int + pointer) 2[15 points ] Consider the following function definition func f(a,b,c,d) = if c(c(a,b),b) then d[b] else c Assuming Hindley-Milner type inference is done, fill in the blank for each of the following (assume arithmetic can only be done on numeric types int or real). You can parametrize you answer with polymorphic types, but you should use the names of the types consistently for the various answers. Answer: 1. Ta = bool 2. Tb = int 3. Tc = bool (*) (bool, int) 4. Td = array of bool(*)(bool, int) 5. Tf = bool (*)(bool,int) (*) (Ta, Tb,Tc,Td) 3[15 points] Consider the following C code struct T { [Show More]

Last updated: 1 year ago

Preview 1 out of 18 pages

Add to cart

Instant download


Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

Reviews( 0 )


Add to cart

Instant download

Can't find what you want? Try our AI powered Search



Document information

Connected school, study & course

About the document

Uploaded On

Aug 29, 2021

Number of pages


Written in



Member since 3 years

102 Documents Sold

Additional information

This document has been written for:


Aug 29, 2021





Document Keyword Tags

Recommended For You

Get more on EXAM »

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 Questions? Leave a message!

Follow us on

Copyright © Browsegrades · High quality services·