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 for 'NewGen' - 3 question(s) found - Order By Newest | ||||
| ||||
This question was recently asked at 'newGen'.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 1 Companies | ||||
Related Questions | ||||
What is a BlockingQueue? | ||||
Which of the following doesn't extend Collection interface ? | ||||
If you need to consume messages from the queue faster, which approach will you recommend - batching or concurrency ? | ||||
What is ConcurrentLinkedDeque ? | ||||
Name few classes that implement Queue interface ? | ||||
Name few Queue classes and interfaces ? | ||||
What is Apache Kafka ? | ||||
What is a broker in Apache Kafka ? | ||||
What is a Topic in Apache Kafka ? | ||||
Have you used Kafka in your project ? If Yes, for what ? | ||||
| ||||
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 | ||||
Related Questions | ||||
What is a binary tree ? | ||||
Write code for Binary tree traversal ? | ||||
Flatten a Binary Tree to Linked List | ||||
Write code to check if a Binary tree is symmetrical | ||||
Write program to balance a binary tree | ||||
Given a sorted array, write an algorithm to create a binary tree. | ||||
Write a Program to find depth of node binary tree ? | ||||
| ||||
This question was recently asked at 'Newgen technologies'.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 1 Companies | ||||
Related Questions | ||||
Difference between == and .equals() ? | ||||
Why is String immutable in Java ? | ||||
Explain the scenerios to choose between String , StringBuilder and StringBuffer ? or What is the difference between String , StringBuilder and StringBuffer ? | ||||
What are the difference between composition and inheritance in Java? | ||||
Explain OOPs or Explain OOPs Principles or Explain OOPs Concepts or Explain OOPs features or Tell me something about OOPs | ||||
What is a Lambda Expression ? What's its use ? | ||||
Does garbage collection guarantee that a program will not run out of memory? | ||||
Why Char array is preferred over String for storing password? | ||||
What are different ways to create String Object? Explain. | ||||
What is the difference between final, finally and finalize() ? | ||||