LinguaSol
The Doon School Interview Questions and Answers
Q1. what is Binary Serch Tree and its Time Complexity.
Binary Search Tree is a data structure where each node has at most two children, with left child smaller and right child larger. Time complexity is O(log n) for search, insert, and delete operations.
Nodes have at most two children - left child is smaller, right child is larger
Search, insert, and delete operations have time complexity of O(log n)
Example: In a BST, if we search for a value, we can eliminate half of the remaining nodes at each step
Q2. Difference between array and linked list ? Arraylist and LinkedList in collection framework
Array is a fixed-size data structure while linked list is a dynamic data structure. ArrayList and LinkedList are implementations of List interface in Java.
Array is a contiguous block of memory with fixed size, while linked list is a collection of nodes where each node points to the next node.
ArrayList in Java is implemented using an array, which can dynamically resize itself. LinkedList is implemented using nodes with references to the next and previous nodes.
Arrays are faste...read more
Q3. Explain Quick sort , Merge Sort algorithm
Quick sort and Merge sort are popular sorting algorithms used to efficiently sort arrays of elements.
Quick sort: Divide and conquer algorithm, picks a pivot element and partitions the array around the pivot. Recursively sorts subarrays.
Merge sort: Divide and conquer algorithm, divides the array into two halves, recursively sorts the halves, and then merges them back together.
Example: Quick sort - [3, 6, 8, 10, 1, 2, 1], Merge sort - [7, 2, 4, 1, 5, 3]
Q4. Write down the linked list implementation code .
Implementation of a linked list in code format
Define a Node class with data and next pointer
Create LinkedList class with methods like insert, delete, search
Handle edge cases like empty list, inserting at beginning/end
Q5. difference between interface and abstract class
Interface defines only method signatures while abstract class can have method implementations.
Interface cannot have method implementations, only method signatures
Abstract class can have method implementations along with abstract methods
A class can implement multiple interfaces but can only inherit from one abstract class
Interfaces are used to achieve multiple inheritance in Java
Abstract classes can have constructors while interfaces cannot
Q6. what is polymorphism
Polymorphism is the ability of a single function or method to operate on different types of data.
Polymorphism allows objects of different classes to be treated as objects of a common superclass.
There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).
Example: a superclass Animal with subclasses Dog and Cat. Both Dog and Cat can be treated as Animals.
Q7. java code on HashMap().
HashMap is a data structure in Java that stores key-value pairs.
HashMap is part of the Java Collections framework.
Keys in a HashMap must be unique.
Values in a HashMap can be duplicated.
Example: HashMap
map = new HashMap<>(); Example: map.put("John", 25);
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month