UC3M

Telematic/Audiovisual Syst./Communication Syst. Engineering

Systems Architecture

September 2015 - January 2016

Dynamic Data Structures

Previous activities

1.  Read about hash tables

Resources

Work Plan

  • Answer the following questions:

    1. Suppose that a new data structure has been defined with name struct hashtable representing a hash table like the one in the example. Which prototypes do the functions to search for a value and insert a pair (key, value) have?

    2. If the hash table has size 100, Which simple hash function can you think using the passport number? ¿And in general for any table size?

How long did this activity take you? mins.

2.  Implementing a hash table

Resources

  • Hash Tables

  • Implementation of the functions required to manipulate a linked list of elements (create, insert, delete, search, etc.)

Work Plan

  1. Read the document Hash Tables

  2. Propose a data structure containing a hash table. This structure is the one to be manipulated in the application, that is, it will be created by a function written by you, and will be received as parameter in the functions to search, add, delete, etc.

  3. Write the function to create a new hash table. Decide which parameters need to be received.

  4. Write the function that given a hash table and a key, search if such key exists. Returns the value associated with that key or NULL otherwise.

  5. Write the function that given a hash table, a key and a value, adds the pair (key, value) to the table. It is assumed that the key is not present in the table before executing the operation.

  6. Write a function that receives a hash table and destroys it. This implies destroying all the collision lists.

  7. Modify the table structure to have a parameter with name density. When the table density goes beyond that value, the table must be increased by 25%. This must happen transparently whenever the insertion of a new pair (key, value) is executed.

How long did this activity take you? mins.