Presentation is loading. Please wait.

Presentation is loading. Please wait.

Question 1 (a) Student FoldingComputedActual Number AddressAddress 9800344618777 9801824128555 9801960230555->6 9813794259222 9815889179666->7->8.

Similar presentations


Presentation on theme: "Question 1 (a) Student FoldingComputedActual Number AddressAddress 9800344618777 9801824128555 9801960230555->6 9813794259222 9815889179666->7->8."— Presentation transcript:

1 Question 1 (a) Student FoldingComputedActual Number AddressAddress 9800344618777 9801824128555 9801960230555->6 9813794259222 9815889179666->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 ^ A B / / + HG F E

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: NxN 2 = N 3

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


Download ppt "Question 1 (a) Student FoldingComputedActual Number AddressAddress 9800344618777 9801824128555 9801960230555->6 9813794259222 9815889179666->7->8."

Similar presentations


Ads by Google