open hashing using cursor base

Discussion in 'C' started by D_switch, Aug 28, 2010.

  1. D_switch

    D_switch New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    problem: a list represented using cursor based implementation contains all ACT, BSCS, BSICT, BSIT and BSMATH students. A dictionary is created implemented using open hashing for BSCS and BSIT students. Each grouping the dictionary is a list implemented using cursor based. given below is the definition of the LIST, Dictionary, Virtual heap.

    #define maxCells 1000
    #define maxGrp 10
    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 int LIST;/*LIST is implemented using cursor base*/

    typedef struct
    LIST Header; /*holds the index of the first element in each group*/
    int StudCtr; /*holds the number of elements in each group*/

    typedef Group * Dictionary;

    typedef struct
    celltype heap[maxCells];
    int AvailPtr;/*holds the index to the next available cell in the virtual heap*/

    problem 1:
    write the code of function Hash. the function will return the remainder of when the total sum of all digits of the ID will be divided by maxGrp.
    here's my answer:
    int Hash(celltype x)
    int sum;
    unsigned long ID, i;
    sum += ID/i;
    return (sum%maxGrp);
    my teacher said that the celltype in the parameter is wrong and also sum and i%=10 but he didn't explain why i tried to run it and yes he was right but i don't understand what is wrong so please explain why that is.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice