Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  The characters of the string K R P C S N Y T ... Start Learning for Free
The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash function
h(x) = ((ord(x) - ord(A) + 1)) mod 10
If linear probing is used to resolve collisions, then the following insertion causes collision
  • a)
    Y
  • b)
    C
  • c)
    M
  • d)
    P
Correct answer is option 'C'. Can you explain this answer?
Verified Answer
The characters of the string K R P C S N Y T J M are inserted into a h...
The hash table with size 10 will have index from 0 to 9. hash function = h(x) = ((ord(x) - ord(A) + 1)) mod 10 So for string K R P C S N Y T J M: K will be inserted at index : (11-1+1) mod 10 = 1 R at index: (18-1+1) mod 10 = 8 P at index: (16-1+1) mod 10 = 6 C at index: (3-1+1) mod 10 = 3 S at index: (19-1+1) mod 10 = 9 N at index: (14-1+1) mod 10 = 4 Y at index (25-1+1) mod 10 = 5 T at index (20-1+1) mod 10 = 0 J at index (10-1+1) mod 10 = 0 // first collision occurs. M at index (13-1+1) mod 10 = 3 //second collision occurs. Only J and M are causing the collision. Final Hash table will be:
0    T
1    K
2    J
3    C
4    N
5    Y
6    P
7    M
8    R
9    S
So, option (C) is correct.
View all questions of this test
Most Upvoted Answer
The characters of the string K R P C S N Y T J M are inserted into a h...
Collision occurs when two or more elements are hashed to the same index in the hash table. In this case, the hash function h(x) = ((ord(x) - ord(A) + 1)) mod 10 is used to determine the index for each character. Let's analyze the given string and the hash function to understand why option 'C' causes a collision.

Given string: K R P C S N Y T J M

Hash function: h(x) = ((ord(x) - ord(A) + 1)) mod 10

Step 1: Calculate the index for each character using the hash function.

Character 'K':
ord('K') = 75
h('K') = ((75 - 65 + 1) mod 10) = 1

Character 'R':
ord('R') = 82
h('R') = ((82 - 65 + 1) mod 10) = 8

Character 'P':
ord('P') = 80
h('P') = ((80 - 65 + 1) mod 10) = 6

Character 'C':
ord('C') = 67
h('C') = ((67 - 65 + 1) mod 10) = 3

Character 'S':
ord('S') = 83
h('S') = ((83 - 65 + 1) mod 10) = 9

Character 'N':
ord('N') = 78
h('N') = ((78 - 65 + 1) mod 10) = 4

Character 'Y':
ord('Y') = 89
h('Y') = ((89 - 65 + 1) mod 10) = 5

Character 'T':
ord('T') = 84
h('T') = ((84 - 65 + 1) mod 10) = 4

Character 'J':
ord('J') = 74
h('J') = ((74 - 65 + 1) mod 10) = 0

Character 'M':
ord('M') = 77
h('M') = ((77 - 65 + 1) mod 10) = 3

Step 2: Check for collision.

Looking at the calculated indices, we can see that characters 'N' and 'T' both hash to index 4. This means that there is a collision between these two characters.

Therefore, the correct answer is option 'C' because inserting the character 'M' causes a collision with the character 'N' at index 4.
Free Test
Community Answer
The characters of the string K R P C S N Y T J M are inserted into a h...
The hash table with size 10 will have index from 0 to 9. hash function = h(x) = ((ord(x) - ord(A) + 1)) mod 10 So for string K R P C S N Y T J M: K will be inserted at index : (11-1+1) mod 10 = 1 R at index: (18-1+1) mod 10 = 8 P at index: (16-1+1) mod 10 = 6 C at index: (3-1+1) mod 10 = 3 S at index: (19-1+1) mod 10 = 9 N at index: (14-1+1) mod 10 = 4 Y at index (25-1+1) mod 10 = 5 T at index (20-1+1) mod 10 = 0 J at index (10-1+1) mod 10 = 0 // first collision occurs. M at index (13-1+1) mod 10 = 3 //second collision occurs. Only J and M are causing the collision. Final Hash table will be:
0    T
1    K
2    J
3    C
4    N
5    Y
6    P
7    M
8    R
9    S
So, option (C) is correct.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer?
Question Description
The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? for Computer Science Engineering (CSE) 2024 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer?.
Solutions for The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer?, a detailed solution for The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? has been provided alongside types of The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice The characters of the string K R P C S N Y T J M are inserted into a hash table of size 10 using hash functionh(x) = ((ord(x) - ord(A) + 1)) mod 10If linear probing is used to resolve collisions, then the following insertion causes collisiona)Yb)Cc)Md)PCorrect answer is option 'C'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam

Top Courses for Computer Science Engineering (CSE)

Explore Courses
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev