Get best answers to any doubt/query/question related to programming , jobs, gate, internships and tech-companies. Feel free to ask a question and you will receive the best advice/suggestion related to anything you ask about software-engineering , development and programming problems .

0 like 0 dislike
1,174 views
in Online Assessments by Expert (44,360 points)

2 Answers

0 like 0 dislike
 
Best answer

image

Images of ques

 

by Expert (44,360 points)
0 like 0 dislike
Q1: Let's first think for some interval of integers that we'll denote [x^2, (x+1)^2), how many valid pairs can we make? All numbers in this range would have the same hash.
There are ((x+1)^2 - x^2) = (2x+1) integers in this range. Thus, we have (2x+1)^2 total pairs in the range.

 

Now, we can count the pairs in ranges up to the largest x < floor(sqrt(k)), and the remaining pairs in the range (floor(sqrt(k))^2, k) can be counted in a similar fashion.
by Expert (44,360 points)
...