Sadineni.Venkat
BAN USER- 1of 1 vote
AnswersThere is an 100 storied building and you are given 2 glass balls. Find the floor where the ball will be broken when you throw it. Find it in minimum number of throws.
- Sadineni.Venkat
What is the minimum number throws???| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm
How do you know if a number is Odd or Even?
Ans: For odd numbers, the last bit in its binary represenattion is 1. For even numbers it is 0.
So if n&1 == 1, then the number is odd.
@FK
What is HashMap functionality in the above method. Can you plesae explain?
How can we use the hash table. Can anyone plese explain??
- Sadineni.Venkat October 20, 2008Another way is to find the right row where the element can be found. Then search in that row if the element is present or not.
Say given Arr is:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
First search on the last col to decode the right row. To decide the right row:
check if the arr element is < num( to be found) then check with the next row last element.
if Equal then found.
if Arr element > num, then this is the right row.
Then search the elements in that row. Use Binary search to search in a row. Then we can solve the prob in O(n) + O(logn) in the worst case.
VIgorous:
In your strategy, it should be: 100/k + (K-2) right? Because we covered, 100 and 90 which are multiples of 10. In case if the ball breaks on 100th story, then we keep trying from 91st floor onwards to 99th floor, which amounts to 8.
1. Clustred vs Non-Clustred
A clustered index forces the data to be stored in the index column sequence. Clustered index is helpful to search range of data values.
Eg: Assume there is an Employee(EmpId, EmpName, Sal, Dept) with clustered index on EmpId column
SELECT Empname
FROM Employee
WHERE EmpId between 8 AND 16.
As the employee records are stored in the sequence of EmpId, we can easily locate EmpIds 9 to 16 once we find the location of record for EmpID 8.
A good example of clustered index is: Dictionary where each page header contains the starting letters of words that are present in that page. If we go to a page, we can easily find all the words adjacent to a particular word.
There can be only one clustered index per table but there can be approximately 249 non-clustred indexes.
Non-Clustred index: A non-clustered index stores location of the data page and an offset to the data record in that page.
A good example is: index on the back of a book
You can refer to the below links for more information
1. sql-server-
performance.com/articles/per/index_data_structures_p2.aspx
2. msdn2.microsoft.com/en-us/library/ms189280.aspx
Can someone explain the hash function please?
Pratik: How will you make sure that arr[i] and (sum - arr[i) will hash to the same location??
Start with head1 and head2. Keep comparing the pointers and move ahead both pointers until they are not equal.
When they are equal, that is the first common node.
Repsharonpkarr, None at BT
Hi! My name is Mary. I am a writer for a variety of web and multi-platform applications.I am a ...
Repmarktrejjo, Data Engineer at Accolite software
I’m Mark.I believe life is too short to be serious all the time, so if you cannot laugh ...
Repjanistbennett, Blockchain Developer at AMD
I am JanisBennett working as a journalist, having years of experience in my career. I have covered various stories.Great ...
Repsujijaa565, AT&T Customer service email at ABC TECH SUPPORT
My name is suji. I am working as a Suadela Investment in Tulsa USA . I identify and establish a new ...
Repcherylthurber, Developer Advocate at Absolute Softech Ltd
Hi,I am from Taxes, USA. Passionate multilingual translator with 2.5 years experience in Spanish-English translations.Looking to further ...
Replouisefbray, Integration Software Engineer at Ask.com
Hey! My name is Louise and I am a computer hardware retailer and wholesaler.I also provide services online. My ...
>> How can u swap 2 variables without using temp variable (XOR)
- Sadineni.Venkat February 18, 2009Ans:
A = A^B
B = A^ B
A = A^B