Hi please help me with this. My head really hurts from attempting to answer this question. Thanks a lot!

#define maxCells 1000
#define maxCS 11
#define maxIT 19
typedef struct
char LN[16], FN[24], MI;
typedef struct studtype
unsigned long ID;
nametype name;
char course[8];
int yr;
typedef struct ctype
student stud;
int next;
typedef struct
int *Header;
int CourseCtr; /*holds the # of elements for each course*/
typedef CSIT Dictionary[2];
typedef int LIST;
typedef struct
celltype heap[maxCells];
int AvailPtr; /*holds the index to the first available cell in the VH*/

Problem Definition: A list of BSCS and BSIT student records is stored in internal memory represented using cursor-based implementation. The list is to be converted into a dictionary, a set ADT. The dictionary is represented in memory using open-hashing (cursor-based). Each group in the header table is sorted in ascending order according to ID.
*Hash function exists and can be called in your function. The function will accept an element as its parameter and return the appropriate hash value for each element.
Write the code of the function CreateDic() – the function will convert the list of BSCS and BSIT student records into a dictionary, which will be returned to the calling function. Each student record is uniquely identified by the ID.

See this tutorial for details on writing a hash table. As far as extracting each item in the list for adding to the dictionary, it should be a simple cursor-based traversal:

Dict CreateDic(void)
    void AddDic(Dict*, student*);

    LIST cursor;
    Dict dict;

    for (cursor = 0; cursor != -1; cursor = VH->head[cursor].next)
        AddDic(&Dict, &VH->heap[cursor].stud);

    return dict;

AddDic() would generate the hash and add a copy of the student to your hash table. Note that I'm making quite a few assumptions in that CreateDic() because you didn't provide all of the necessary details. But it should be sufficient to exhibit how you might traverse the list.

This article has been dead for over six months. Start a new discussion instead.