Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers - Order By Newest | ||||
| ||||
Ans. pop method pulls the top element from the stack and then move the top to the next element whereas peek only get the top element but doesn't move the top. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  stack | ||||
| ||||
Ans. Data type: a set of values together with operations on that type Data structure: a physical implementation of a data type | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   data structure   data type | ||||
| ||||
Ans. Class can be better seen as Data Type. This could be implemented as a Data Structure too in some cases. One thing worth understanding here is that Data type and Data structure are conceptual things. Class could be implementation of either of these. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   oops   class   data type   data structure | ||||
| ||||
Ans. http://stackoverflow.com/questions/494830/how-to-determine-if-a-linked-list-has-a-cycle-using-only-two-memory-locations | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  linked list   data structure   algorithm   java   ebay | ||||
| ||||
Ans. [ Open Ended question ] | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  data structures   open ended questions   load balancer | ||||
| ||||
Ans. Array List works on Array and when we add an element in middle of the list, Array List need to update the index of all subsequent elements. I the capacity is full, it even may need to move the whole list to a new memory location . Linked List works on Double linked list algorithm and all it has to do is to adjust the address of the previous and next elements. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  arraylist vs linkedlist  collections  list Asked in 2 Companies | ||||
| ||||
Ans. https://qr.ae/TWK2Ok | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  circular queue  priority queue  queue  data structures  collections | ||||
| ||||
Ans. import java.util.*; class LinkedListSolution{ protected LinkedList list; public LinkedListSolution(){ list = new LinkedList(); } public Object pop() throws NoSuchElementException{ if(list.isEmpty()) throw new NoSuchElementException(); else return list.removeFirst(); } public void push(Object obj){ list.addFirst(obj); } public Object peek() throws NoSuchElementException{ if(list.isEmpty()) throw new NoSuchElementException(); else return list.getFirst(); } public boolean isEmpty(){ return list.isEmpty(); } public String toString(){ return list.toString(); } } class TestStack{ public static void main(String args[]){ LinkedListSolution s = new LinkedListSolution(); s.push("First"); s.push("Second"); s.push("Third"); System.out.println("Top: " s.peek()); s.push("Fourth"); while(!(s.isEmpty())) System.out.println(s.pop()); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Linkedlist  data structures  algorithm Asked in 2 Companies basic | ||||
| ||||
This question was recently asked at 'Caprus IT'.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  linkedlist  delete a node from linked list Asked in 1 Companies | ||||
| ||||
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 | ||||
| ||||
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  data structure  linked list | ||||
| ||||
Ans. We can merge two sorted array by using quick sort algorithm | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  arrays  merge sorted arrays Asked in 2 Companies | ||||
| ||||
This question was recently asked at 'Bind Software Innovations'.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  oding  cod Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'MarkMonitor'.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  hashtable Asked in 1 Companies | ||||
| ||||
Ans. Stack is based on Last in First out (LIFO) principle while a queue is based on FIFO (First In First Out) principle. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  data structure  stack vs queue  stack  queue Basic | ||||
| ||||
Ans. Graph contain cycles whereas Trees cannot. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  graph  trees  data structures  tree vs graph | ||||
| ||||
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  Data Structure | ||||
| ||||
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  Data Structure | ||||
| ||||
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  Data Structures | ||||
| ||||
This question was recently asked at 'Amazon'.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  Tree  Data structures Asked in 1 Companies | ||||
| ||||
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  queue  collections  data structure | ||||
| ||||
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  Arraylist  linkedlist  queue  collections | ||||
| ||||
Ans. public class BinarySearchTree { //Represent the node of binary tree public static class Node { int data; Node left; Node right; public Node(int data) { //Assign data to the new node, set left and right children to null this.data = data; this.left = null; this.right = null; } } //Represent the root of binary tree public Node root; public BinarySearchTree() { root = null; } //factorial() will calculate the factorial of given number public int factorial(int num) { int fact = 1; if (num == 0) return 1; else { while (num > 1) { fact = fact * num; num--; } return fact; } } //numOfBST() will calculate the total number of possible BST by calculating Catalan Number for given key public int numOfBST(int key) { int catalanNumber = factorial(2 * key) / (factorial(key 1) * factorial(key)); return catalanNumber; } public static void main(String[] args) { BinarySearchTree bt = new BinarySearchTree(); //Display total number of possible binary search tree with key 5 System.out.println("Total number of possible Binary Search Trees with given key: " bt.numOfBST(5)); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Amazon'.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  arrays  coding  code Asked in 1 Companies | ||||
| ||||
Ans. list.get(index); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  list Asked in 1 Companies | ||||
| ||||
Ans. Create one extra field called MAX O(1) when you an element to the stack check these two condition 1. Stack is empty, then MAX = element 2. Stack is not empty then check if the element is greater than MAX then MAX = element when getMax fuction is called, then return MAX | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  complexity  stack  data structure Asked in 1 Companies | ||||
| ||||
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   | ||||
| ||||
Ans. public class StackUsingArrayList { public static void main(String[] args) { List list = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); Stack stack = new Stack(); list.forEach(a -> stack.add(a)); System.out.println(stack); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve   Asked in 1 Companies | ||||
| ||||
Ans. Use hashCode() which returns an integer value, generated by a hashing algorithm | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hash codes  hashcode Asked in 1 Companies | ||||
| ||||
This question was recently asked at 'Spillman Technologies,Motorola Solutions'.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   Asked in 2 Companies | ||||