# 50+ Data Structure, Algorithms & Programming Languages Interview Questions for Programmers

By Kimberly Cook
1. How do you find the missing number in a given integer array of 1 to 100? (solution)
2. How do you find the duplicate number on a given integer array? (solution)
3. How do you find the largest and smallest number in an unsorted integer array? (solution)
4. How do you find all pairs of an integer array whose sum is equal to a given number? (solution)
5. How do you find duplicate numbers in an array if it contains multiple duplicates? (solution)
6. How are duplicates removed from a given array in Java? (solution)
7. How is an integer array sorted in place using the quicksort algorithm? (solution)
8. How do you remove duplicates from an array in place? (solution)
9. How do you reverse an array in place in Java? (solution)
10. How are duplicates removed from an array without using any library? (solution)
1. How do you find the middle element of a singly linked list in one pass? (solution)
2. How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle? (solution)
3. How do you reverse a linked list? (solution)
4. How do you reverse a singly linked list without recursion? (solution)
5. How are duplicate nodes removed in an unsorted linked list? (solution)
6. How do you find the length of a singly linked list? (solution)
7. How do you find the third node from the end in a singly linked list? (solution)
8. How do you find the sum of two linked lists using Stack? (solution)
1. How do you print duplicate characters from a string? (solution)
2. How do you check if two strings are anagrams of each other? (solution)
3. How do you print the first non-repeated character from a string? (solution)
4. How can a given string be reversed using recursion? (solution)
5. How do you check if a string contains only digits? (solution)
6. How are duplicate characters found in a string? (solution)
7. How do you count a number of vowels and consonants in a given string? (solution)
8. How do you count the occurrence of a given character in a string? (solution)
9. How do you find all permutations of a string? (solution)
10. How do you reverse words in a given sentence without using any library method? (solution)
11. How do you check if two strings are a rotation of each other? (solution)
12. How do you check if a given string is a palindrome? (solution)
These questions help improve your knowledge of string as a data structure. If you can solve all these String questions without any help then you are in good shape. For more advanced questions, I suggest you solve problems given in the Algorithm Design Manual by Steven Skiena, a book with the toughest algorithm questions. If you need more practice, here is another list of 20 string coding questions. 4. Binary Tree Coding Interview Questions So far, we have looked at only the linear data structure, but all information in the real world cannot be represented in linear fashion, and that’s where tree data structure helps. Tree data structure is a data structure that allows you to store your data in a hierarchical fashion. Depending on how you store data, there are different types of trees, such as a binary tree, where each node has, at most, two child nodes.a Along with its close cousin binary search tree, it’s also one of the most popular tree data structures. Therefore, you will find a lot of questions based on them, such as how to traverse them, count nodes, find depth, and check if they are balanced or not. A key point to solving binary tree questions is a strong knowledge of theory, e.g. what is the size or depth of the binary tree, what is a leaf, and what is a node, as well as an understanding of the popular traversing algorithms, e.g. pre-, post-, and in-order traversal. Here is a list of popular binary tree-based coding questions from software engineer or developer job interviews:
• How is a binary search tree implemented? (solution)
• How do you perform preorder traversal in a given binary tree? (solution)
• How do you traverse a given binary tree in preorder without recursion? (solution)
• How do you perform an inorder traversal in a given binary tree? (solution)
• How do you print all nodes of a given binary tree using inorder traversal without recursion? (solution)
• How do you implement a postorder traversal algorithm? (solution)
• How do you traverse a binary tree in postorder traversal without recursion? (solution)
• How are all leaves of a binary search tree printed? (solution)
• How do you count a number of leaf nodes in a given binary tree? (solution)
• How do you perform a binary search in a given array? (solution)
If you feel that your understanding of binary tree coding is inadequate and you can’t solve these questions on your own, I suggest you go back and pick a good data structure and algorithm course like From 0 to 1: Data Structures & Algorithms in Java. If you need some more recommendations, here is my list of useful data structure algorithm books and courses to start with. 5. Miscellaneous Coding Interview Questions Apart from data structure-based questions, most of the programming job interviews also ask algorithm, design, bit manipulation, and general logic-based questions, which I’ll describe in this section. It’s important that you practice these concepts because sometimes they become tricky to solve in the actual interview. Having practiced them before not only makes you familiar with them but also gives you more confidence in explaining the solution to the interviewer.
• How is a bubble sort algorithm implemented? (solution)
• How is an iterative quicksort algorithm implemented? (solution)
• How do you implement an insertion sort algorithm? (solution)
• How is a merge sort algorithm implemented? (solution)
• How do you implement a bucket sort algorithm? (solution)
• How do you implement a counting sort algorithm? (solution)
• How is a radix sort algorithm implemented? (solution)
• How do you swap two numbers without using the third variable? (solution)
• How do you check if two rectangles overlap with each other? (solution)
• How do you design a vending machine? (solution)