1. What is a Data Structure?
The Data Structure is the way data is organized (stored) and manipulated for retrieval and access. It also
defines the way different sets of data relate to one another, establishing relationships and forming
algorithm.
2 What are some applications of Data Structures?
Numerical analysis, operating system, AI, compiler design, database management, graphics, statistical
analysis, and simulation.
3 What is an algorithm?
An algorithm is a step by step method of solving a problem or manipulating data. It
defines a set of instructions to be executed in a certain order to get the desired output
Why do we need to do an algorithm analysis?
A problem can be solved in more than one way using several solution algorithms.
Algorithm analysis provides an estimation of the required resources of an algorithm to
solve a specific computational problem. The amount of time and space resources
required to execute is also determined.
The time complexity of an algorithm quantifies the amount of time taken for an algorithm
to run as a function of the length of the input. The space complexity quantifies the
amount of space or memory taken by an algorithm, to run as a function of the length of
the input.
What is a stack?
The next one in the list of DSA interview questions is one about stack. A stack is an
abstract data type that specifies a linear data structure, as in a real physical stack or
piles where you can only take the top item off the stack in order to remove things. Thus,
insertion (push) and deletion (pop) of items take place only at one end called top of the
stack, with a particular order: LIFO (Last In First Out) or FILO (First In Last Out).
Where are stacks used?
Expression, evaluation, or conversion of evaluating prefix, postfix, and infix expressions
Syntax parsing
String reversal
Parenthesis checking
Backtracking
What is a queue Data Structure?
In this type of data structure interview questions, you can also discuss your experience
and situations using queue. A queue is an abstract data type that specifies a linear data
structure or an ordered list, using the First In First Out (FIFO) operation to access
elements. Insert operations can be performed only at one end called REAR and delete
operations can be performed only at the other end called FRONT.
List some applications of queue Data Structure.
To prioritize jobs as in the following scenarios:
As waiting lists for a single shared resource in a printer, CPU, call center systems, or
image uploads; where the first one entered is the first to be processed
In the asynchronous transfer of data; or example pipes, file IO, and sockets
As buffers in applications like MP3 media players and CD players
To maintain the playlist in media players (to add or remove the songs)
What is an asymptotic analysis of an algorithm?
Asymptotic analysis is the technique of determining an algorithm's running time in
mathematical units to determine the program's limits, also known as "run-time
performance." The purpose is to identify the best case, worst case, and average-case
times for completing a particular activity. While not a deep learning training technique,
Asymptotic analysis is an essential diagnostic tool for programmers to analyze an
algorithm's efficiency rather than its correctnes
What are asymptotic notations?
The next one in the list of DSA interview questions is one about asymptotic notations.
Asymptotic Notation represents an algorithm's running time - how long an algorithm
takes with a given input, n. Big O, large Theta (), and big Omega () are the three distinct
notations. When the running time is the same in all circumstances, big- is used, big-O
for the worst-case running time, and big- for the best case running time.
What are the advantages of binary search over a linear search?
In a sorted list:
A binary search is more efficient than a linear search because we perform fewer
comparisons. With linear search, we can only eliminate one element per comparison
each time we fail to find the value we are looking for, but with the binary search, we
eliminate half the set with each comparison.
Binary search runs in O(log n) time compared to linear search’s O(n) time. This
means that the more of the elements present in the search array, the faster is binary
search compared to a linear search.
What are the different types of data structures?
Data structures are classified as follows:
Linear data structures: A data structure is considered linear if all
its elements are arranged sequentially. In linear data structures,
elements are stored in a non-hierarchical manner, where each item
has a predecessor and a successor, except for the first and last
elements.
Non-linear data structures: A non-linear data structure does not
form a sequence; rather, each item or element is connected to two
or more other items in a non-linear arrangement. The data elements
are not organized in a sequential structure.
Explain the difference between an array and a linked list.
Arrays and linked lists are two ways to store groups of items, but they work
differently. Let’s see the main differences:
Arrays. They act like a row of boxes in memory, allowing quick
access to items by index, with a time complexity of O(1). However,
adding or removing items from the middle is challenging because it
requires shifting other items.
Linked lists. They consist of nodes, where each node holds an item
and points to the next one. This makes it easier to insert or delete
items without affecting the whole list, but finding an item takes
longer, with a time complexity of O(n).
Why do we need data structures?
● Data structures allow us to achieve an important goal: component reuse. ● Once data structure has
been implemented, it can be used again and again in various applications
How data structures are classified?
Data structures are classified into two categories based on how the data items are operated: i. Primitive
data structure ii. Non-Primitive data structure
What are the types of linked lists?
There are three types i. Singly linked list ii. Doubly linked list iii. Circularly linked list
How the singly linked lists can be represented?
Each node has two elements i. Data ii. Next
What are some applications of Data structures?
Following are some real-time applications of data structures
Decision Making
Genetics
Image Processing
Blockchain
Numerical and Statistical Analysis
Compiler Design
Database Design and many mo
Differentiate between stack and queue data structure
Stack Queue
Stack is a linear data structure where Queue is a linear data structure where data is
data is added and removed from the ended at the rear end and removed from the
top. front.
Stack is based on LIFO(Last In First Queue is based on FIFO(First In First Out)
Out) principle principle
Insertion operation in Stack is known Insertion operation in Queue is known as
as push. eneque.
Delete operation in Stack is known as Delete operation in Queue is known as
pop. dequeue.
Only one pointer is available for both Two pointers are available for addition and
addition and deletion: top() deletion: front() and rear()
Used in solving sequential processing
Used in solving recursion problems
problems
Elaborate on different types of array data structure
There are several different types of arrays:
One-dimensional array: A one-dimensional array stores its elements in contiguous
memory locations, accessing them using a single index value. It is a linear data
structure holding all the elements in a sequence.
Two-dimensional array: A two-dimensional array is a tabular array that includes rows
and columns and stores data. An M × N two-dimensional array is created by grouping
M rows and N columns into N columns and rows.
Three-dimensional array: A three-dimensional array is a grid that has rows, columns,
and depth as a third dimension. It comprises a cube with rows, columns, and depth as
a third dimension. The three-dimensional array has three subscripts for a position in a
particular row, column, and depth. Depth (dimension or layer) is the first index, row
index is the second index, and column index is the third index.
What is the need for the header?
Header of the linked list is the first element in the list and it stores the number of elements in the list. It
points to the first data element of the list.
What are push and pop operations?
• Push – adding an element to the top of stack
• Pop – removing or deleting an element from the top of stack
What is meant by traversing?
Traversing a tree means processing it in such a way, that each node is visited only once.
What is sorting?
Sorting is the process of arranging the given items in a logical order. Sorting is an example where the
analysis can be precisely performed.
Define searching ?
Searching refers to determining whether an element is present in a given list of elements or not. If the
element is present, the search is considered as successful, otherwise it is considered as an unsuccessful
search. The choice of a searching technique is based on the following factors
a. Order of elements in the list i.e., random or sorted
b. Size of the list.
Mention the types of searching ?
The types are ● Linear search ● Binary search
What is meant by linear search?
Linear search or sequential search is a method for finding a particular value in a list that consists of
checking every one of its elements, one at a time and in sequence, until the desired one is found
What is binary search?
For binary search, the array should be arranged in ascending or descending order. In each step, the
algorithm compares the search key value with the middle element of the array. If the key match, then a
matching element has been found and its index, or Position, is returned. Otherwise, if the search key is
less than the middle element, then the algorithm repeats its action on the sub-array to the left of the
middle element or, if the search key is greater, on the sub-array to the right.