0% found this document useful (0 votes)
3 views42 pages

Additional Questions

Uploaded by

ann2004maria
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views42 pages

Additional Questions

Uploaded by

ann2004maria
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1) Difference Between DBMS and RDBMS

DBMS RDBMS
Relational Database Management
Database Management System
System
Stores data as files Stores data in tables (rows & columns)
Relationship between data is not Relationships are maintained using
compulsory keys
Less secure More secure
Supports small applications Supports large enterprise applications
Example: File system, XML DB Example: MySQL, Oracle Database

) Which Programming Language Do You


Prefer?
Best Safe Answer: Python

Q: Which programming language do you prefer and why?

Answer:
“I prefer Python because it is simple, readable, and beginner-friendly. It helps in faster
development and has strong libraries for web development, AI, machine learning, and data
analysis. I used Python in academic projects because it reduced coding complexity and
improved productivity.”

If They Ask “Why not Java/C++?”

Answer:
“I know basics of other languages too, but I feel more comfortable with Python because of
its simplicity and faster implementation.”
3) OOPS 4 Pillars with Real-World Example
(1) Encapsulation

Definition

Binding data and methods into a single unit.

Real-World Example

ATM machine — user cannot directly access bank details; only allowed operations are
shown.

Interview Answer

“Encapsulation means wrapping data and functions together and restricting direct access
using access modifiers. Example: ATM machine.”

(2) Abstraction

Definition

Showing only important details and hiding implementation.

Real-World Example

Driving a car — we use steering and brakes without knowing engine internals.

Interview Answer

“Abstraction means hiding internal implementation and showing only essential features.
Example: driving a car.”
(3) Inheritance

Definition

One class acquires properties of another class.

Real-World Example

Child inherits features from parents.

Interview Answer

“Inheritance allows one class to reuse properties and methods of another class, improving
code reusability.”

(4) Polymorphism

Definition

One function behaves differently in different situations.

Real-World Example

Person behaves differently with parents, friends, and teachers.

Interview Answer

“Polymorphism means one method can perform different actions based on context.”

4) “Do You Work With Excel?”


Since you may not have professional experience, answer confidently but honestly.
Best Answer

“Yes, I have used Microsoft Excel for academic and personal work such as organizing data,
calculations, filtering, sorting, and creating tables. I’m comfortable with basic formulas
and willing to learn advanced features if required.”

5) Basic Excel Formulas to Mention


SUM
Adds numbers.

=SUM(A1:A5)

AVERAGE
Finds average.

=AVERAGE(A1:A5)

COUNT
Counts numeric cells.

=COUNT(A1:A5)

MAX / MIN
Find largest/smallest value.

=MAX(A1:A5)
=MIN(A1:A5)
IF Formula
Conditional checking.

=IF(A1>50,"Pass","Fail")

VLOOKUP (Good to Mention)


Searches value in table.

=VLOOKUP(101,A1:C10,2,FALSE)

Simple Interview Line

“I know basic Excel formulas like SUM, AVERAGE, IF, COUNT, and basic data filtering.”

6) “I Didn’t Work With SQL” — How to


Answer Smartly
Do NOT say:
“I don’t know SQL.”

Instead say:

Best Answer

“I have theoretical knowledge of SQL concepts like tables, queries, primary keys, and joins
through academics, but I haven’t worked extensively on real-time projects yet. I’m
currently improving my practical skills.”

This sounds honest + trainable.


7) Possible SQL Questions + Safe Answers
Q: What is SQL?
Answer:
“SQL stands for Structured Query Language. It is used to store, retrieve, update, and
manage data in databases.”

Q: What is a Primary Key?


Answer:
“A primary key uniquely identifies each record in a table and cannot contain NULL values.”

Q: What is a Foreign Key?


Answer:
“A foreign key is used to establish a relationship between two tables.”

Q: Difference between DELETE and DROP?


DELETE DROP
Deletes rows Deletes entire table
Structure also
Table structure remains
removed
Can rollback in some
Cannot rollback easily
DBs
Short Interview Answer

“DELETE removes data from a table, whereas DROP removes the entire table structure.”

Q: What is JOIN?
Answer:
“JOIN is used to combine data from multiple tables based on a related column.”

8) If Interviewer Asks “Do You Have Any


Questions?”
Always ask something. It shows interest.

Safe Questions to Ask

Option 1

“What technologies or tools does the team mainly work with?”

Option 2

“What would be the learning opportunities for freshers in this role?”

Option 3

“What qualities do you expect from a fresher joining the company?”

Option 4

“How does the training process work for fresh graduates?”


9) Final HR Tip
Even if you don’t know everything:

• Speak slowly and confidently


• Don’t say “I don’t know” immediately
• Say:
o “I have basic knowledge about it”
o “I’m currently learning”
o “I’m interested in improving in that area”

For fresher interviews, confidence + communication + willingness to learn matters a lot.

1) What is SMTP?
SMTP stands for:

Simple Mail Transfer Protocol


It is a protocol used to send emails over the internet.

Simple Interview Answer

“SMTP stands for Simple Mail Transfer Protocol. It is used for sending emails from a sender
to a receiver through mail servers.”

Real Example

When you send an email using Gmail or Outlook, SMTP is used behind the scenes.

2) Difference Between C and Java


C Java
Procedural language Object-oriented language
Platform dependent Platform independent
Uses pointers No direct pointer access
Faster execution Slightly slower due to JVM
Manual memory Automatic garbage
management collection
Less secure More secure

nterview Answer
Q: Difference between C and Java?

Answer:
“C is a procedural programming language mainly focused on functions, whereas Java is an
object-oriented language focused on classes and objects. Java is platform independent
because of JVM, while C is platform dependent.”

3) What is Polymorphism in Programming?


Definition
Polymorphism means:

“One thing can take many forms.”

In programming, the same method can behave differently in different situations.

Real-World Example
A person behaves differently:

• With friends
• With teachers
• With parents

Same person → different behavior.


Programming Example
A draw() function:

• Draws circle
• Draws rectangle
• Draws triangle

Same method name → different behavior.

Types of Polymorphism

(1) Compile-Time Polymorphism

Method overloading.

add(int a, int b)
add(int a, int b, int c)

(2) Run-Time Polymorphism

Method overriding.

Child class changes parent class method behavior.

Interview Answer
“Polymorphism means one method can perform different actions depending on the
situation. It improves flexibility and code reusability.”
4) Difference Between CHAR and
VARCHAR in DBMS
CHAR VARCHAR
Fixed-length data type Variable-length data type
Wastes memory if data is small Uses memory efficiently
Faster Slightly slower
Example: CHAR(10) always stores 10 VARCHAR(10) stores only required
characters characters

Example

CHAR

CHAR(10)

If value is "Ann"
Remaining spaces are filled automatically.

VARCHAR

VARCHAR(10)

If value is "Ann"
Only 3 characters are stored.

Interview Answer
“CHAR stores fixed-length data, whereas VARCHAR stores variable-length data. VARCHAR
is more memory efficient because it stores only the required number of characters.”
Bonus SQL Question From Your Image
The query in the image finds:

Customers who placed more than 3 orders.


SELECT *
FROM customers c
WHERE (
SELECT COUNT(*)
FROM orders o
WHERE [Link] = [Link]
) > 3;

Simple Explanation for Interview


• COUNT(*) counts number of orders
• Subquery checks each customer’s order count
• If count > 3, customer details are displayed

Short Answer

“This query retrieves customers who have placed more than 3 orders using a subquery and
COUNT function.”

Q1. Explain the difference between a primary key and a foreign key.

Sample Answer:
A primary key is a unique identifier for each record in a table, ensuring that no two rows
have the same primary key value. It cannot have NULL values and must be unique across
the entire table.

A foreign key, on the other hand, is a field (or a set of fields) in one table that links to the
primary key in another table. It creates a relationship between the two tables. A foreign key
can contain NULL values and does not need to be unique.
Q2. What are the advantages of using Python for data analytics?

Sample Answer:
Python is a popular choice for data analytics because it’s simple, versatile, and powerful.
Its libraries like Pandas and NumPy make data manipulation and analysis much easier.
Python also excels in data cleaning and transformation, which is crucial when working with
raw data. Its clean syntax makes it beginner-friendly, and it’s scalable, so whether I’m
working with small datasets or handling big data, Python works well. Additionally, it
integrates seamlessly with other tools, making it great for end-to-end analytics.

Q3. What is the difference between a stack and a queue?

Sample Answer:
A stack follows the LIFO (Last In, First Out) principle, where the last element added is the
first one to be removed. A queue follows FIFO (First In, First Out), where the first element
added is the first one to be removed.

Q4. Explain the concept of a binary search algorithm.

Sample Answer:
Binary search is a divide-and-conquer algorithm used to find the position of a target value
within a sorted array. It repeatedly divides the search interval in half, checking whether the
target is in the left or right half.

Q5. What are your thoughts on AI and its impact on consulting?

Sample Answer:
AI has the potential to greatly impact the consulting industry by enabling faster and more
accurate data analysis, automating repetitive tasks, and providing predictive insights. It
allows consultants to focus on higher-value tasks like strategy and client engagement.
However, AI will never fully replace human expertise, especially in complex decision-
making and client relationships. The future of consulting will likely combine AI’s
capabilities with human intuition.

Q8. What do you consider to be your greatest strength?

Sample Answer:
I would say my greatest strength is my ability to adapt quickly to new situations. Whether
it’s learning a new technology or adjusting to a new work environment, I’m always open to
change and willing to take on new challenges. I also pride myself on being a problem-
solver, using my critical thinking skills to analyze situations and come up with effective
solutions.

Q9: Tell me about a situation where you acted as a leader when a problem arose.

Answer:
“During my final-year COPD project, our team faced confusion because different
members were using different datasets and preprocessing methods, which affected the
results. I took the initiative to organize a discussion, standardize the workflow, and divide
tasks clearly among the team. This helped us complete the project on time and improved
coordination. The experience taught me the importance of communication and teamwork
in solving problems.”

1. Why do you want to work at Deloitte?

Answer:

I want to work at Deloitte because it is one of the world’s leading professional services
firms with a strong reputation in consulting, technology, audit, and innovation. I am
especially interested in how Deloitte is investing in future technologies like blockchain,
cloud services, and AI consulting.

Another reason is Deloitte’s strong work culture and focus on diversity, collaboration, and
continuous learning. As a fresher, I want to start my career in an environment where I can
learn from experienced professionals, work on impactful projects, and grow both
technically and professionally.
I also admire Deloitte’s strong global presence and client impact. Working there would give
me exposure to real-world business challenges and opportunities to improve my skills.

2. What does Deloitte do?


Answer:

“Deloitte is a professional services company that provides services such as consulting,


audit, tax, risk advisory, and financial advisory.

The company works with businesses across different industries and helps clients solve
business and technology problems.”

Important:
Say “professional services firm,” not just “accounting company.”

3. What are Deloitte’s core values?


Answer:

Deloitte’s core values are:

• Integrity
• Outstanding value to clients
• Commitment to each other
• Strength from cultural diversity

Simple explanation:

• Integrity → doing the right thing ethically


• Outstanding value → helping clients effectively
• Commitment to each other → teamwork and collaboration
• Cultural diversity → respecting different backgrounds and ideas
4. Why is integrity important at Deloitte?
Answer:

“Integrity is important because Deloitte works with major companies and clients who trust
their services. Maintaining ethical standards and professionalism is essential for building
trust and reputation.”

5. Why is diversity important in companies


like Deloitte?
Answer:

“Diversity brings different perspectives and ideas, which improves innovation and
teamwork. Working with people from different backgrounds also helps employees grow
professionally and personally.”

6. What interests you about Deloitte’s


consulting services?
Answer:

“I’m interested in Deloitte’s consulting services because they work on modern


technologies and real business challenges. Areas like AI, cloud computing, cybersecurity,
and digital transformation are exciting to me as a technology graduate.”
7. What is blockchain consulting?
Answer:

“Blockchain consulting involves helping companies implement blockchain technology


securely and efficiently for business operations like transactions, security, and record
management.”

8. What is digital transformation?


Answer:

“Digital transformation means using modern digital technologies to improve business


processes, customer experience, and overall efficiency.”

9. Who are some major clients of Deloitte?


Answer:

Some well-known Deloitte clients mentioned in the transcript include:

• Microsoft
• Boeing
• MetLife
10. Approximately how many countries
does Deloitte operate in?
Answer:

“Deloitte operates in more than 150 countries worldwide.”

11. Approximately how many employees


work at Deloitte?
Answer:

“Deloitte has more than 260,000 employees globally.”

(You can simply say “over 250,000 employees globally.”)

12. What are Deloitte’s major service


areas?
Answer:

Major service areas include:

• Consulting
• Audit & Assurance
• Tax
• Risk Advisory
• Financial Advisory
13. What do you know about Deloitte’s
work culture?
Answer:

“Deloitte is known for teamwork, collaboration, diversity, and continuous learning. The
company also focuses on employee development and maintaining a positive work
environment.”

14. Why do companies value work-life


balance?
Answer:

“Good work-life balance improves employee well-being, productivity, motivation, and job
satisfaction.”

15. What is Deloitte’s ‘WorldClass’


initiative?
Answer:

“Deloitte’s WorldClass initiative focuses on improving education and providing


opportunities for people to develop skills for the future.”
16. What is professional ethics?
Answer:

“Professional ethics are the moral principles and standards that guide behavior in the
workplace, such as honesty, responsibility, confidentiality, and integrity.”

17. Why do you think teamwork is


important?
Answer:

“Teamwork improves communication, problem-solving, productivity, and allows people to


learn from each other.”

18. How do you handle working with


people from different backgrounds?
Answer:

“I respect different opinions and communication styles. I believe diversity helps teams
become more creative and effective.”
19. What do you know about emerging
technologies Deloitte works with?
Answer:

“Deloitte works with technologies like AI, cloud computing, blockchain, analytics,
cybersecurity, and digital transformation solutions.”

20. What are your career goals?


Answer:

“My short-term goal is to build strong technical and professional skills. Long-term, I want
to grow into a role where I can contribute to impactful projects and take more
responsibilities.”

21. Why should Deloitte hire you?


Answer:

“I am a quick learner, adaptable, and willing to improve continuously. I have a technical


background in computer science and I’m eager to contribute positively while learning from
experienced professionals.”
22. Tell me about yourself
Sample Answer:

“I’m Ann Maria, a Computer Science graduate. During my academics, I worked on projects
related to AI and healthcare, including a COPD severity detection project using
spectrograms and deep learning concepts.

I’m interested in technology, problem-solving, and continuous learning. I’m now looking for
an opportunity where I can start my professional career, improve my technical skills, and
contribute effectively as part of a team.”

23. What do you know about Deloitte’s


technology focus?
Answer:

“Deloitte focuses heavily on technology consulting and innovation. The company works in
areas like AI, cloud services, cybersecurity, blockchain, and business analytics to help
organizations improve their operations.”

24. What is client service?


Answer:

“Client service means understanding customer needs, communicating professionally,


solving problems effectively, and maintaining good relationships.”
25. Why do you want to join consulting?
Answer:

“Consulting gives exposure to different industries, technologies, and business challenges.


It provides continuous learning opportunities and helps develop both technical and
communication skills.”

1. Types of Polymorphism in OOP


Polymorphism means “many forms.”
The same function or method behaves differently depending on the object or input.

There are mainly 2 types:

A) Compile-Time Polymorphism (Method Overloading)

Method overloading means the same method name can perform different tasks based on
different parameters.

Python does not support true method overloading like Java, but we can achieve similar
behavior using default arguments.

Real-life Example

Think about a person named “Alex.”

• Alex as a student studies.


• Alex as a employee works.
• Alex as a friend chats.

Same person → different behavior.

Example in Python

class Calculator:

def add(self, a, b, c=0):


return a + b + c

obj = Calculator()

print([Link](2, 3)) # 5
print([Link](2, 3, 4)) # 9

Here:

• add(2,3) adds 2 numbers


• add(2,3,4) adds 3 numbers

Same method → different behavior.

B) Run-Time Polymorphism (Method Overriding)

Method overriding happens when a child class provides its own version of a method
already present in the parent class.

Real-life Example

Different animals make different sounds.

• Dog → bark
• Cat → meow

Same action: sound()


Different outputs.

Example in Python

class Animal:
def sound(self):
print("Animal makes sound")

class Dog(Animal):
def sound(self):
print("Dog barks")
class Cat(Animal):
def sound(self):
print("Cat meows")

d = Dog()
c = Cat()

[Link]()
[Link]()

Output

Dog barks
Cat meows

2. Difference Between GROUP BY and


HAVING Clause
GROUP BY HAVING
Used to group rows with same
Used to filter grouped data
values
Comes before HAVING Comes after GROUP BY
Works on rows Works on groups
Often used with aggregate Used with conditions on
functions aggregates

Example

Suppose we have an Employee table:

Department Salary
HR 30000
HR 35000
IT 50000
IT 60000

GROUP BY

SELECT Department, AVG(Salary)


FROM Employee
GROUP BY Department;

Groups employees department-wise.

HAVING

SELECT Department, AVG(Salary)


FROM Employee
GROUP BY Department
HAVING AVG(Salary) > 40000;

Filters only departments whose average salary is greater than 40000.

3. Types of Joins
A) INNER JOIN
Returns only matching records from both tables.

Real-life Example

Students who actually enrolled in a course.

Example

SELECT [Link], Courses.course_name


FROM Students
INNER JOIN Courses
ON [Link] = Courses.student_id;
Only matching student IDs are shown.

B) OUTER JOIN
Returns matching records plus non-matching records.

Types:

• LEFT OUTER JOIN


• RIGHT OUTER JOIN
• FULL OUTER JOIN

LEFT JOIN

Returns all records from left table + matching from right.

SELECT [Link], Courses.course_name


FROM Students
LEFT JOIN Courses
ON [Link] = Courses.student_id;

Even students without courses are shown.

Real-life Example

Show all employees even if some are not assigned projects.

C) SELF JOIN
A table joins with itself.
Real-life Example

Employees and their managers are stored in the same table.

Emp_ID Name Manager_ID


1 John NULL
2 Anna 1
3 Mike 1

Query

SELECT [Link] AS Employee,


[Link] AS Manager
FROM Employee A
SELF JOIN Employee B
ON A.Manager_ID = B.Emp_ID;

Output

Anna -> John


Mike -> John

4. Operator Overloading in Python


Operator overloading means giving special meaning to operators for user-defined objects.

Example:

• + normally adds numbers


• We can make + add two objects

Python uses special methods like:

• __add__()
• __sub__()
• __mul__()
Example Program
class Student:

def __init__(self, marks):


[Link] = marks

# Overloading + operator
def __add__(self, other):
return [Link] + [Link]

s1 = Student(85)
s2 = Student(90)

result = s1 + s2

print("Total Marks:", result)

Output

Total Marks: 175

Explanation

When we write:

s1 + s2

Python internally calls:

s1.__add__(s2)

So the + operator is overloaded for Student objects.

1. “Why should we hire you when AI can do most tasks


now?”
Answer:
AI can definitely improve speed and automation, but companies still need people who can
think critically, communicate with teams, understand real-world problems, and make
decisions responsibly.

As a fresher, I may not know everything yet, but I learn quickly and adapt to new
technologies. Instead of seeing AI as competition, I see it as a tool that can help me work
more efficiently. I can combine technical knowledge, teamwork, and problem-solving with
AI tools to deliver better results.

2. “If you had the power to solve one problem using AI,
what would you choose?”
Answer:

I would use AI in healthcare, especially for early disease detection in rural areas where
doctors are not always available.

For example, AI systems can help identify diseases early through medical images or
patient data, which can save lives and reduce treatment costs. Since I also worked on a
COPD-related project, I became interested in how AI can support healthcare professionals
and improve accessibility.

3. “Suppose AI replaces your current role in the future.


What will you do?”
Answer:

I believe technology will change roles, but it will also create new opportunities. Instead of
resisting change, I would continuously upgrade my skills and learn emerging technologies.

People who adapt and learn will always remain valuable. I would focus on skills like
problem-solving, communication, teamwork, and understanding business needs, because
those are difficult to fully replace.
4. “Imagine your team misses a deadline because one
member did not complete their work. What would you
do?”
Answer:

First, I would avoid blaming the person immediately and understand the reason behind the
delay. Then I would discuss with the team how we can divide the remaining work and
complete the critical tasks first.

If needed, I would inform the project lead honestly about the situation and provide a
realistic updated timeline. I believe solving the problem calmly is more important than
blaming people.

5. “You are leading a project. Two team members are


arguing continuously. How will you handle it?”
Answer:

I would first speak to both members individually to understand their perspectives. Then I
would arrange a discussion focused on the project goal rather than personal differences.

I would encourage professional communication and assign clear responsibilities so


confusion reduces. A good leader should maintain teamwork and ensure personal
conflicts do not affect project performance.

6. “If your manager asks you to do something you think is


wrong, what will you do?”
Answer:

I would first make sure I fully understand the task and why it is being asked. If I still feel it is
unethical or harmful, I would respectfully communicate my concern with valid reasons.
I believe professionalism includes honesty and responsibility. I would try to find an
alternative solution instead of simply refusing emotionally.

7. “Suppose your project fails. How will you react?”


Answer:

I would first analyze what went wrong and identify the lessons from the failure. Instead of
getting discouraged, I would focus on improving the process and avoiding the same
mistakes in future projects.

Failure can be a learning opportunity if we handle it positively.

8. “You have multiple deadlines at the same time. How


will you manage them?”
Answer:

I would prioritize tasks based on urgency and importance. I would divide the work into
smaller steps, create a schedule, and focus on completing high-priority tasks first.

If needed, I would also communicate early with the team or manager rather than waiting
until the last moment.

9. “What would you do if your teammate takes credit for


your work?”
Answer:

I would first handle it professionally and avoid reacting emotionally. I would speak privately
with the teammate and clarify the situation respectfully.
I believe teamwork is important, but proper recognition also matters. If the issue
continues, I would discuss it calmly with the team lead.

10. “If you could automate one daily activity using AI,
what would it be?”
Answer:

I would automate repetitive documentation and scheduling tasks because they consume a
lot of time in many organizations.

AI can handle repetitive administrative work, allowing employees to focus more on


creativity, problem-solving, and decision-making.

11. “Tell me about a situation where you solved a


problem.”
Answer:

During my academic project, we faced issues with integrating different modules properly.
Instead of panicking, we divided the problem into smaller parts, identified where the issue
was occurring, and tested each module step by step.

By coordinating as a team and communicating regularly, we were able to fix the issue and
complete the project successfully.

12. “If your teammate is weaker than others, how will you
work with them?”
Answer:
I would support them instead of ignoring them because team success is more important
than individual performance.

I would help clarify tasks, share resources if needed, and encourage collaboration.
Everyone learns at different speeds, and a supportive environment improves overall
productivity.

13. “You are given a task you have never done before.
What will you do?”
Answer:

I would first understand the requirements clearly, then research and learn the necessary
concepts. I am comfortable learning independently and asking for guidance when needed.

I believe adaptability and willingness to learn are very important for freshers.

14. “Would you choose accuracy or speed?”


Answer:

I believe both are important, but the priority depends on the situation.

For critical tasks, accuracy is more important because small mistakes can create bigger
problems. However, in fast-moving environments, maintaining a balance between speed
and quality is necessary.

15. “What makes humans valuable when AI exists?”


Answer:

AI is powerful in processing data and automation, but humans bring creativity, emotional
intelligence, ethical judgment, leadership, and real-world understanding.
The best results come when humans and AI work together rather than replacing each other
completely.

1. Linear Search

Linear search checks elements one by one until the target is found.

Example:
Array = [10, 20, 30, 40]
Searching for 30:

• Check 10
• Check 20
• Check 30 → found

Time Complexity

• Best Case: O(1) → element found at first position


• Average Case: O(n)
• Worst Case: O(n) → element at last position or not present

Use Case:
Used when data is unsorted or small.

2. Binary Search

Binary search works only on sorted data.


It repeatedly divides the array into halves.

Example:
Array = [10, 20, 30, 40, 50]
Searching for 30:

• Middle = 30 → found directly

Searching for 50:


• Middle = 30
• Go right → 40, 50
• Middle = 50 → found

Time Complexity

• Best Case: O(1)


• Average Case: O(log n)
• Worst Case: O(log n)

Because every step removes half the elements.

Use Case:
Efficient for large sorted datasets.

3. Merge Sort

Merge sort is a sorting algorithm, not a searching algorithm.


It uses Divide and Conquer.

Steps:

1. Divide array into halves


2. Sort each half
3. Merge them back in sorted order

Example:
[4,2,1,3]

Split:

• [4,2] and [1,3]

Sort:

• [2,4] and [1,3]

Merge:

• [1,2,3,4]
Time Complexity

• Best Case: O(n log n)


• Average Case: O(n log n)
• Worst Case: O(n log n)

Advantages

• Stable sorting
• Good for large datasets

Disadvantage

• Uses extra memory

Difference Between BFS and DFS


Feature BFS DFS
Full Form Breadth First Search Depth First Search
Approach Visits level by level Goes deep first
Data Structure
Queue Stack / Recursion
Used
Shortest Path Finds shortest path May not find shortest
Memory Usage More Less
Shortest path, Cycle detection,
Applications
networking backtracking

BFS Example

Graph traversal:

• Visit neighbors first


• Order: A → B → C → D

DFS Example

• Go deep into one branch first


• Order: A → B → D → C

Difference Between Array and Linked List


Feature Array Linked List
Continuous
Memory Non-continuous memory
memory
Size Fixed Dynamic
Fast (O(1)
Access Speed Slow (O(n))
indexing)
Insertion/Deletion Costly Easy
More (extra pointer
Memory Usage Less
needed)

Array

Example:
[10,20,30]

• Fast access using index


• Best when size is known

Linked List

Example:
10 → 20 → 30

• Nodes connected using pointers


• Easy insertion and deletion

Simple Interview Summary

• Linear Search → checks one by one → O(n)


• Binary Search → works on sorted data → O(log n)
• Merge Sort → divide and merge sorting → O(n log n)
• BFS → level-wise traversal using Queue
• DFS → depth-wise traversal using Stack
• Array → fixed size, fast access
• Linked List → dynamic size, easy insertion/deletion
insertion, selection and quick sort too?

1. Insertion Sort
Insertion sort places each element in its correct position, similar to arranging playing cards
in hand.

Example:
Array = [5, 3, 4, 1]

Steps:

• Compare 3 with 5 → place before 5 → [3,5,4,1]


• Compare 4 with 5 → insert → [3,4,5,1]
• Compare 1 with all → [1,3,4,5]

Time Complexity

• Best Case: O(n) → already sorted


• Average Case: O(n²)
• Worst Case: O(n²) → reverse sorted

Advantages

• Simple
• Efficient for small datasets

Disadvantage

• Slow for large datasets


2. Selection Sort
Selection sort repeatedly selects the smallest element and places it at the beginning.

Example:
Array = [64, 25, 12, 22]

Steps:

• Smallest = 12 → swap with 64


[12,25,64,22]
• Smallest from remaining = 22
[12,22,64,25]
• Smallest = 25
[12,22,25,64]

Time Complexity

• Best Case: O(n²)


• Average Case: O(n²)
• Worst Case: O(n²)

Advantages

• Simple
• Performs fewer swaps

Disadvantage

• Inefficient for large data

3. Quick Sort
Quick sort uses Divide and Conquer.

It selects a pivot element and arranges:


• smaller elements to the left
• larger elements to the right

Then recursively sorts both sides.

Example:
Array = [6, 3, 8, 5, 2]

Choose pivot = 5

After partition:
[3,2] 5 [6,8]

Sort left and right:


[2,3,5,6,8]

Time Complexity

• Best Case: O(n log n)


• Average Case: O(n log n)
• Worst Case: O(n²)
(when pivot selection is poor)

Advantages

• Very fast in practice


• Widely used

Disadvantage

• Worst case can become slow

Quick Comparison Table


Average Worst
Sorting Algorithm Best Case
Case Case
Insertion Sort O(n) O(n²) O(n²)
Selection Sort O(n²) O(n²) O(n²)
O(n log O(n log
Merge Sort O(n log n)
n) n)
O(n log
Quick Sort O(n log n) O(n²)
n)

Simple Interview One-Line Answers


• Insertion Sort: Inserts elements into correct position one by one.
• Selection Sort: Selects minimum element repeatedly and places it correctly.
• Quick Sort: Uses pivot partitioning and divide-and-conquer strategy.
• Merge Sort: Divides array and merges sorted halves.

You might also like