



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
DATA STRUCTURES AND ALGORITHMS INTERVIEW QUESTIONS. These are very important questions and are frequently asked by interviewers. This will help you to crack any interview for sure.
Typology: Exams
1 / 7
This page cannot be seen from the preview
Don't miss anything!
Dear readers, these Data Structures & Algorithms Interview Questions have been designed specially to get you acquainted with the nature of questions you may encounter during your interview for the subject of Data Structures & Algorithms. As per my experience good interviewers hardly plan to ask any particular question during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer:
01. What is data-structure?
Data structure is a way of defining, storing & retrieving of data in a structural & systematic way. A data structure may contain different type of data items.
02. What are various data-structures available?
Data structure availability may vary by programming languages. Commonly available data structures are list, arrays, stack, queues, graph, tree etc.
03. What is algorithm?
Algorithm is a step by step procedure, which defines a set of instructions to be executed in certain order to get the desired output.
04. Why we need to do algorithm analysis?
A problem can be solved in more than one ways. So, many solution algorithms can be derived for a given problem. We analyse available algorithms to find and implement the best suitable algorithm.
05. What are the criteria of algorithm analysis?
An algorithm are generally analysed on two factors − time and space. That is, how much execution time and how much extra space required by the algorithm.
06. What is asymptotic analysis of an algorithm?
Asymptotic analysis of an algorithm, refers to defining the mathematical boundation/framing of its run-time performance. Using asymptotic analysis, we can very well conclude the best case, average case and worst case scenario of an algorithm.
07. What are asymptotic notations?
Asymptotic analysis can provide three levels of mathematical binding of execution time of an algorithm − Best case is represented by Οn notation. Worst case is represented by Ωn
notation. Average case is represented by Θn notation.
08. What is linear data structure?
A linear data-structure has sequentially arranged data items. The next time can be located in the next memory address. It is stored and accessed in a sequential manner. Array and list are example of linear data structure.
09. What are common operations that can be performed on a data-structure?
The following operations are commonly performed on any data-structure –
Insertion − adding a data item
Deletion − removing a data item
Traversal − accessing and/or printing all data items
Searching − finding a particular data item
Sorting − arranging data items in a pre-defined sequence
Briefly explain the approaches to develop algorithms.
There are three commonly used approaches to develop algorithms –
Greedy Approach − finding solution by choosing next best option
Divide and Conquer − diving the problem to a minimum possible sub-problem and solving them independently
Dynamic Programming − diving the problem to a minimum possible sub-problem and solving them combined
Give some examples greedy algorithms.
The below given problems find their solution using greedy algorithm approach –
Travelling Salesman Problem Prim's Minimal Spanning Tree Algorithm Kruskal's Minimal Spanning Tree Algorithm Dijkstra's Minimal Spanning Tree Algorithm Graph - Map Coloring Graph - Vertex Cover Knapsack Problem
10. What are some examples of dynamic programming algorithms?
The below given problems find their solution using divide and conquer algorithm approach
Fibonacci number series Knapsack problem
17. What operations can be performed on Queues?
The below operations can be performed on a stack –
enqueue − adds an item to rear of the queue dequeue − removes the item from front of the queue peek − gives value of front item without removing it isempty − checks if stack is empty isfull − checks if stack is full
18. What is linear searching?
Linear search tries to find an item in a sequentially arranged data type. These sequentially arranged data items known as array or list, are accessible in incrementing memory location. Linear search compares expected data item with each of data items in list or array. The
average case time complexity of linear search is Οn and worst case complexity is Ο(n 2). Data in target arrays/lists need not to be sorted.
19. What is binary search?
A binary search works only on sorted lists or arrays. This search selects the middle which splits the entire list into two parts. First the middle is compared. This search first compares the target value to the mid of the list. If it is not found, then it takes decision on whether.
20. What is bubble sort and how bubble sort works?
Bubble sort is comparison based algorithm in which each pair of adjacent elements is compared and elements are swapped if they are not in order. Because the time complexity is Ο(n 2), it is not suitable for large set of data.
21. Tell me something about 'insertion sort'?
Insertion sort divides the list into two sub-list, sorted and unsorted. It takes one element at time and finds it appropriate location in sorted sub-list and insert there. The output after insertion is a sorted sub-list. It iteratively works on all the elements of unsorted sub-list and inserts them to sorted sublist in order.
22. What is selection sort?
Selection sort is in-place sorting technique. It divides the data set into two sub-lists: sorted and unsorted. Then it selects the minimum element from unsorted sub-list and places it into the sorted list. This iterates unless all the elements from unsorted sub-list are consumed into sorted sub-list.
23. How insertion sort and selection sorts are different?
Both sorting techniques maintains two sub-lists, sorted and unsorted and both take one element at a time and places it into sorted sub-list. Insertion sort works on the current element in hand and places it in the sorted array at appropriate location maintaining the properties of insertion sort. Whereas, selection sort searches the minimum from the unsorted sub-list and replaces it with the current element in hand.
24. What is merge sort and how it works?
Merge sort is sorting algorithm based on divide and conquer programming approach. It keeps on dividing the list into smaller sub-list until all sub-list has only 1 element. And then it merges them in a sorted way until all sub-lists are consumed. It has run-time complexity of Οnlogn and it needs Οn auxiliary space.
25. What is shell sort?
Shell sort can be said a variant of insertion sort. Shell sort divides the list into smaller sublist based on some gap variable and then each sub-list is sorted using insertion sort. In best cases, it can perform upto Οnlogn.
26. How quick sort works?
Quick sort uses divide and conquer approach. It divides the list in smaller 'partitions' using 'pivot'. The values which are smaller than the pivot are arranged in the left partition and greater values are arranged in the right partition. Each partition is recursively sorted using quick sort.
27. What is a graph?
A graph is a pictorial representation of a set of objects where some pairs of objects are connected by links. The interconnected objects are represented by points termed as vertices, and the links that connect the vertices are called edges.
28. How depth first traversal works?
Depth First Search algorithmDFS traverses a graph in a depthward motion and uses a stack to remember to get the next vertex to start a search when a dead end occurs in any iteration.
29. How breadth first traversal works?
Breadth First Search algorithmBFS traverses a graph in a breadthwards motion and uses a queue to remember to get the next vertex to start a search when a dead end occurs in any iteration.
30. What is a tree?
A tree is a minimally connected graph having no loops and circuits.
31. What is a binary tree?
A binary tree has a special condition that each node can have two children at maximum.
32. What is a binary search tree?
A binary search tree is a binary tree with a special provision where a node's left child must have value less than its parent's value and node's right child must have value greater than it's parent value.
33. What is tree traversal?
Tree traversal is a process to visit all the nodes of a tree. Because, all nodes are connected via edges links we always start from the root head node. There are three ways which we use to
42. What is tower of hanoi?
Tower of Hanoi, is a mathematical puzzle which consists of three tower pegs and more than one rings. All rings are of different size and stacked upon each other where the large disk is always below the small disk. The aim is to move the tower of disk from one peg to another, without breaking its properties.
43. What is fibonacci series?
Fibonacci Series generates subsequent number by adding two previous numbers. For example − 0 1 1 2 3 5 8 13.
44. What is hashing?
Hashing is a technique to convert a range of key values into a range of indexes of an array. By using hash tables, we can create an associative data storage where data index can be find by providing its key values.
45. What is interpolation search technique?
Interpolation search is an improved variant of binary search. This search algorithm works on the probing position of required value.
46. What is the prefix and post fix notation of a + b * c + d?
Prefix Notation − * + a b + c d
Postfix Notation − a b + c d + *
Thank You! Have A Blessed Day!!!!!!