Algorithm - Interview Questions and Answers for 'Binary' | Search Java Interview Question - javasearch.buggybread.com

# Search Interview Questions

2679 questions in repository.
There are more than 200 unanswered questions.
Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

Algorithm - Interview Questions and Answers for 'Binary' - 11 question(s) found - Order By Newest

Q1. Can you provide some implementation of a Dictionary having large number of words ? Solution
Ans. Simplest implementation we can have is a List wherein we can place ordered words and hence can perform Binary Search.

Other implementation with better search performance is to use HashMap with key as first character of the word and value as a LinkedList.

Further level up, we can have linked Hashmaps like ,

hashmap {
a ( key ) -> hashmap (key-aa , value (hashmap(key-aaa,value)
b ( key ) -> hashmap (key-ba , value (hashmap(key-baa,value)
....................................................................................
z( key ) -> hashmap (key-za , value (hashmap(key-zaa,value)
}

upto n levels ( where n is the average size of the word in dictionary.

Help us improve. Please let us know the company, where you were asked this question :

java   collections   hashmap   binary search   search algorithm   advanced   architecture   data structure     Dell EMC   Intuit   Corporate Brokers  PWC India  Yahoo  Oracle        frequent

Try 1 Question(s) Test

Q2. What are the pre-requisite for the collection to perform Binary Search ?
Ans. 1. Collection should have an index for random access.
2. Collection should have ordered elements.

Help us improve. Please let us know the company, where you were asked this question :

java   collections   search algorithm   search   binary search   at&t      intermediate

Q3. What is a binary tree ?Algorithm2017-01-19 15:38:04
Ans. Binary tree is a tree in which each node has up to two children.Tree is a data structure composed of nodes.Each tree has a root node(not necessary in graph theory). The root node has zero or more child nodes.Each child node has zero or more child nodes, and so on.The tree cannot contain cycles.

Help us improve. Please let us know the company, where you were asked this question :

binary tree     Deloitte

Q4. What is the difference between >> and >>>?
Ans. Both bitwise right shift operator ( >> ) and bitwise zero fill right shift operator ( >>> ) are used to shift the bits towards right. The difference is that >> will protect the sign bit whereas the >>> operator will not protect the sign bit. It always fills 0 in the sign bit.

Help us improve. Please let us know the company, where you were asked this question :

java   operators   bitwise operators   binary shift   right shift

Q5. Write a method to convert binary to a number ?Core Java
Ans.
convert(int binaryInt) {
int sumValue=0;
int multiple = 1;
while(binaryInt > 0){
binaryDigit = binaryInt%10;
binaryInt = binaryInt /10;
sumValue = sumValue + (binaryDigit * multiple);
multiple = multiple * 2;
}
return sumValue;
}

Help us improve. Please let us know the company, where you were asked this question :

java   binary   interesting question   coding

Q6. Can we use Ordered Set for performing Binary Search ?
Ans. We need to access values on the basis of an index in Binary search which is not possible with Sets.

Help us improve. Please let us know the company, where you were asked this question :

java   sets   set   collections   binary search

Q7. Write a program to implement Binary search ?Core Java2016-10-18 10:49:58

Help us improve. Please let us know the company, where you were asked this question :

binary search  search     Cognizant (CTS)  Click Labs  Infoview Technologies  Mahindra Comviva  Acute Informatics      basic        frequent

Try 1 Question(s) Test

Q8. Write code to check if a Binary tree is symmetricalAlgorithm2017-03-03 14:29:12

Help us improve. Please let us know the company, where you were asked this question :

binary tree     Amazon

Q9. How Cassandra provides better Read performance than Oracle Indices ?Database2017-08-18 09:39:56
Ans. Cassandra uses Hash Search which provides a look time of O(1) whereas Oracle Indices uses Binary Search that provide a lookup time of O(Log n).

Help us improve. Please let us know the company, where you were asked this question :

cassandra  hash search  hash search vs binary search

Do you think these are the Best Java Frameworks ?

 OpenXava SPRING MVC Apache Stripes Check everything that is Best in Java Click Here

Q10. Explain Binary SearchAlgorithm2018-02-02 08:37:31

Help us improve. Please let us know the company, where you were asked this question :

search  binary search     Nagarvision      basic        frequent

 Q11. Binary Search requires that the collection should be Algorithm
a. Sorted in Ascending Order
b. Sorted in Descending Order
c. Sorted in any Order
d. Unsorted

Ans.c. Sorted in any Order

Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Delivered by FeedBurner

## Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.