Interview Questions and Answers for 'Sear' - 20 question(s) found - Order By Rating Q1. What are the disadvantages of binary search trees? Algorithm
This question was recently asked at 'ServiceNow'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  binary search tree Asked in 1 Companies This question was recently asked at 'Nagarvision'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  search  binary search Asked in 1 Companies basic   frequent Q3. How different is the Search algorithm when we query Cassandra Tables and When we query Oracle Tables ? Cassandra
Ans. Relational Database uses linear search if we don't query using indices. Performance for linear search is O(n). If indices have been used , relational database uses binary search. Performance for binary search is O(Log n).
Casandra uses hash search. Performance for Hash Search is O(1). Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  cassandra vs oracle  nosql vs relational  search algorithm Q4. How Cassandra provides better Read performance than Oracle Indices ? Database
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 : Like Discuss Correct / Improve  cassandra  hash search  hash search vs binary search Q5. What data structure will you use if we have to search an element in million of elements ? Data Structure
This question was recently asked at 'Microsoft'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Search Asked in 1 Companies Q6. Write a Program to print factorial of a number using recursion Core Java
Ans. public class BuggyBread {
public static void main(String args[]) {
System.out.println(factorial(5));
}
private static int factorial(int number){
if(number == 1){
return 1;
} else {
return number * factorial(number - 1);
}
}
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  recursion Asked in 25 Companies Q7. Do you feel that its useless to define hashCode method for a class ? Core Java
Ans. Yes its useless if we are not going to use its objects within Hash collection, For example - HashSet , HashMap. HashCode is used internally by these collections for Search. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hashcode  hash collections  search Q8. Explain various Searching and Sorting Algorithms ? Algorithm
This question was recently asked at 'HeadStrong,ServiceNow'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Search Algorithm  Sorting Algorithm Asked in 2 Companies basic   frequent Ans. Maven is a build automation tool used primarily for Java projects. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  maven  build Asked in 6 Companies basic   frequent Ans. Spring Boot is Springs convention-over-configuration solution for creating stand-alone, production-grade Spring-based Applications. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Spring Boot Asked in 7 Companies Q11. Design a Data Structure for a full text Search ? Design
This question was recently asked at 'Myntra'.This question is still unanswered. Can you please provide an answer. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  Full Text Search  Data Structure Asked in 1 Companies expert Frequently asked to Fresh graduates. Q12. Write a program to implement Binary search ? Core Java
Ans. http://algs4.cs.princeton.edu/11model/BinarySearch.java.html Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  binary search  search Asked in 5 Companies basic   frequent Try 1 Question(s) TestVery frequently asked. Among first few questions in almost all interviews. Among Top 5 frequently asked questions. Frequently asked in Indian service companies (HCL,TCS,Infosys,Capgemini etc based on multiple feedback ) and Epam Systems Q13. Difference between == and .equals() ? Core Java
Ans. "equals" is the method of object class which is supposed to be overridden to check object equality, whereas "==" operator evaluate to see if the object handlers on the left and right are pointing to the same object in memory.
x.equals(y) means the references x and y are holding objects that are equal. x==y means that the references x and y have same object.
Sample code:
String x = new String("str");
String y = new String("str");
System.out.println(x == y); // prints false
System.out.println(x.equals(y)); // prints true Sample Code for equals Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   string comparison   string   object class   ==   equals   object equality  operator   == vs equals   equals vs == Asked in 294 Companies basic   frequent Try 6 Question(s) TestVery frequently asked. Usually asked with questions related to String. Frequently asked at CTS / Cognizant Ans. Object that can't be changed after instantiation. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   oops   immutable  immutability Asked in 27 Companies basic   frequent Try 2 Question(s) Test Q15. 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 : Like Discuss Correct / Improve  java   sets   set   collections   binary search Q16. 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 : Like Discuss Correct / Improve  java   collections   search algorithm   search   binary search   at&t intermediate Advanced level question frequently asked in US based companies. Recently asked in EMC and Intuit. Q17. 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 : Like Discuss Correct / Improve  java   collections   hashmap   binary search   search algorithm   advanced   architecture   data structure Asked in 6 Companies   frequent Try 1 Question(s) TestFrequently asked to experienced developers. Recently asked in many US interviews. Q18. What is database deadlock ? How can we avoid them? Database
Ans. When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may makes the DB unresponsive.
Deadlock can be avoided using variety of measures, Few listed below -
Can make a queue wherein we can verify and order the request to DB.
Less use of cursors as they lock the tables for long time.
Keeping the transaction smaller. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  java   database   architecture Asked in 7 Companies expert   frequent Very frequently asked if being interviewed for hibernate. Frequently asked in Tata Consultancy (TCS) and Overstock.com Q19. Difference between load and get ? Hibernate
Ans. If id doesnt exist in the DB load throws an exception whereas get returns null in that case.get makes the call to DB immediately whereas load makes the call to proxy. Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  hibernate Asked in 16 Companies basic   frequent Frequently asked in face to face interviews. Q20. Write a program to print fibonacci series. Core Java
Ans. int count = 15;
int[] fibonacci = new int[count];
fibonacci[0] = 0;
fibonacci[1] = 1;
for(int x=2; x < count; x++){
fibonacci[x] = fibonacci[x-1] + fibonacci[x-2];
}
for(int x=0; x< count; x++){
System.out.print(fibonacci[x] + " ");
} Help us improve. Please let us know the company, where you were asked this question : Like Discuss Correct / Improve  ebay   fibonacci series Asked in 66 Companies basic   frequent a. Sorted in Ascending Order b. Sorted in Descending Order c. Sorted in any Order d. UnsortedAns.c. Sorted in any Order