1 / 10

Question 1

Question 1. (a) Student Folding Computed Actual Number Address Address 98003446 187 7 7 98018241 285 5 5 98019602 305 5 5->6 98137942 592 2 2 98158891 796 6 6->7->8 . Question 1. (b) Average = (1 + 1 + 2 + 1 + 3) / 5 = 1.6

ivana
Download Presentation

Question 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Question 1 (a) Student Folding Computed Actual Number Address Address 98003446 187 7 7 98018241 285 5 5 98019602 305 5 5->6 98137942 592 2 2 98158891 796 6 6->7->8

  2. Question 1 (b) Average = (1 + 1 + 2 + 1 + 3) / 5 = 1.6 (c)Since each cell in the table is eventually probed, if the table is not full, the collision can be resolved. (d) Similar to quadratic probing, all elements that hash to the same location will try the same collision resolution sequence. Thus secondary clustering problem cannot be resolved. But primary clustering problem similar to linear probing will not occur because there is no difference between records that hash to neighbouring and distant cells.

  3. Question 2 Convert the infix expression, A^B*C-D+E/F/(G+H), into postfix expression Answer: AB^C*D-EF/GH+/+

  4. Expression tree + - / * D + / C ^ F E G H A B

  5. Question 3 A strictly binary tree is one that every non-leaf node has non-empty left and right subtrees. Write a recursive algorithm to determine if a binary tree is strictly binary or not. Assume the following data structure is given struct node { struct node *left; int info; struct node *right; };

  6. Question 3 int binary (nodeptr root) { if (root!=NULL) if((root->left!= NULL && root-> right == NULL) || (root->left == NULL && root-> right !=NULL)) return (0); else return(binary(root->left) * binary(root->right)); else return (1); } Answer

  7. Question 4 Sum=0; for (j=0;j<N;j++) for (k=0;k<N*N;k++) Sum++; Answer: NxN2 = N3

  8. Question 4 Sum=0; for (j=0;j<N;j++) for (k=0;k<j;k++) Sum++; Answer: 1 + 2 + 3 +…. + (N-1) = N(N-1)/2

  9. Question 5 Show and describe how to implement three stacks in one array Answer: - one from bottom up - one from top down - one from middle

  10. Question 5 Show and describe how to implement three stacks in one array - if third stack collides with either one => needs to move - one reasonable strategy: move it so that its center is halfway between tops of two stacks

More Related