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

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

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 Spring problems, 5 pages Exam Three 8 April Your Name (please print clearly)

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 28 November 2012

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 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 Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

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 Spring problems, 8 pages Final Exam Solutions 1 May 2013

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

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

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 Two 21 October 2016

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

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!

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

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

COMP 524 Spring 2018 Midterm Thursday, March 1

York University AS/AK/ITEC INTRODUCTION TO DATA STRUCTURES. Midterm Sample I. Examiner: S. Chen Duration: One Hour and 30 Minutes

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

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

ECE 454 Computer Systems Programming

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

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

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

Creating a String Data Type in C

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

CSE 131 Introduction to Computer Science Fall Exam II

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

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

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

CS 3114 Data Structures and Algorithms READ THIS NOW!

COS 226 Algorithms and Data Structures Fall Midterm

ECE264 Fall 2013 Exam 3, November 20, 2013

CSCI Compiler Design

CSE351 Winter 2016, Final Examination March 16, 2016

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

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

CSE 333 Midterm Exam Nov. 3, 2017 Sample Solution

CS61C : Machine Structures

COS 226 Algorithms and Data Structures Fall Midterm

Exam Principles of Imperative Computation, Summer 2011 William Lovas. June 24, 2011

CS 2150 Exam 2, Spring 2018 Page 1 of 6 UVa userid:

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

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

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

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

CS 170, Spring 2000 Midterm #1 Professor M. Clancy

Midterm Examination # 2 Wednesday, March 19, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:

Final Examination Term: 162 Year: 2016/2017 (v2)

Data Structure with C. List

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

CSE 131S Introduction to Computer Science Summer SON Exam I

(the bubble footer is automatically inserted into this space)

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

ECE 2030B 1:00pm Computer Engineering Spring problems, 5 pages Exam Two 10 March 2010

CS61C : Machine Structures

CSE 131 Introduction to Computer Science Fall Exam I

CSE 131 Introduction to Computer Science Fall Exam I

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

Midterm, Spring 2013

Midterm Exam Answers Instructor: Randy Shepherd CSCI-UA.0201 Spring 2017

Computer Science Foundation Exam

My malloc: mylloc and mhysa. Johan Montelius HT2016

CS-245 Database System Principles

Midterm Examination # 2 Wednesday, March 18, Duration of examination: 75 minutes STUDENT NAME: STUDENT ID NUMBER:

CSE373 Fall 2013, Second Midterm Examination November 15, 2013

CS61C Machine Structures. Lecture 4 C Structs & Memory Management. 9/5/2007 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

BBM 201 DATA STRUCTURES

Project 0: Implementing a Hash Table

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

CS61C : Machine Structures

CSE 333 Midterm Exam 2/14/14

CSE 131 Introduction to Computer Science Fall Exam I

CS 3114 Data Structures and Algorithms READ THIS NOW!

Do not start the test until instructed to do so!

Do not start the test until instructed to do so!

CS 3330 Final Exam Spring 2016 Computing ID:

Sample Examination. Family Name:... Other Names:... Signature:... Student Number:...

Both parts center on the concept of a "mesa", and make use of the following data type:

Lecture 16 More on Hashing Collision Resolution

Wawrzynek & Weaver CS 61C. Sp 2018 Great Ideas in Computer Architecture MT 1. Print your name:,

The assignment requires solving a matrix access problem using only pointers to access the array elements, and introduces the use of struct data types.

Prelim CS410, Summer July 1998 Please note: This exam is closed book, closed note. Sit every-other seat. Put your answers in this exam. The or

ECE 15B COMPUTER ORGANIZATION

Introduction to Linked Lists

CSE 333 Midterm Exam 5/10/13

CS 222/122C Fall 2016, Midterm Exam

Lecture Data layout on disk. How to store relations (tables) in disk blocks. By Marina Barsky Winter 2016, University of Toronto

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

Final Exam. COMP Summer I June 26, points

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CSE 247 Data Structures and Algorithms Fall Exam I

CS 241 Data Organization Binary Trees

COS 226 Algorithms and Data Structures Spring Midterm Exam

Dynamic Memory Allocation

Transcription:

Your Name (please PRINT clearly) Your Student Number (9 digit) 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 total 35 30 35 100 Instructions: This is a closed book, closed note exam. Calculators are not permitted. Please work the exam in dark pencil or pen and do not separate the pages of the exam. Note that this exam is double sided. If you run out of room, please mark on the problem that you will continue on the pages at the end of the exam. Also please identify the problem that is being continued, and draw a box around it. When writing your answer in a given answer box, please just write the answer and do not add extraneous marks etc. which confuse our grading tools. Read each question over before you start to work. If you have a question, raise your hand and we will come to you; do not leave your seat. For maximum credit, show your work. Good Luck!

Problem 1 (2 parts, 35 points) Hash Tables and Linked Lists Consider a hash table that is implemented using the following struct definitions. typedef unsigned int (*HashFunction)(unsigned int key); typedef struct _HTE { unsigned int key; void* value; struct _HTE* next; } HashTableEntry; typedef struct _HT { HashTableEntry** buckets; HashFunction hash; unsigned int num_buckets; } HashTable; Part A (6 points) What is sizeof (in bytes) for each of the following? Assume 32-bit word size. sizeof(hashtableentry) sizeof(hashtable) Part B (29 points) Complete the following function, which takes a pointer to a HashTable and a pointer to a HashTableEntry and appends the entry to the end of the appropriate bucket list in the hashtable, based on the entry s key. Assume that there is no entry with this key already in the hashtable. The bucket lists in the hashtable are not sorted. Write only C-code (no comments) in the given spaces. void appenditem(hashtable* myht, HashTableEntry* newentry) { key ; // Declare & initialize key. // Declare and initialize the bucket number: bucknum ; // Declare and initialize thisentry to the head of the bucket: thisentry ; // If bucket is empty, insert newentry as head of bucket and return: // Find the end of the bucket list: // Append the entry to the end of the bucket list: } return;

Problem 2 (2 parts, 30 points) Hash Table Trace and Performance Part A (16 points) 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 which starts out empty. Be sure to reuse any blocks added to the free list before allocating unused blocks. 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. Trace # op key value Trace # op key value 1 insert 67 111 3 insert 19 333 2 remove 42 n/a 4 insert 40 888 Part B (14 points) Consider an associative set of 121 entries each containing a (key, value) pair. Suppose the set is implemented by an unsorted singly linked list. An application performs 240 lookups of various keys: 160 of the lookups find the key in the list and 80 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. How many key comparisons would be required for the average lookup in the list? Answer: key comparisons (give an unsigned int, not a fraction) Now suppose the associative set of 121 entries is implemented by a hash table whose buckets each containing a sorted singly linked list of entries. The 121 entries are evenly distributed across the hash table buckets. As before, an application performs 240 lookups of various keys: 160 of the lookups find the key in the hash table and 80 lookups fail to find the key. The keys that are found are distributed throughout the buckets so that each position is equally likely to be where a key is found. How many buckets should the hash table contain for the average hash table lookup to require 6 key comparisons? Answer: buckets (give an unsigned int, not a fraction)

Problem 3 (4 parts, 35 points) Heap Management Consider a memory allocator (malloc and free), such as described in class. Inside the C-code for the allocator, unsigned *heapptr is the address of the next word that could be allocated in the heap, and unsigned **freeptr is the address of the first block (or object) on the free list (and the word at the address of each block on the free list is a pointer to the next block on the free list). The allocator uses a best fit strategy with a free list sorted by increasing block size, and never splits blocks. addr value addr value addr value addr value addr value addr value 8000 16 8032 12 8064 4 8096 8048 8128 8 8160 0 8004 0 8036 0 8068 12 8100 8104 8132 8052 8164 0 8008 4 8040 8072 8072 8088 8104 4 8136 8 8168 22 8012 16 8044 12 8076 8144 8108 2 8140 4 8172 7000 8016 8072 8048 16 8080 8 8112 12 8144 43 8176 12 8020 8 8052 0 8084 16 8116 8004 8148 28 8180 41 8024 8132 8056 8 8088 0 8120 4 8152 8 8184 40 8028 116 8060 8124 8092 16 8124 30 8156 0 8188 0 Suppose heapptr = 8148 and freeptr = 8132. Consider each part below independently. a) (5) How many blocks and useable bytes are on the free list? blocks = bytes = b) (10) What value would be returned by the call malloc(4); Which (if any) values in the above map would be changed by the call in (b)? addr value addr value addr value No change ( ) (fill in the address/value pairs above. There may be more pairs than needed.) Fill in the values at this point: heapptr = freeptr= c) (10) What value would be returned by the call malloc(17); Which (if any) values in the above map would be changed by this call? addr value addr value addr value No change ( ) Fill in the values at this point: heapptr = freeptr= d) (10) Which (if any) values in the above map would be changed by the call free(8036)? addr value addr value addr value No change ( ) Fill in the values at this point: heapptr = freeptr=

Extra work space: If you are continuing a problem here, please identify the problem that is being continued.

Extra work space: If you are continuing a problem here, please identify the problem that is being continued.