sample-midterm.pdf - CS 211 Midterm 100 points Instructor Prof Santosh Nagarakatte Full Name Here RUID Question 1 2 3 4 5 Max Points 20 20 20 20 20 1

sample-midterm.pdf - CS 211 Midterm 100 points Instructor...

This preview shows page 1 - 4 out of 9 pages.

CS 211: Midterm : 100 points Instructor: Prof. Santosh Nagarakatte Full Name Here: RUID: Question Max Points Points 1 20 2 20 3 20 4 20 5 20 1
Image of page 1
Problem 1: C Programming (20 points)1. You are implementing a hash table with open chaining where each node is of the following type.struct node{int id;// represents hash keyint data;// data of an itemstruct node * link;};Given that the hash table is implemented as an array of pointers to hash table nodes, implement thefollowing hashsearch function to search a key in the hash table. If the key is found, the search functionreturns the value associated with the key and returns -1 otherwise. The value MAXENTRIES is thenumber of buckets in the hash table.Your code should carefully handle all corner cases, shouldcompile, and should not experience segmentation faults on any input.Use (key + 797) modulo MAXENTRIES as the hash function.struct node * hash_table[MAX_ENTRIES];int hash_search(int key){ 2
Image of page 2
Image of page 3
Image of page 4

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture