Things you need to know about your Data structure and Algorithm interview
Data structure and Algorithm related questions are very crucial part of any programming related job interview. Whether it is a Java interview or C++ interview, such questions will always be asked. Since it is entirely practical concept you will have to focus a lot on core programming concepts.
Following is the combined and detailed list of important questions that can be asked in any such interview. The questions can vary from various data structure like stack, queue and array etc. Read the questions carefully and prepare yourself beforehand so that you can confidently sit through your interview!
Q1 HOW TO SEARCH FOR THE MIDDLE ELEMENT OF LINKED LIST IN ONLY ONE PASS?
It is considered the most popular question while such interviews. However, it is very easy to answer and most of the programmers know it. In order to find the length, we have to find the last node first. The node should point to null and in second pass find the middle element by traversing only half of length.
Q2 HOW TO FIND THE LINKED LIST IF THERE IS A LOOP?
This question is in relevance to the first question. The answer is that you can use two pointer approaches to solve this issue.
Q3 WHAT IS HASHING TECHNIQUE?
Hashing technique is a procedure in which search time for any time of sequential or binary search is in independent of the number of times or elements. This technique uses a hash function to generate from a key.
Q4 TELL THE DIFFERENT TECHNIQUES FOR MAKING HASH FUNCTION?
There are four different techniques for making a hash function;
1. Truncation Method
2. Midsquare Method
3. Folding Method
4. Division Method
The next question can be to explain any of the above four methods. Prepare all the techniques briefly. The interviewer can also ask you questions or some example to solve.
Q6 HOW TO REVERSE ANY STRING IN JAVA?
String is a very important aspect of programming. There are many methods through which a string can be reversed in Java or any other programming language. List your favorite or the method you know most perfect. The interviewer can also ask you to solve a problem with the help of an API. Be prepared for that!
Q7 USE A BUBBLE SORT ALGORITHM TO WRITE A JAVA PROGRAM TO SORT AN ARRAY
Bubble sort is very simple sorting algorithm. But it has the tendency to check your programming skills. So in my point of view it is the compulsory question in any such interview.
Q8 TELL A DIFFERENCE BETWEEN QUEUE AND DATA STRUCTURE
It is also an important question to be asked in your interview. Most of the programmers know the answer very well. The main difference is that queue is a First in First out (FIFO) data structure while Stack is (LIFO) Last In First Out data structure.
Q9 WHAT IS A BINARY TREE?
A binary tree is that in which a node can only have maximum of two parts.
Q10 WHAT IS A BINARY SEARCH TREE?
This question is the part of the Tree data structures. Binary Search Tree has some significant properties. Some of them are that right sub tree contains keys with higher node value than the root, left nodes contains items whose value is less than the root etc.
Q11 WHAT IS AN EXTENDED BINARY TREE?
A binary tree can easily be converted to an extended binary tree. This can be done by adding special nodes to those which have only one part or to add them to leaf nodes. Extended binary tree is also named as 2-tree. So, the question can also be asked with this term.
Lot of questions can be asked except the above mentioned. So, be prepared. But the above mentioned questions are the core part of any interview. Hope these were helpful for you!
Written by Kaainat Maqbool
I am currently a student of journalism, pursuing my passion for writing. My words are my lifeline. I dream to be a famous news caster or an editor someday! I ocassionally writet blogs too.