Q1. What is Artificial Intelligence, and how is it different from traditional programming?

Answer: Artificial Intelligence (AI) is the branch of computer science that builds systems able to perform tasks that normally require human intelligence, such as understanding language, recognising images, reasoning, planning and making decisions.

The core difference is where the logic comes from:

Traditional ProgrammingAI / Machine Learning
Humans write explicit rules: Data + Rules → OutputThe system learns the rules: Data + Output → Rules (model)
Best when rules are clear and stable (billing, sorting)Best when rules are too complex to write (face recognition, spam detection)
Changes only when code is editedImproves when it gets more or better data

Example: A traditional spam filter blocks emails containing "FREE MONEY". An AI spam filter learns patterns from thousands of labelled emails and can catch spam it has never seen before.

Q2. What is the difference between AI, Machine Learning, Deep Learning and Generative AI?

Answer: They are nested fields, each a subset of the previous one:

  • AI: The broadest field. Any technique that makes machines behave intelligently, including rule-based expert systems and search algorithms.

  • Machine Learning (ML): A subset of AI where systems learn patterns from data instead of following hand-written rules (e.g., decision trees, linear regression).

  • Deep Learning (DL): A subset of ML that uses multi-layer neural networks to learn features automatically from raw data such as images, audio and text (e.g., CNNs, Transformers).

  • Generative AI: A subset of DL focused on creating new content (text, images, code, audio) rather than only classifying or predicting (e.g., GPT, Claude, Stable Diffusion).

Key point: All deep learning is ML, and all ML is AI, but not the other way round. A chess engine using minimax search is AI but not ML.

Q3. What are the types of AI based on capability?

Answer:

  1. Narrow AI (Weak AI / ANI): Designed for a specific task or a limited set of tasks. All AI that exists today is narrow, including voice assistants, recommendation engines and chatbots. It cannot transfer its intelligence to unrelated domains on its own.

  2. General AI (Strong AI / AGI): A hypothetical AI that could understand, learn and perform any intellectual task a human can, and transfer knowledge across domains. It is an active research goal but has not been achieved.

  3. Super AI (ASI): A hypothetical AI that would surpass human intelligence in every field, including creativity, problem-solving and social skills. It is mostly discussed in AI safety and philosophy.

Interview tip: Even very capable LLMs are classified as Narrow AI by most experts because they lack robust, autonomous general intelligence, although this boundary is increasingly debated.

Q4. What are the types of AI based on functionality?

Answer:

  1. Reactive Machines: Respond only to the current input, with no memory of the past. Example: IBM's Deep Blue, which beat Garry Kasparov at chess in 1997.

  2. Limited Memory: Use historical or recent data to make better decisions. Almost all modern AI falls here. Examples: self-driving cars tracking nearby vehicles, ML models trained on past data, chatbots using conversation history.

  3. Theory of Mind: Would understand human emotions, beliefs, intentions and social interaction. This is still at the research stage.

  4. Self-Aware AI: Would have consciousness and self-awareness. Purely hypothetical.

Difference from Q3: Capability classifies AI by how intelligent it is. Functionality classifies it by how it works and uses memory.

Q5. What is the Turing Test, and what are its limitations?

Answer: Proposed by Alan Turing in 1950 in his paper "Computing Machinery and Intelligence", the Turing Test (the "Imitation Game") checks whether a machine can show behaviour indistinguishable from a human. A human judge holds text conversations with a human and a machine. If the judge cannot reliably tell which is which, the machine passes.

Limitations:

  • It tests imitation, not understanding. A system can sound human without truly understanding anything.

  • It covers only language, not perception, physical reasoning or real-world action.

  • It can be passed through tricks and deception, such as deliberately making typos or dodging questions.

  • Results depend heavily on the judge's skill.

Today, researchers prefer task-based benchmarks for reasoning, coding, maths and safety over the Turing Test.

Q6. What was the Dartmouth Conference, and what are the major milestones in the history of AI?

Answer: The Dartmouth Summer Research Project (1956), organised by John McCarthy, Marvin Minsky, Claude Shannon and Nathaniel Rochester, is considered the birth of AI as a field. McCarthy coined the term "Artificial Intelligence" in the proposal for it.

Major milestones:

  • 1950: Turing proposes the Turing Test.

  • 1956: Dartmouth Conference.

  • 1966: ELIZA, an early chatbot.

  • 1970s–80s: Expert systems such as MYCIN and XCON.

  • 1997: IBM Deep Blue defeats Garry Kasparov.

  • 2011: IBM Watson wins Jeopardy!

  • 2012: AlexNet wins ImageNet and starts the deep learning boom.

  • 2016: DeepMind's AlphaGo beats Lee Sedol at Go.

  • 2017: The "Attention Is All You Need" paper introduces the Transformer.

  • 2022 onwards: ChatGPT and the generative AI wave, followed by multimodal models, reasoning models and AI agents.

Q7. What were the "AI Winters", and why did they happen?

Answer: AI Winters were periods when funding and interest in AI dropped sharply because results failed to meet expectations.

  • First AI Winter (~1974–1980): Early promises of human-level AI did not come true. The Lighthill Report (1973) in the UK criticised AI's failure to scale beyond toy problems, and governments cut funding. Problems included combinatorial explosion and very limited computing power.

  • Second AI Winter (~1987–1993): Expert systems were expensive to build and maintain, brittle outside their narrow domain, and could not learn. The specialised LISP machine market also collapsed.

Lessons for today: Over-hyping AI capabilities, ignoring computing and data limits, and failing to deliver real business value can all trigger disillusionment. This is why responsible communication about what AI can and cannot do matters.

Q8. What is the Chinese Room argument?

Answer: The Chinese Room is a thought experiment proposed by philosopher John Searle in 1980 to challenge the idea that a computer running the right program truly "understands".

The setup: A person who knows no Chinese sits in a room with a rulebook. Chinese questions are passed in, and by following the rulebook, the person produces correct Chinese answers. To outsiders, the room appears to understand Chinese, but the person inside understands nothing. They are only manipulating symbols.

Searle's conclusion: Symbol manipulation (syntax) is not the same as understanding (semantics). Passing the Turing Test does not prove a machine has a mind. This is the argument against "Strong AI".

Common counter-argument (the Systems Reply): The person does not understand Chinese, but the whole system (person + rulebook + room) might. The debate is still relevant to discussions about whether LLMs "understand" language.

Q9. What are some real-world applications of AI across industries?

Answer:

  • Healthcare: Disease detection from X-rays and MRIs, drug discovery, protein structure prediction (AlphaFold), clinical documentation.

  • Finance: Fraud detection, credit scoring, algorithmic trading, risk analysis.

  • Retail & E-commerce: Recommendation engines, demand forecasting, dynamic pricing, visual search.

  • Transportation: Self-driving cars, route optimisation, traffic prediction.

  • Manufacturing: Predictive maintenance, quality inspection with computer vision, robotics.

  • Agriculture: Crop disease detection, yield prediction, precision farming with drones.

  • Education: Personalised learning, AI tutors, automatic grading.

  • Customer Service: Chatbots, voice assistants, sentiment analysis.

  • Software Development: AI coding assistants, automated testing, code review.

  • Cybersecurity: Threat detection and anomaly detection in network traffic.

Q10. What are the main branches or subfields of AI?

Answer:

  1. Machine Learning: Learning patterns from data.

  2. Deep Learning: Multi-layer neural networks.

  3. Natural Language Processing (NLP): Understanding and generating human language.

  4. Computer Vision: Understanding images and video.

  5. Robotics: Machines that sense and act in the physical world.

  6. Expert Systems: Rule-based systems that emulate human experts.

  7. Knowledge Representation & Reasoning: Storing knowledge and drawing logical conclusions.

  8. Planning & Search: Finding sequences of actions to reach goals.

  9. Speech Processing: Speech recognition and text-to-speech.

  10. Fuzzy Logic: Reasoning with degrees of truth.

  11. Reinforcement Learning: Learning through rewards and penalties.

  12. Generative AI: Creating new content.

Real systems usually combine several branches. A self-driving car uses computer vision, planning, reinforcement learning and robotics together.

Q11. What is the difference between Symbolic AI and Connectionist AI?

Answer:

Symbolic AI (GOFAI)Connectionist AI
Represents knowledge with explicit symbols, rules and logicRepresents knowledge as patterns of weights in neural networks
Knowledge is hand-crafted by expertsKnowledge is learned from data
Highly explainableOften a "black box"
Brittle with noisy or unseen dataRobust to noise, generalises well
Good at logic, planning, rule-followingGood at perception, language, pattern recognition
Examples: expert systems, Prolog, knowledge graphsExamples: CNNs, Transformers, LLMs

Neuro-symbolic AI combines the two, using neural networks for perception and symbolic reasoning for logic and explainability. It is an active research area for building more reliable and interpretable systems.

Q12. Why is data so important in AI? Explain "Garbage In, Garbage Out".

Answer: In ML-based AI, the model learns everything from data. Its behaviour, accuracy and fairness are directly limited by the quality of that data.

"Garbage In, Garbage Out" (GIGO) means that if you train a model on poor data, the model will be poor, no matter how advanced the algorithm. Poor data can be inaccurate, incomplete, biased, outdated or wrongly labelled.

Qualities of good training data:

  • Accurate: Correct values and labels.

  • Complete: Few missing values.

  • Representative: Covers all real-world scenarios and user groups.

  • Consistent: Same formats and definitions throughout.

  • Relevant: Related to the problem being solved.

  • Sufficient: Enough examples to learn from.

  • Timely: Reflects current conditions.

Real-world insight: Data scientists commonly spend most of their time on data collection, cleaning and preparation rather than modelling. Improving data quality often helps more than changing the algorithm, which is the idea behind "data-centric AI".

Q13. What is the difference between structured, semi-structured and unstructured data?

Answer:

  • Structured data: Organised in a fixed schema of rows and columns. Easy to store in relational databases and query with SQL. Examples: sales tables, bank transactions, Excel sheets.

  • Semi-structured data: Has some organisation through tags or keys but no rigid schema. Examples: JSON, XML, emails (headers plus body), log files.

  • Unstructured data: No predefined format. Examples: images, videos, audio, free text, PDFs, social media posts.

Relevance to AI: Classical ML algorithms work best with structured, tabular data. Deep learning and Generative AI made it possible to extract value from unstructured data, which makes up the large majority of the world's data. For example, a CNN can read X-rays and an LLM can summarise contracts.

Q14. What are training, validation and test datasets? Why do we need all three?

Answer:

  • Training set (~60–80%): Used to fit the model, so the model learns its parameters (weights) from this data.

  • Validation set (~10–20%): Used during development to tune hyperparameters, compare models and decide when to stop training. The model does not learn from it directly, but our choices are influenced by it.

  • Test set (~10–20%): Used only once, at the end, to estimate how the final model will perform on truly unseen data.

Why all three? If you tune the model using the test set, you indirectly "leak" test information into your decisions, and the reported performance becomes over-optimistic. The validation set absorbs that tuning, keeping the test set an honest final exam.

Good practices: Use stratified splits for imbalanced classes, time-based splits for time-series data (never train on the future), and cross-validation when data is small.

Q15. What is the difference between model parameters and hyperparameters?

Answer:

ParametersHyperparameters
Learned automatically from data during trainingSet manually (or by a tuning search) before training
Define the trained model's behaviourControl how the model learns
Examples: weights and biases in a neural network, coefficients in linear regression, split points in a decision treeExamples: learning rate, number of layers, batch size, number of trees, max depth, regularisation strength, k in KNN
Saved as part of the modelChosen through experimentation

Analogy: Hyperparameters are like the settings on an oven (temperature, time). Parameters are what the cake becomes after baking.

Hyperparameters are tuned using methods such as grid search, random search or Bayesian optimisation, evaluated on a validation set.

Q16. What are features and labels in machine learning?

Answer:

  • Features (X / input variables / independent variables): The measurable properties used to make a prediction.

  • Label (y / target / dependent variable): The output the model is trying to predict.

Example: house price prediction

  • Features: area in sq. ft, number of bedrooms, location, age of the house.

  • Label: the house price.

Example: email spam detection

  • Features: word frequencies, sender domain, number of links.

  • Label: Spam / Not Spam.

Key points:

  • Supervised learning needs both features and labels. Unsupervised learning uses only features.

  • Feature engineering, the process of creating and selecting good features, often improves model performance more than changing the algorithm.

  • Labels must be accurate. Noisy labels directly limit how good the model can become.

Q17. Explain the AI/ML project lifecycle.

Answer:

  1. Problem Definition: Understand the business goal, define success metrics, and check whether AI is even needed.

  2. Data Collection: Gather data from databases, APIs, sensors, logs or labelling efforts.

  3. Data Preparation: Clean, handle missing values, remove duplicates, label, and split into train, validation and test sets.

  4. Exploratory Data Analysis (EDA): Understand distributions, correlations, outliers and imbalances.

  5. Feature Engineering: Create, transform and select useful features.

  6. Model Selection & Training: Try candidate algorithms and train them.

  7. Evaluation & Tuning: Measure with the right metrics and tune hyperparameters.

  8. Deployment: Serve the model through APIs, batch jobs or edge devices.

  9. Monitoring & Maintenance: Track performance and drift, then retrain when needed.

  10. Feedback & Iteration: Use new data and user feedback to improve.

The lifecycle is iterative, not linear. Teams frequently loop back to earlier stages, for example from evaluation back to data collection.

Q18. What is the difference between training and inference in AI?

Answer:

TrainingInference
The model learns from data by adjusting its parametersThe trained model makes predictions on new data
Happens once or periodicallyHappens continuously in production, often millions of times
Very compute-heavy (GPUs/TPUs, hours to months)Lighter per request, but latency and cost matter at scale
Needs labelled data (in supervised learning)Needs only the input
Involves forward pass + backpropagation + weight updatesInvolves only a forward pass

Example: Training a spam classifier on 1 million emails is training. Classifying a new incoming email in milliseconds is inference.

Why it matters: For large models, total inference cost over the product's lifetime often exceeds training cost. That is why techniques like quantisation, caching and batching are important in production.

Q19. What are the advantages and limitations of AI?

Answer:

Advantages:

  • Automation of repetitive tasks, saving time and cost.

  • Speed and scale: Processes huge volumes of data quickly.

  • Consistency: No fatigue, available 24/7.

  • Pattern discovery: Finds insights humans may miss.

  • Personalisation: Tailored recommendations and experiences.

  • Safety: Handles dangerous tasks such as mining, bomb disposal and space exploration.

Limitations:

  • Data dependency: Needs large amounts of quality data.

  • Bias: Can learn and amplify unfair patterns from data.

  • Lack of explainability: Many models are black boxes.

  • Hallucinations and errors: Can be confidently wrong.

  • No true common sense or understanding in many contexts.

  • High cost: Compute, energy and specialised talent.

  • Security risks: Adversarial attacks, prompt injection, misuse such as deepfakes.

  • Ethical and legal concerns: Privacy, accountability, job displacement.

Q20. What is Computer Vision, and what are its common tasks?

Answer: Computer Vision (CV) is the field of AI that enables machines to interpret and understand visual information from images and videos.

Common tasks:

  • Image Classification: What is in the image? ("cat")

  • Object Detection: What objects are present, and where? (bounding boxes)

  • Semantic Segmentation: Label every pixel with a class.

  • Instance Segmentation: Separate each individual object at pixel level.

  • Facial Recognition: Identify or verify people.

  • Optical Character Recognition (OCR): Extract text from images.

  • Pose Estimation: Detect body keypoints.

  • Image Generation: Create images from text (diffusion models).

Common techniques: CNNs (ResNet, EfficientNet), Vision Transformers (ViT), YOLO for real-time detection, U-Net for segmentation.

Applications: Medical imaging, autonomous vehicles, retail shelf monitoring, manufacturing defect detection, surveillance.

Q21. What is Natural Language Processing (NLP), and what are its common preprocessing steps?

Answer: NLP is the branch of AI that enables machines to understand, interpret and generate human language.

Common tasks: sentiment analysis, machine translation, named entity recognition (NER), text classification, summarisation, question answering, chatbots.

Classical preprocessing steps:

  1. Tokenisation: Splitting text into words or subwords.

  2. Lowercasing: Normalising case.

  3. Removing punctuation and special characters.

  4. Stop-word removal: Removing very common words like "the" and "is".

  5. Stemming: Cutting words to a crude root ("running" → "run", "studies" → "studi").

  6. Lemmatisation: Converting to the proper dictionary form ("better" → "good", "studies" → "study").

  7. Vectorisation: Converting text to numbers (Bag of Words, TF-IDF, embeddings).

Modern note: Transformer-based models use subword tokenisers (like BPE) and usually do not need stop-word removal or stemming. They learn context from the raw text.

Q22. What is the role of AI in robotics?

Answer: Robotics deals with physical machines that sense, decide and act. AI provides the "brain" that turns a pre-programmed machine into an intelligent, adaptive one.

How AI is used in robotics:

  • Perception: Computer vision, LiDAR processing and sensor fusion to understand surroundings.

  • Localisation & Mapping: SLAM (Simultaneous Localisation and Mapping) to build a map while tracking position.

  • Path Planning: Search algorithms like A* and RRT to find safe routes.

  • Control & Manipulation: Reinforcement learning to learn grasping, walking and balancing.

  • Human-Robot Interaction: Speech recognition and NLP for natural commands.

  • Embodied AI / Vision-Language-Action models: Robots that follow natural-language instructions using large multimodal models.

Examples: Warehouse robots, robotic surgery assistants, autonomous drones, robot vacuum cleaners, humanoid robots.

Key challenge: The "sim-to-real gap". Behaviour learned in simulation often fails in the messy real world.

Q23. What is an Expert System, and what are its components?

Answer: An Expert System is a rule-based AI program that emulates the decision-making ability of a human expert in a specific domain. It was popular in the 1970s–80s. Examples: MYCIN for diagnosing blood infections, XCON for configuring computers.

Components:

  1. Knowledge Base: Stores domain facts and rules (IF–THEN), collected from human experts.

  2. Inference Engine: Applies logical rules to the knowledge base to derive conclusions, using forward chaining or backward chaining.

  3. User Interface: Allows users to enter queries and receive answers.

  4. Explanation Facility: Explains why and how a conclusion was reached.

  5. Knowledge Acquisition Module: Helps add or update knowledge.

Advantages: Consistent, explainable, preserves expert knowledge, available 24/7.

Disadvantages: Expensive to build (the knowledge acquisition bottleneck), cannot learn by itself, brittle outside its narrow domain, hard to maintain as rules grow.

Q24. What is Fuzzy Logic, and how is it different from Boolean logic?

Answer: Boolean logic works with two values only: TRUE (1) or FALSE (0). Fuzzy logic, introduced by Lotfi Zadeh in 1965, allows degrees of truth between 0 and 1, which mirrors how humans reason with vague concepts.

Example: Is 28°C "hot"?

  • Boolean: Hot if temperature > 30°C, so 28°C is "not hot".

  • Fuzzy: 28°C is "hot" with membership 0.7 and "warm" with membership 0.3.

How a fuzzy system works:

  1. Fuzzification: Convert crisp inputs into fuzzy membership values.

  2. Rule Evaluation: Apply rules like "IF temperature is hot AND humidity is high THEN fan speed is fast."

  3. Aggregation: Combine the outputs of all the rules.

  4. Defuzzification: Convert back to a crisp output (e.g., fan speed = 1,450 RPM).

Applications: Washing machines, air conditioners, camera autofocus, anti-lock braking systems, rice cookers.

Q25. What are the major career roles in AI, and how do they differ?

Answer:

  • Data Analyst: Analyses data, builds dashboards and reports. Tools: SQL, Excel, Power BI, Tableau.

  • Data Scientist: Explores data, builds statistical and ML models, and turns insights into business decisions. Python, statistics and experimentation.

  • Machine Learning Engineer: Builds, optimises and deploys ML models at production scale. Strong software engineering plus ML.

  • AI Engineer / GenAI Engineer: Builds applications on top of foundation models: RAG systems, AI agents, prompt pipelines, evaluation and guardrails.

  • MLOps Engineer: Automates training, deployment, monitoring and CI/CD for models.

  • Data Engineer: Builds the pipelines and infrastructure that move and store data.

  • Research Scientist: Invents new algorithms and architectures and publishes research.

  • Computer Vision / NLP Engineer: Specialists in a particular domain.

  • AI Product Manager: Defines AI product strategy and bridges business and technical teams.

  • Forward Deployed Engineer: Works directly with customers to adapt and deploy AI solutions.

  • AI Ethics / Responsible AI Specialist: Ensures fairness, safety and compliance.

Q26. What is an intelligent agent? Explain the agent function and the agent program.

Answer: An intelligent agent is anything that perceives its environment through sensors and acts on it through actuators to achieve goals.

  • Percept: What the agent senses at a given moment.

  • Percept sequence: The complete history of everything the agent has perceived.

  • Agent function: A mathematical mapping from any percept sequence to an action (an abstract description).

  • Agent program: The actual code that implements the agent function on a physical system (the concrete implementation).

Agent = Architecture + Program, where the architecture is the hardware with its sensors and actuators.

Examples:

  • Human: eyes and ears (sensors), hands and legs (actuators).

  • Robot vacuum: dirt and bump sensors, wheels and brushes.

  • Software agent: keystrokes and API responses as percepts, displaying output or calling APIs as actions.

Q27. Explain the PEAS framework with an example.

Answer: PEAS is used to specify the task environment of an agent before designing it.

ComponentSelf-Driving TaxiMedical Diagnosis System
PerformanceSafety, speed, legality, comfort, profitPatient health, minimised cost, accuracy
EnvironmentRoads, traffic, pedestrians, weatherPatient, hospital, staff
ActuatorsSteering, accelerator, brake, hornDisplay of diagnoses, tests, treatments
SensorsCameras, LiDAR, GPS, speedometerSymptoms entry, test results, patient answers

Why it matters: Defining PEAS first clarifies what "success" means and what information the agent has. That decides which algorithms and architecture are appropriate.

Q28. What are the different properties of task environments in AI?

Answer:

  1. Fully vs Partially Observable: Can the agent see the complete state? (Chess is fully observable; poker is partially observable.)

  2. Deterministic vs Stochastic: Is the next state completely determined by the current state and action? (Puzzle solving is deterministic; driving is stochastic.)

  3. Episodic vs Sequential: Are decisions independent, or do current actions affect future ones? (Image classification is episodic; chess is sequential.)

  4. Static vs Dynamic: Does the environment change while the agent is thinking? (Crossword is static; traffic is dynamic.)

  5. Discrete vs Continuous: Finite number of states and actions, or continuous values? (Chess is discrete; steering angle is continuous.)

  6. Single-agent vs Multi-agent: Are other agents involved, cooperatively or competitively?

  7. Known vs Unknown: Does the agent know the rules or physics of the environment?

The hardest case: Partially observable, stochastic, sequential, dynamic, continuous and multi-agent, which describes real-world driving.

Q29. What are the different types of AI agents?

Answer:

  1. Simple Reflex Agent: Acts only on the current percept using condition-action rules. No memory. Fails in partially observable environments. Example: a thermostat.

  2. Model-Based Reflex Agent: Maintains an internal state (a model of how the world works) to handle parts it cannot currently see. Example: a robot vacuum remembering cleaned areas.

  3. Goal-Based Agent: Considers future consequences and chooses actions that achieve a goal, using search and planning. Example: GPS navigation.

  4. Utility-Based Agent: Uses a utility function to choose the best way to reach a goal when there are trade-offs. Example: choosing a route that balances time, toll cost and safety.

  5. Learning Agent: Improves with experience. Components:

    • Performance element: selects actions.

    • Learning element: makes improvements.

    • Critic: gives feedback on how well the agent is doing.

    • Problem generator: suggests exploratory actions.

Q30. What is the difference between rationality and omniscience in AI agents?

Answer:

  • A rational agent chooses the action that is expected to maximise its performance measure, given its percept sequence and built-in knowledge.

  • An omniscient agent knows the actual outcome of its actions in advance, which is impossible in reality.

Key insight: Rationality is about making the best decision with the available information, not about always getting the best result.

Example: You check both sides of the road, see no traffic and cross. A meteorite then falls on you. Your decision was still rational. You were not omniscient.

Related concepts:

  • Information gathering: A rational agent should take actions to gather information when it helps, such as looking before crossing.

  • Autonomy: A rational agent should learn from experience to compensate for incomplete prior knowledge rather than depending only on its designer's assumptions.

Q31. What is state space representation, and how is a problem formulated in AI?

Answer: State space representation models a problem as the set of all possible states plus the actions that move between them. Solving the problem means searching for a path from the initial state to a goal state.

Problem formulation components:

  1. Initial State: Where the agent starts.

  2. Actions: Possible moves in each state.

  3. Transition Model: The resulting state after an action.

  4. Goal Test: A check for whether a state is a goal.

  5. Path Cost: The numeric cost of a sequence of actions.

Example: Water Jug Problem (a 4L jug and a 3L jug, measure exactly 2L)

  • State: (x, y) = litres in each jug. Initial state: (0, 0).

  • Actions: fill a jug, empty a jug, pour from one jug into the other.

  • Goal: any state where x = 2.

Abstraction (removing irrelevant details) keeps the state space small enough to search.

Q32. What is the difference between Breadth-First Search (BFS) and Depth-First Search (DFS)?

Answer:

PropertyBFSDFS
StrategyExplores level by levelGoes as deep as possible, then backtracks
Data structureQueue (FIFO)Stack (LIFO) / recursion
Complete?Yes (if branching factor is finite)No (can loop forever in infinite or cyclic spaces without checks)
Optimal?Yes, when all step costs are equalNo
TimeO(b^d)O(b^m)
SpaceO(b^d), which is highO(b·m), which is low

(b = branching factor, d = depth of the shallowest goal, m = maximum depth)

When to use: BFS when the shortest path matters and memory is available (e.g., shortest connection in a social network). DFS when memory is limited, solutions are deep, or you need to explore all paths (e.g., maze solving, topological sort).

Q33. What is Uniform-Cost Search, and how is it different from BFS?

Answer: Uniform-Cost Search (UCS) expands the node with the lowest path cost g(n) from the start, using a priority queue. It is essentially Dijkstra's algorithm applied to search.

Difference from BFS:

  • BFS expands the shallowest node (fewest steps).

  • UCS expands the cheapest node (lowest total cost).

  • When every step costs the same, they behave identically. When costs differ, BFS can return a path with fewer steps but a higher total cost, while UCS always returns the cheapest path.

Properties:

  • Complete (if every step cost is greater than some small positive ε).

  • Optimal: guaranteed to find the least-cost path.

  • Can be slow, because it explores in every direction with no sense of where the goal is. A* fixes this by adding a heuristic.

Example: Finding the cheapest flight route where flights have different prices.

Q34. What is Iterative Deepening Depth-First Search (IDDFS), and why is it useful?

Answer: IDDFS repeatedly runs depth-limited DFS with increasing depth limits (0, 1, 2, 3, …) until a goal is found.

Why it is useful: It combines the best of BFS and DFS.

  • Complete and optimal (for uniform step costs), like BFS.

  • Low memory O(b·d), like DFS.

"Isn't repeating the search wasteful?" Not much. In a tree, most nodes are at the deepest level, so re-expanding the shallow levels adds only a small overhead. Total time is still O(b^d).

When to use: When the search space is large and the depth of the solution is unknown. It is generally the preferred uninformed search method in such cases.

Related: Iterative Deepening A* (IDA*) applies the same idea to informed search using f-cost limits instead of depth limits.

Q35. What is the difference between informed and uninformed search? What is a heuristic function?

Answer:

Uninformed (Blind) SearchInformed (Heuristic) Search
Uses only the problem definitionUses extra knowledge about the goal
No idea which direction is closer to the goalUses a heuristic to prioritise promising nodes
BFS, DFS, UCS, IDDFSGreedy Best-First, A*, IDA*
Usually slowerUsually much faster

A heuristic function h(n) estimates the cost from node n to the nearest goal. It is a "rule of thumb" that guides the search.

Examples:

  • Route finding: straight-line (Euclidean) distance to the destination.

  • 8-puzzle: number of misplaced tiles, or Manhattan distance (sum of each tile's distance from its goal position). Manhattan distance is more informed, so it explores fewer nodes.

A good heuristic is cheap to compute and close to the true cost without overestimating it.

Q36. How does the A* algorithm work, and when is it optimal?

Answer: A* evaluates each node using:

f(n) = g(n) + h(n)

  • g(n) = actual cost from the start to n

  • h(n) = estimated cost from n to the goal

It always expands the node with the lowest f(n) from a priority queue. This balances the cost already paid with the estimated remaining cost.

Optimality conditions:

  • Admissible heuristic: h(n) never overestimates the true cost to the goal. This guarantees optimality in tree search.

  • Consistent (monotonic) heuristic: h(n) ≤ cost(n, n') + h(n') for every successor n'. This guarantees optimality in graph search, and every consistent heuristic is also admissible.

Special cases:

  • h(n) = 0 → A* becomes Uniform-Cost Search.

  • Ignoring g(n) → it becomes Greedy Best-First Search.

Limitation: It stores all generated nodes in memory, which can be huge. Memory-bounded variants like IDA* and SMA* address this.

Applications: Game pathfinding, GPS navigation, robot motion planning.

Q37. What is Greedy Best-First Search, and what are its limitations?

Answer: Greedy Best-First Search expands the node that appears closest to the goal, using only the heuristic: f(n) = h(n). It ignores the cost already spent.

Advantages:

  • Often finds a solution very quickly.

  • Simple to implement.

Limitations:

  • Not optimal: It can choose a path that looks close but is actually expensive.

  • Not complete in tree search: it can get stuck in loops.

  • Misleading heuristics can lead it into dead ends.

  • Worst-case time and space are O(b^m).

Example: Driving to a city, you always take the road that points most directly toward it, but that road may lead to a river with no bridge, forcing a long detour.

A* fixes this by also considering g(n), the cost already travelled.

Q38. What is Hill Climbing, and what problems does it face?

Answer: Hill Climbing is a local search algorithm. It starts from a solution and repeatedly moves to the best neighbouring state that improves the objective function, stopping when no neighbour is better. It uses very little memory because it keeps only the current state.

Problems:

  1. Local Maximum: A peak higher than its neighbours but lower than the global maximum. The algorithm stops there.

  2. Plateau: A flat area where all neighbours have the same value, so there is no direction to move in.

  3. Ridge: A narrow rising area where single moves go downhill, even though the overall direction is upward.

Solutions:

  • Random-Restart Hill Climbing: Run it many times from random starting points and keep the best result.

  • Stochastic Hill Climbing: Choose randomly among uphill moves.

  • Sideways moves: Allow a limited number of moves on plateaus.

  • Simulated Annealing: Occasionally accept worse moves.

Applications: Scheduling, the travelling salesman problem, the N-Queens puzzle, parameter optimisation.

Q39. What is Simulated Annealing, and how does it avoid local optima?

Answer: Simulated Annealing is a probabilistic local search method inspired by annealing in metallurgy, where metal is heated and then cooled slowly so its atoms settle into a low-energy, stable structure.

How it works:

  1. Start with a solution and a high "temperature" T.

  2. Pick a random neighbour.

  3. If it is better, move there.

  4. If it is worse, move there anyway with probability P = e^(−ΔE / T), where ΔE is how much worse it is.

  5. Gradually lower T according to a cooling schedule.

Why it escapes local optima: At high temperature, it frequently accepts worse moves, which lets it explore widely and escape local peaks. As T decreases, it becomes more selective and settles into a good solution.

Key property: With a slow enough cooling schedule, it converges to the global optimum with high probability.

Applications: VLSI chip layout, job scheduling, the travelling salesman problem, network design.

Q40. What are Genetic Algorithms, and how do they work?

Answer: Genetic Algorithms (GAs) are optimisation algorithms inspired by natural selection and evolution. They work with a population of candidate solutions instead of a single one.

Steps:

  1. Initialisation: Create a random population of candidate solutions (chromosomes).

  2. Fitness Evaluation: Score each candidate with a fitness function.

  3. Selection: Choose fitter individuals as parents (roulette wheel, tournament selection).

  4. Crossover: Combine parts of two parents to create offspring.

  5. Mutation: Randomly change small parts of offspring to maintain diversity.

  6. Replacement: Form the new generation and repeat until a good enough solution is found or a generation limit is reached.

Strengths: Works well in huge, complex search spaces where gradients are not available. Naturally parallel. Good at exploring globally.

Weaknesses: No guarantee of the optimal solution, computationally expensive, many parameters to tune.

Applications: Scheduling, route optimisation, neural architecture search, engineering design.

Q41. Explain the Minimax algorithm used in game playing.

Answer: Minimax is an adversarial search algorithm for two-player, turn-based, zero-sum games with perfect information, such as chess and tic-tac-toe.

How it works:

  • MAX player tries to maximise the score, and MIN player tries to minimise it.

  • Build the game tree to a certain depth.

  • Score the leaf (terminal or cut-off) states with a utility or evaluation function.

  • Pass the values up the tree: MAX nodes take the maximum child value, MIN nodes take the minimum.

  • At the root, MAX chooses the move with the highest backed-up value.

Assumption: The opponent plays optimally.

Complexity: Time O(b^m), space O(b·m). For chess (b ≈ 35, m ≈ 100), a full search is impossible, so real engines use:

  • Depth-limited search with a heuristic evaluation function (material, mobility, king safety).

  • Alpha-beta pruning to skip irrelevant branches.

Q42. What is Alpha-Beta Pruning, and why is it important?

Answer: Alpha-Beta Pruning is an optimisation of Minimax that skips branches that cannot affect the final decision, while returning exactly the same result.

  • α (alpha): The best (highest) value MAX can guarantee so far along the path.

  • β (beta): The best (lowest) value MIN can guarantee so far along the path.

  • Pruning rule: When α ≥ β, stop exploring that branch, because a rational opponent will never allow the game to reach it.

Efficiency:

  • Worst case (bad move ordering): no improvement, O(b^m).

  • Best case (perfect move ordering): O(b^(m/2)), which means the algorithm can search roughly twice as deep in the same time.

Move ordering is crucial. Checking the most promising moves first (captures, killer moves, results from earlier shallower searches) leads to more pruning.

Q43. What is a Constraint Satisfaction Problem (CSP), and how is it solved?

Answer: A CSP is a problem defined by:

  • Variables: X₁, X₂, …, Xₙ

  • Domains: The possible values for each variable.

  • Constraints: Rules that restrict which combinations of values are allowed.

A solution assigns a value to every variable so that all constraints are satisfied.

Examples: Sudoku, map colouring (no adjacent regions share a colour), exam timetabling, N-Queens.

Solving techniques:

  • Backtracking Search: Assign variables one at a time and backtrack when a constraint is violated.

  • Heuristics to speed it up:

    • MRV (Minimum Remaining Values): Choose the variable with the fewest legal values left.

    • Degree heuristic: Choose the variable involved in the most constraints.

    • Least Constraining Value: Choose the value that rules out the fewest options for neighbouring variables.

  • Forward Checking: After each assignment, remove inconsistent values from neighbouring variables' domains.

  • Arc Consistency (AC-3): Propagate constraints to shrink domains before and during search.

Q44. What is knowledge representation in AI, and what are the common techniques?

Answer: Knowledge Representation (KR) is how an AI system stores information about the world so it can reason, answer questions and make decisions.

Common techniques:

  1. Logical Representation: Propositional logic and first-order logic. Precise and supports inference.

  2. Semantic Networks: A graph of concepts (nodes) and relationships (edges), e.g., "Dog → is-a → Animal".

  3. Frames: Structured records with slots and values, like objects in object-oriented programming (Car: wheels = 4, colour = red).

  4. Production Rules: IF–THEN rules, used in expert systems.

  5. Ontologies & Knowledge Graphs: Formal vocabularies of concepts and relationships (e.g., Google Knowledge Graph, Wikidata).

  6. Probabilistic Representations: Bayesian networks for uncertain knowledge.

  7. Embeddings (modern): Dense vectors that capture meaning, used by neural networks and LLMs.

Properties of good KR: Representational adequacy, inferential efficiency, ease of acquisition, and clarity.

Q45. What is the difference between propositional logic and first-order logic?

Answer:

Propositional LogicFirst-Order Logic (FOL / Predicate Logic)
Deals with whole statements that are true or falseDeals with objects, their properties and relationships
Uses propositions (P, Q) and connectives (∧, ∨, ¬, →, ↔)Adds predicates, functions, variables and quantifiers (∀, ∃)
Cannot generaliseCan express general rules
Less expressive, simpler inferenceMore expressive, more complex inference

Example: "All humans are mortal; Socrates is a human."

  • Propositional logic would need a separate proposition for each person ("Socrates_is_mortal", "Plato_is_mortal", …).

  • FOL: ∀x Human(x) → Mortal(x), Human(Socrates) ⊢ Mortal(Socrates)

Use: FOL is the basis of Prolog, knowledge bases and automated theorem proving.

Q46. What is the difference between forward chaining and backward chaining?

Answer: Both are inference methods used by rule-based systems.

Forward ChainingBackward Chaining
Data-driven: starts from known factsGoal-driven: starts from the goal (hypothesis)
Applies rules to derive new facts until the goal is reached or nothing new can be derivedWorks backward to find facts that support the goal
Bottom-upTop-down
May derive many irrelevant factsExplores only what is relevant to the goal
Good for monitoring, planning, predictionGood for diagnosis, answering specific questions
Example: CLIPS, production systemsExample: Prolog, MYCIN

Example:

Rules: Fever ∧ Cough → Flu.

  • Forward: "Patient has fever and cough" → conclude "Flu".

  • Backward: "Does the patient have flu?" → check "Fever?" and "Cough?"

Q47. What is an ontology and a knowledge graph in AI?

Answer:

  • An ontology is a formal, explicit specification of the concepts in a domain, their properties and the relationships between them. It is the "schema" or vocabulary. Example: a medical ontology defines that Disease has Symptoms, and Diabetes is-a Metabolic Disease. Standards include OWL and RDF.

  • A knowledge graph stores real-world entities and their relationships as a graph of (subject, predicate, object) triples, usually following an ontology. Example: (Sachin Tendulkar, plays, Cricket), (Sachin Tendulkar, born_in, Mumbai).

Uses:

  • Search engines (Google Knowledge Panel).

  • Recommendation systems.

  • Question answering and reasoning.

  • GraphRAG: Grounding LLMs with knowledge graphs for multi-hop, relationship-heavy questions.

  • Fraud detection (finding hidden connections between accounts).

Benefit: Makes knowledge explicit, machine-readable and connected, which supports reasoning and explainability.

Q48. What is the difference between monotonic and non-monotonic reasoning?

Answer:

  • Monotonic Reasoning: Once a conclusion is derived, adding new knowledge never invalidates it. The set of conclusions only grows. Classical logic (propositional and first-order) is monotonic.

    Example: "All triangles have three sides." No new fact changes this.

  • Non-Monotonic Reasoning: Conclusions can be withdrawn when new information arrives. This is how humans reason with incomplete knowledge, using default assumptions.

    Example: "Tweety is a bird → Tweety can fly." Later we learn "Tweety is a penguin", so we retract "Tweety can fly."

Why it matters: Real-world AI must make reasonable assumptions with incomplete information and revise them later.

Techniques: Default logic, circumscription, Truth Maintenance Systems (TMS), which track why beliefs are held so they can be revised consistently.

Q49. How is Bayes' Theorem used in AI?

Answer: Bayes' Theorem updates the probability of a hypothesis based on new evidence:

P(H | E) = [P(E | H) × P(H)] / P(E)

  • P(H): prior, the belief before seeing evidence

  • P(E | H): likelihood

  • P(H | E): posterior, the updated belief

Example: Medical test

A disease affects 1% of people. A test detects it 99% of the time but gives false positives 5% of the time. If you test positive:

P(Disease | +) = (0.99 × 0.01) / (0.99 × 0.01 + 0.05 × 0.99) ≈ 16.7%.

Even with a positive result, the chance of having the disease is low because the disease is rare. This is the base rate fallacy.

Uses in AI: Naive Bayes classifiers (spam filtering), Bayesian networks, Bayesian optimisation for hyperparameter tuning, robot localisation, A/B testing, and uncertainty estimation.

Q50. What is a Bayesian Network?

Answer: A Bayesian Network (belief network) is a probabilistic graphical model that represents variables and their conditional dependencies using a Directed Acyclic Graph (DAG).

  • Nodes: Random variables.

  • Edges: Direct causal or probabilistic influence.

  • Conditional Probability Tables (CPTs): For each node, the probability of its values given its parents.

Example: Burglary → Alarm ← Earthquake; Alarm → JohnCalls; Alarm → MaryCalls.

If Mary calls, the network can compute the probability that a burglary occurred.

Advantages:

  • Compact representation of a joint probability distribution.

  • Handles uncertainty and missing data.

  • Supports both diagnostic reasoning (effect → cause) and predictive reasoning (cause → effect).

  • Interpretable structure.

Applications: Medical diagnosis, fault detection, risk assessment, spam filtering.