pure virtual function, Deadlock, paging and segmentation, conditions of deadlock etc.
1)How a HashMap Works
A HashMap is a key-value data structure that allows fast insertion, deletion, and lookup. Its core
concept relies on hashing.
Array: Best for ACCESSING THE ELEMENT
Linked List: Best for dynamic size and efficient insertion/deletion, but slower for access and more
memory overhead
DIFFERENCE BETWEEN C++ AND JAVASCRIPT.
Feature C++ JavaScript
Type Compiled, statically-typed Interpreted, dynamically-typed
Paradigm Procedural, Object-Oriented, Generic Object-Oriented, Functional, Event-driven
Feature C++ JavaScript
What is multithreading and how did you use it in your project?
the use of #include in C
#include is a preprocessor directive in C that inserts the contents of a header file into the program
before compilation. It allows us to use built-in functions, macros, and declarations without rewriting
them. It also helps in modular programming by separating code into multiple files."
“For example, when I write #include <stdio.h>, the declarations of functions like printf and scanf are
inserted into my program so the compiler knows about them.”
aabbbb ->a2b4
FIBONACCI SERIES WITHOUT TEMP VARIABLE
IDEA
b = a + b // new b becomes the next Fibonacci number
a = b - a // restore old b as new a (no temp required)
After b = a + b, b becomes next term.
Then a = b - a gives the previous value of b.
1️⃣ Artificial Intelligence (AI)
“AI is the broad field where we try to make machines behave intelligently, like humans — such as
decision making, reasoning, and problem solving.”
Applications
Speech translation
Object recognition /detection
2️⃣ Machine Learning (ML)
“ML is a subset of AI where machines learn patterns from data instead of following hard-coded
rules.”
3️⃣ Deep Learning (DL)
“DL is a subset of ML that uses multi-layer neural networks to learn complex patterns automatically
and perform very accurate prediction.
A self-driving car uses AI for decision-making, ML for learning road patterns, and DL for image
recognition.
Example: Detecting a cat in an image
AI: The goal is to make a system that can ‘think’ and decide whether the image has a cat.
ML: We train a model using thousands of cat and non-cat images so it learns the patterns
and predicts on new images.
DL: Instead of manually giving features, a Deep Learning model (like a CNN) automatically
learns features such as ears, eyes, fur texture, and makes the prediction more accurately.
Concept Real-Life Examples
Siri/Alexa, chatbots, fraud detection, game-playing bots (Chess,
AI
Go)
Spam email detection, product recommendations (Amazon,
ML
Netflix), credit scoring
Face recognition (Face ID), self-driving cars, medical image
DL
diagnosis, voice assistants
Point Advantages of AI Disadvantages of AI
AI systems may behave incorrectly or
AI helps machines mimic human intelligence
1. Definition unpredictably if trained poorly or given
to automate complex tasks.
wrong data.
2. Accuracy & Performs tasks with high accuracy and Can produce biased or wrong results if
Efficiency speed; reduces human errors. data is biased or insufficient.
Automates repetitive, time-consuming tasks,
3. Automation
saving time and cost.
4. Decision- Can analyze massive data and give quick Decisions lack human emotion,
Making insights. empathy, and intuition.
High power consumption and
5. Availability Works 24/7 without fatigue.
maintenance cost.
6. Risk Handling
7. Provides personalized suggestions (YouTube, Raises privacy concerns due to user data
Personalization Netflix, Amazon). collection.
8. Learning & Learns from data and improves performance Training AI requires huge amounts of
Improvement over time. data and computational resources.
Easily scalable across industries like
9. Scalability
healthcare, finance, and education.
THREAD POOL
Thread Pool is a group of reusable threads that execute multiple tasks efficiently without creating
new threads each time.
🧠 Why do we need a Thread Pool?
Creating and destroying threads repeatedly is time-consuming and resource-heavy.
A thread pool improves performance, scalability, and resource management.
⚙️How does a Thread Pool work?
1. A fixed number of threads are created at the start.
2. Tasks are placed into a task queue.
3. An idle thread picks a task from the queue.
4. After finishing, the thread returns to the pool (not destroyed).
5. The process repeats.
🌟 Advantages of Thread Pool
🚀 Faster execution (no repeated thread creation)
🧠 Better CPU utilization
💾 Reduced memory overhead
🔒 Controlled number of threads (avoids system crash)
📈 Scales well for server applications
⚠️Disadvantages of Thread Pool
❌ If pool size is too small → tasks wait longer
❌ If pool size is too large → context switching overhead
❌ Poor design may cause deadlock or starvation
📌 Where Thread Pools are Used?
🌐 Web servers (handling multiple client requests)
📱 Android apps (background tasks)
☁️Cloud & backend systems
🧠 Parallel processing applications
Malloc function
malloc() (memory allocation) is a C standard library function used to dynamically allocate memory at
runtime from the heap.