Docsity

Data Structures Homework 3: Buddy System and Double Hashing - Prof. Venkatramana Subrahman, Assignments of Data Structures and Algorithms

Toggle sidebar
bg1
CMSC 420: Data Structures
Fall 2003
Homework 3
Due: Dec. 2, 2003.
QUESTION 1 (12 points). Suppose a dynamic storage allocation program that uses the buddy
system has a total of
๎˜€๎˜‚๎˜
units of memory to allocate. Suppose the following transactions occur:
1. Process P1 requests 16 units of memory.
2. Process P2 requests 8 units of memory.
3. Process P3 requests 8 units of memory.
4. Process P4 requests 8 units of memory.
5. Process P5 requests 8 units of memory.
6. Process P6 requests 8 units of memory.
7. Process P3 returns its memory.
8. Process P4 returns its memory.
9. Process P5 returns its memory.
10. Process P6 returns its memory.
11. Process P2 returns its memory.
12. Process P1 returns its memory.
For each of the above, show: (i) start address and size of the block allocated to the process (for allo-
cation requestions) and (ii) the state of the array maintained by the buddy system at the immediately
after processing of each of the above transactions. This means that you must show each node in the
linked lists associated with the entries in the array.
During insertion, whenever there is a choice of which of two buddies are to be split, you must
split the buddy with the smaller start address.
QUESTION 2(8 points). Consider double hashing using the primary hash function
๎˜ƒ๎˜…๎˜„๎˜‡๎˜†๎˜‰๎˜ˆ๎˜‹๎˜Š
๎˜†๎˜๎˜Œ๎˜๎˜Ž๎˜‘๎˜๎˜“๎˜’๎˜•๎˜”
and
๎˜–๎˜—๎˜„๎˜‡๎˜†๎˜‰๎˜ˆ๎˜˜๎˜Š๎˜™๎˜†๎˜š๎˜Œ๎˜๎˜Ž๎˜‘๎˜๎˜œ๎˜›
. Insert the following keys into a hash table of size 10 (labeled
0 through 9) using Brentโ€™s method for reorganizing hash tables.
๎˜’๎˜ž๎˜๎˜œ๎˜Ÿ๎˜ž๎˜’
๎˜€
๎˜Ÿ๎˜ž๎˜’ ๎˜›!๎˜Ÿ๎˜ž๎˜’๎˜ž"๎˜œ๎˜Ÿ๎˜ž๎˜’๎˜ž#๎˜œ๎˜Ÿ$๎˜%๎˜›!๎˜Ÿ
๎˜
๎˜›!&
Show what the hash table looks like after each of the above keys has been inserted.
1

Partial preview of the text

Download Data Structures Homework 3: Buddy System and Double Hashing - Prof. Venkatramana Subrahman and more Assignments Data Structures and Algorithms in PDF only on Docsity!

CMSC 420: Data Structures

Fall 2003 Homework 3 Due: Dec. 2, 2003.

QUESTION 1 (12 points). Suppose a dynamic storage allocation program that uses the buddy

system has a total of ^ units of memory to allocate. Suppose the following transactions occur:

  1. Process P1 requests 16 units of memory.
  2. Process P2 requests 8 units of memory.
  3. Process P3 requests 8 units of memory.
  4. Process P4 requests 8 units of memory.
  5. Process P5 requests 8 units of memory.
  6. Process P6 requests 8 units of memory.
  7. Process P3 returns its memory.
  8. Process P4 returns its memory.
  9. Process P5 returns its memory.
  10. Process P6 returns its memory.
  11. Process P2 returns its memory.
  12. Process P1 returns its memory.

For each of the above, show: (i) start address and size of the block allocated to the process (for allo- cation requestions) and (ii) the state of the array maintained by the buddy system at the immediately after processing of each of the above transactions. This means that you must show each node in the linked lists associated with the entries in the array. During insertion, whenever there is a choice of which of two buddies are to be split, you must split the buddy with the smaller start address.

QUESTION 2(8 points). Consider double hashing using the primary hash function  

  and     . Insert the following keys into a hash table of size 10 (labeled

0 through 9) using Brentโ€™s method for reorganizing hash tables.

Show what the hash table looks like after each of the above keys has been inserted.