Dsa
Dsa
DSA
Questions for MAANG Interviews
A 10
7
B
E
12
60
20
32
D C
working professionals.
www.bosscoderacademy.com 1
#1
#1
What is a Data Structure?
A data structure is a method of presenting, storing and
manipulating data in a computer system in a way that makes
it easy to process in order to arrive at the desired output.
Some of them are arrays, linked list, stack, queue, trees and
graphs and so on.
#2
#2
What is the difference between a
Stack and a Queue?
Stack: Is based on the LIFO – Last in First Out principle.
Example: Undo operation in text editors.
www.bosscoderacademy.com 2
#3
#3
What is a Linked List?
In linked list structure each piece of data or node contains
information along with a reference pointing to its next data
item in the list.
Types:
www.bosscoderacademy.com 3
#4
#4
What is a Binary Search?
In a sorted array binary search functions by segmenting
search intervals in two equal parts during repeated iterations
to locate elements.
Steps:
Compare the middle element with the target.
The index gets returned if the match occurs.
To search smaller targets use left subarray regions
first and right subarray sections for larger targets.
www.bosscoderacademy.com 4
#5
#5
What is a Hash Table?
It gives users a storage space where key-value pairs are kept
using an array index generated by a hash function.
Example: Dictionary in Python.
It establishes a mechanism which provides rapid operations
for value insertions and key lookups and value deletions.
#6
#6
Difference between BFS and DFS?
BFS (Breadth-First Search): All neighbouring locations
receive exploration before further depth exploration
begins. Uses a queue.
www.bosscoderacademy.com 5
#7
#7
What is a Binary Search?
A tree data structure called a binary tree features nodes that
can reach a maximum of two child elements which we
identify as left and right children.
#8
#8
What is Dynamic Programming?
Through dynamic programming techniques complex
problems become solvable by splitting them into overlapping
subparts that store intermediary results to prevent repetitive
computations.
www.bosscoderacademy.com 6
#9
#9
What is the difference between a
Heap and a Priority Queue?
Heap: A binary tree framework where nodes hold
positions higher or lower than their child nodes relative
to each other.
#10
#10
What is the Time Complexity of
Binary Search?
The time complexity of the binary search is measured to be
O(log n ), since there are only two partitions of the search
space at each step.
www.bosscoderacademy.com 7
#11
#11
What are Graphs?
A graph is a set of points called nodes or vertices and a
connecting line segment called edges.
Types:
Directed and Undirected Graphs
#12
Weighted and Unweighted Graphs
#12
What is a Trie?
Trie is a tree like structure used to store the dynamic
collection of strings. It is used in the circumstances such as
auto completion, or looking up a word in a dictionary.
www.bosscoderacademy.com 8
#13
#13
What is the difference between
Merge Sort and Quick Sort?
Merge Sort: It divides the whole array into equal halves,
sorts them, and merging them.
Time complexity: O(n log n).
#14
#14
What are the differences between
Array and Linked List?
Feature Array Linked List
Storage Fixed size (contiguous) Dynamic size (nodes)
Access Random access Sequential access
Insertion Expensive (shifting) Efficient
www.bosscoderacademy.com 9
#15
#15
What is Recursion?
Recursion is a way to solve a problem by calling a function
which solved a subtype of the problem and that function
recursively calls itself until reached a base condition.
Example: Calculating factorial:
#16
factorial(n) n x factorial(n 1)
#16
Reverse a String
Problem: Reverse a given string.
www.bosscoderacademy.com 10
#17
#17
Find the Maximum Element in an
Array
Problem: Find the largest element in an array.
www.bosscoderacademy.com 11
#18
#18
Check for Palindrome
Problem: Check if a string is a palindrome.
Diagram:
www.bosscoderacademy.com 12
#19
#19
Merge Two Sorted Arrays
Problem: Merge two sorted arrays into one sorted array.
www.bosscoderacademy.com 13
#20
#20
Two Sum Problem
Problem: Find indexes of two numbers in an array that
add up to a target.
www.bosscoderacademy.com 14
Diagram:
Target: 9
Output: [0, 1]
#21
#21
Find the Missing Number
Problem: Find the missing number in an array of size n
containing numbers from 0 to n.
www.bosscoderacademy.com 15
#22
#22
Move Zeroes to End
Problem: Move Zeroes to EndMove all zeroes in an array
to the end while maintaining the order of other elements.
www.bosscoderacademy.com 16
Diagram:
#23
#23
Rotate Array
Problem: Rotate an array to the right by k steps.
www.bosscoderacademy.com 17
#24
#24
Find First Unique Character in a
String
Problem: Return the index of the first non-repeating
character in a string.
www.bosscoderacademy.com 18
#25
#25
Valid Parentheses
Problem: Check if a string containing parentheses is
valid.
www.bosscoderacademy.com 19
www.bosscoderacademy.com 20