ECE 2035 Programming HW/SW Systems Spring problems, 5 pages Exam Three 8 April Your Name (please print clearly)

Similar documents
ECE 2035 A Programming HW/SW Systems Spring problems, 5 pages Exam Three 13 April Your Name (please print clearly)

ECE 2035 Programming HW/SW Systems Fall problems, 4 pages Exam Three 14 November Your Name (please PRINT clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 19 November 2014

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 18 November 2015

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 28 November 2012

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

ECE 2035 Programming HW/SW Systems Fall problems, 5 pages Exam Three 20 November 2013

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 9 December 2015

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam Solutions 29 April 2015

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

ECE 2035 Programming Hw/Sw Systems Spring problems, 8 pages Final Exam Solutions 1 May 2013

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

Do not start the test until instructed to do so!

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

On my honor I affirm that I have neither given nor received inappropriate aid in the completion of this exercise.

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam Solutions 9 December 2015

CPSC 211, Sections : Data Structures and Implementations, Honors Final Exam May 4, 2001

COMP 524 Spring 2018 Midterm Thursday, March 1

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

Q1: /8 Q2: /30 Q3: /30 Q4: /32. Total: /100

Linked Lists in C and C++

On my honor I affirm that I have neither given nor received inappropriate aid in the completion of this exercise.

Creating a String Data Type in C

CSE 131 Introduction to Computer Science Fall 2016 Exam I. Print clearly the following information:

ECE264 Fall 2013 Exam 3, November 20, 2013

CSE 332 Autumn 2013: Midterm Exam (closed book, closed notes, no calculators)

Instructions. Definitions. Name: CMSC 341 Fall Question Points I. /12 II. /30 III. /10 IV. /12 V. /12 VI. /12 VII.

ECE 454 Computer Systems Programming

CSE351 Winter 2016, Final Examination March 16, 2016

CS 241 Data Organization Binary Trees

CSE 333 Midterm Exam 2/14/14

EE 312 Fall 2018 Midterm 1 Version A October 10, 2018

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Spring Instructions:

CS 3114 Data Structures and Algorithms READ THIS NOW!

C Programming Basics II

CSE 247 Data Structures and Algorithms Fall Exam I

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

Introduction to Computer Systems. Exam 2. April 10, Notes and calculators are permitted, but not computers.

Comp Sci 1MD3 Mid-Term II 2004 Dr. Jacques Carette

CPSC 311: Analysis of Algorithms (Honors) Exam 1 October 11, 2002

Do not start the test until instructed to do so!

Common Misunderstandings from Exam 1 Material

Computer Science Foundation Exam

CSL 201 Data Structures Mid-Semester Exam minutes

Signature: ECE 551 Midterm Exam

Introduction to Linked Lists

CSE373 Fall 2013, Final Examination December 10, 2013 Please do not turn the page until the bell rings.

11 'e' 'x' 'e' 'm' 'p' 'l' 'i' 'f' 'i' 'e' 'd' bool equal(const unsigned char pstr[], const char *cstr) {

MARKS: Q1 /20 /15 /15 /15 / 5 /30 TOTAL: /100

CSE 131 Introduction to Computer Science Fall Exam II

CMPT 225. Lecture 6 linked list

2. dead code elimination (declaration and initialization of z) 3. common subexpression elimination (temp1 = j + g + h)

a) Write the signed (two s complement) binary number in decimal: b) Write the unsigned binary number in hexadecimal:

Kurt Schmidt. May 3, 2017

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam

ECE551 Midterm. There are 7 questions, with the point values as shown below. You have 75 minutes with a total of 75 points. Pace yourself accordingly.

CS61C : Machine Structures

Ashish Gupta, Data JUET, Guna

COP 3502 (Computer Science I) Test #1 Date: 9/13/2013. First Name:, Last Name:

ECE 2400 Computer Systems Programming Fall 2018 Topic 6: C Dynamic Allocation

CS 2505 Computer Organization I Test 1. Do not start the test until instructed to do so! printed

CS 2461: Computer Architecture I: Heap: Dynamic Memory Allocation Data Structures. Recap. Variables and Structures

Programming and Data Structure Solved. MCQs- Part 2

In Java we have the keyword null, which is the value of an uninitialized reference type

Do not start the test until instructed to do so!

C0MP1921/2011/2091 SAMPLE Final Exam Data Structures and Algorithms/Data Organisation/Computing 2

BBM 201 DATA STRUCTURES

University of California, Berkeley College of Engineering

ECE 2030D Computer Engineering Spring problems, 5 pages Exam Two 8 March 2012

You have 90 minutes to complete the exam of InformatikIIb. The following rules apply:

CS 2505 Computer Organization I Test 1. Do not start the test until instructed to do so! printed

CSE 333 Midterm Exam 7/27/15 Sample Solution

CP2 Revision. theme: dynamic datatypes & data structures

CS 111X - Fall Test 1

COP 3502 Section 2 Exam #2 Version A Spring /23/2017

Solution printed. Do not start the test until instructed to do so! CS 2604 Data Structures Midterm Summer I Instructions:

COP 3223 Introduction to Programming with C - Study Union - Fall 2017

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

CSE 131 Introduction to Computer Science Fall Exam I

Class Information ANNOUCEMENTS

DATA STRUCTURES AND ALGORITHMS

CSE 373 Spring 2010: Midterm #1 (closed book, closed notes, NO calculators allowed)

Data Structure Series

CSE 131 Introduction to Computer Science Fall Exam I

COS 226 Algorithms and Data Structures Fall Midterm

ECE551 Midterm Version 1

ENEE 150: Intermediate Programming Concepts for Engineers Spring 2018 Handout #27. Midterm #2 Review

Dynamic Memory Allocation and Linked Lists

CS106X Handout 35 Winter 2018 March 12 th, 2018 CS106X Midterm Examination

There are 16 total numbered pages, 7 Questions. You have 2 hours. Budget your time carefully!

Homework 3 CS161 Computer Security, Fall 2008 Assigned 10/07/08 Due 10/13/08

The combination of pointers, structs, and dynamic memory allocation allow for creation of data structures

ECE 2400 Computer Systems Programming, Fall 2017 Prelim 1 Prep

MCS 360 Exam 2 11 November In order to get full credit, you need to show your work.

Transcription:

Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions of the Honor Code. Signed 1 2 3 4 total 25 2 25 3 1 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand; do not leave your seat. Please work the exam in pencil and do not separate the pages of the exam. For maximum credit, show your work. Good Luck! 1

Problem 1 (25 points) Hash Tables Consider an open hash table composed of a four-bucket table, with each bucket containing a variable length list. Each list entry has three slots <key, value, next> corresponding to the three word groupings in the entries section. The hash function is key mod four. Inserted entries are appended to the end of a bucket list. The initial state of the hash table is shown. List elements as allocated by malloc are shown in the figure. The symbol to the left of each list element (A, B, C,...) is the address returned by malloc. Entries that are freed are maintained in a last-in-first-out (LIFO) free list. Assume the free list is initially empty. Execute the access trace shown in the table below. For ease of representation, you may use the allocated blocks in any order. Show pointers both by their (symbolic) value, and with an arrow. If a value changes, cross it out and place the new value to the right. If a pointer changes, also place an x on the corresponding arrow, and draw the new arrow. Buckets (Hash Anchor Table) 3 2 1 A B A 19 555 D G B 38 333 E H C F I Hash Table Access Trace # op key value # op key value 1 insert 2 111 5 remove 19 n/a 2 insert 35 222 6 insert 42 777 3 insert 63 444 7 insert 63 888 4 remove 2 n/a 8 insert 21 999 2

Problem 2 (3 parts, 2 points) Associative Set Performance Part A (8 points) Suppose we have an associative set of 35 (key, value) pairs implemented as an unsorted doubly linked list. An application performs 6 lookups of various keys: 48 of the lookups find the key in the list and 12 lookups fail to find the key. The keys that are found are distributed throughout the list so that each position is equally likely to be where a key is found. What is the average number of key comparisons that would be needed for a lookup in this list implementation? (Show work. Note: you may not have to use all data provided.) Part B (6 points) Suppose the associative set is reimplemented as an open hash table. The same 35 (key, value) pairs are stored in the hash table and are evenly distributed across 5 buckets, each implemented as a sorted doubly linked list. An application performs the same 6 lookups in which 48 find the key being searched for and 12 do not. The keys that are found are distributed throughout the bucket lists so that each bucket and each position in the bucket lists is equally likely to be where a key is found. What is the average number of key comparisons that would be needed for a lookup in this hash table implementation? (Show work. Note: you may not have to use all data provided.) Part C (6 points) Suppose the hash table of Part B is resized so that the same 35 entries are evenly distributed across 7 buckets. However, the buckets are implemented as unsorted doubly linked lists. As before, the application performs the same 6 lookups in which 48 find the key being searched for and 12 do not. The keys that are found are distributed throughout the bucket lists so that each bucket and each position in the bucket lists is equally likely to be where a key is found. What is the average number of key comparisons that would be needed for a lookup in this hash table implementation? (Show work. Note: you may not have to use all data provided.) 3

Problem 3 (5 parts, 25 points) Heap Management Below is a snapshot of heap storage. The heap has been allocated contiguously beginning at 6, with no gaps between objects. Heap management maintains a sorted free list to implement a best-fit strategy for reusing freed objects. The heap pointer is 6152 and the free pointer is 672. addr value addr value addr value addr value addr value addr value 6 16 632 12 664 62 696 8 6128 616 64 624 636 8 668 4 61 652 6132 4 6164 68 4 64 33 672 61 614 16 6136 632 6168 612 16 644 12 676 16 618 12 614 6172 616 36 648 16 68 128 6112 152 6144 24 6176 62 8 652 6128 684 264 6116 8 6148 618 624 38 656 1 688 4 612 16 6152 6184 628 148 66 4 692 68 6124 24 6156 6188 Part A (4 points) Assuming the heap has been allocated contiguously beginning at 6, with no gaps between objects, circle all object size words in the map above. Part B (4 points) List the address of the first data word in each object in the free list in order, starting with the head of the free list. Addresses of Objects on Free List (in order): Part C (4 points) Based on the free list created in part B, if the following statement were executed, what would be the value of the variable x? char* x = (char*)malloc(strlen( GB ) + 1); How many bytes of slack (if any) will result? (Hint: strlen computes the number of characters in a string up to but not including the terminating null character.) x Slack: Part D (6 points) Suppose the next instruction is free(ptr), where ptr = 636. List all the changes to memory that will result: Address New Value Part E (7 points) Based on the free list after part D, if an object of size 19 bytes is allocated, what address will be returned? How many bytes of slack (if any) will result? Address: List all the changes to memory that will result: Slack: Address New Value 4

Problem 4 (6 parts, 3 points) Dynamic Data Structures: Linked List Consider a singly linked list consisting of student records defined by the following struct definition: typedef struct STUDENT struct STUDENT* next; // Next pointer for linked list char* fname; char* mname; char* lname; double average; char lettergrade; Student_t; Student_t* LookupStudent_Sorted(Student_t* h, char* lastname) int cmp; while ( ) /* part A*/ cmp = ; /* part B*/ if ( ) /* part C*/ ; /* part C*/ else if ( ) /* part D*/ ; /* part D*/ else ; /* part E*/ ; /* part F*/ Assume that the list of student records is sorted by increasing lname (i.e., a student record earlier in the list has a lname lexicographically less than the lname of student records later in the list). The function LookupStudent_Sorted takes a pointer h to a record at the head of a list of student records and a string lastname. Complete this function (following the steps below) so that it searches for a record whose lname field matches lastname. If such a record is found,return it; otherwise return NULL. Part A (4 points) Continue the while loop if the end of list has not yet been reached. Part B (5 points) Set the variable cmp to the result of comparing lastname to the lname of the current record h. Use strcmp, which takes two strings s1 and s2 and returns an integer i indicating how they are related (i= if s1 == s2, i< if s1<s2, and i> if s1>s2). Part C (6 points) If the current student record's lname matches lastname, return the current record. Part D (6 points) Check whether the search can be ended early and if so, return the appropriate result. Part E (5 points) Continue searching by moving h to the next record in the list. Part F (4 points) Fill in what to do if the end of the list is reached and we fall out of the loop. 5