Data Structures is a favorite topic of any interviewer. This subject is best when you have to display your logical skills in an upcoming job interview or that coveted internship. Data Structures is vast. So here is the first set of interview questions the series of Data Structures Interview Questions. These questions explain the basics of data structures.
10 Basic Data Structures Interview Questions
What is the need of Data Structures?
A Data Structure can be defined as a logical or mathematical model to store data in a program and to define various operations that can be performed on the stored data. These operations represent how data is retrieved, sorted, searched, copied or merged.
What are the different operations which can be performed in data structures?
There are different kinds of data structures depending on the way the elements are associated or related to each other. Different data structures have different operations depending on the logic of that specific data structure. Operations can be generalized as insertion, deletion, access or retrieval or traversal, sorting, searching, merging and copying.
What are the categories of data structures on the basis of elements’ relationship to each other?
On the basis of the association of elements, data structures can be categorized as linear and non-linear. In linear data structures the elements are associated with each other in a linear order and they can be accessed in the linear manner- one element after another. Each element is directly associated with two elements- the preceding and the next element. Elements of non-linear data structures are randomly connected to each other. Data structure operations like traversal and searching in non-linear data structures will not be a linear fashion.
What are the types of data structures depending on the dynamics of their size?
Depending on the dynamics of the size of data structures we can classify them as static and dynamic data structures. If the size of a data structure cannot be extended or reduced when the program using it is in execution it is called a static data structure. It’s a kind of fix-sized data structure.
If the size of data structure can be increased or decreased when programming using it is in execution, it is called a dynamic data structure.
Which data structures are dynamic in nature?
Linked list is a dynamic data structure where the elements, called nodes, can be added or deleted at any location without affecting the locations of existing nodes. All data structures when implemented as linked representation are dynamic data structures. Stack when implemented using an array behaves as a static data structure and when implemented as a linked list behaves as a dynamic data structure.
What are some practical examples of data structures?
- Forward and backward buttons of a browser – two way linked list
- Redo and Undo options in different applications- stacks
- Job scheduling in Operating System- Queue
- Forking of tasks in Operating System-Tree
- Associations of users in Social Networks- Graph
- File/Directory Structure in Operating System- Tree
- Routing in Computer Networks- Graph
- Gaming-Graph and Trees
What is the difference between Traversal and Searching?
Searching is the process of locating a specific value in a data structure and retuning its location/ address. Search is successful when at least one value in a data structure matches the value being searched. Search is unsuccessful if no value in a data structure matches the searched value. Searching process terminates when the value is found.
Traversal is the process of accessing or visiting every element of the data structure once starting from the first element. Traversal is accessing all the reachable elements of a data structure.
What is the effect of insertion and deletion operations on a data structure?
Insertion increases the count of elements in a data structure. Deletion decreases the count of elements.
What is sorting? How does it affect a data structure?
Sorting is the process of arranging the elements of a data structure in increasing or decreasing order of a key value. Sorting can redefine locations of elements if there is a physical movement of elements from one location to another to sort them. It can be just rearrangement of indexes or pointers without actual shifting of elements in memory.
What are the basic advantages of using data structures in a program?
Data structures are used to increase the efficiency of data storage, organization and retrieval for a specific application. Being logical or mathematical models, programmer can define logical or mathematical expressions to perform different operations on data.
So, these are the first set Data Structures Interview Questions focusing on the basics of data structures. You will learn more in upcoming posts.