dsa
Interview Date
21-08-2026
Result
Selected
Difficulty
Easy
Rounds
02
Drive Type
Off-Campus
Topics asked
Detailed experience
PRACTICE INTERVIEW SET 23 PART 1: ALGORITHMIC PROBLEM - TREE REROOTING DYNAMIC PROGRAMMING BASE PROBLEM You are given an unrooted tree network with N nodes (representing servers) and N-1 undirected edges (representing network links). You need to place a central controller at one of the nodes. To minimize network latency, you want to find the node that minimizes the sum of distances to all other nodes in the network. Task: Design an algorithm to calculate the sum of distances from every single node to all other nodes in O(N) time. What state variables will you track, and how will you structure the two passes (post-order and pre-order traversals) required for this Tree Rerooting DP approach? FOLLOW-UP 1 The network topology is no longer static. New servers (leaf nodes) are occasionally added, and link weights can change based on traffic. Calculating the distances from scratch in O(N) is too slow for real-time routing. How would you restructure your data using Heavy-Light Decomposition (HLD) combined with a Segment Tree or Fenwick Tree to support both path-distance queries and link-weight updates in O(log^2 N) time? FOLLOW-UP 2 When processing massive trees (e.g., N = 1,000,000) in a strict C++ environment, a standard recursive Depth-First Search (DFS) will cause a stack overflow. How do you convert your two-pass tree DP algorithm into an iterative approach without relying on the call stack, ensuring optimal memory utilization and avoiding runtime crashes? PART 2: SYSTEM DESIGN - EDGE INFERENCE PIPELINE BASE PROBLEM You are architecting a real-time edge inference system for processing live video feeds and telemetry to detect anomalies (e.g., security breaches or hardware failures). The system consists of hundreds of low-power edge devices executing local ML models and a centralized cloud backend for aggregation. Design the high-level architecture to ingest, process, and act on these streams with ultra-low latency. FOLLOW-UP 1 Edge devices have limited compute, meaning heavy deep learning architectures struggle to maintain a high frames-per-second (FPS) rate. How do you design the C++ inference engine to natively utilize hardware accelerators (like OpenCL or dedicated NPUs), and how would you orchestrate a fallback mechanism where complex frames are seamlessly offloaded to the cloud without stalling the local video buffer? FOLLOW-UP 2 The data science team regularly trains updated anomaly detection models (e.g., shifting from a lightweight XGBoost probability model for metadata to a complex CNN for raw frames). How do you design a zero-downtime deployment pipeline to securely push model weight updates to thousands of distributed edge nodes, ensuring that a corrupted model update does not brick the local inference system? PART 3: AI / ML DISCUSSION QUESTIONS How do you formulate anomaly detection in machine learning? Anomaly detection is typically formulated as an unsupervised or semi-supervised learning problem because true anomalies are rare and labeled data is scarce. Techniques range from statistical approaches (like Isolation Forests) to reconstruction-based methods using Autoencoders, where the model learns to reconstruct normal data, and anomalies are identified by a high reconstruction error threshold. What are the core differences between deploying models via PyTorch vs. optimized runtimes like ONNX or TensorRT? Standard PyTorch is highly flexible and excellent for research and training, but its dynamic computation graph incurs overhead during inference. Exporting a model to ONNX provides a standardized, framework-agnostic static graph. TensorRT takes this further by performing hardware-specific optimizations (like layer fusion and precision calibration for GPUs), drastically reducing latency and memory footprint for production deployment. When would you choose XGBoost over a Deep Learning architecture? XGBoost (an implementation of gradient boosted decision trees) is generally superior for structured, tabular data. It requires less tuning, handles missing values natively, is less prone to overfitting on smaller datasets, and trains significantly faster. Deep learning is typically reserved for unstructured data (images, audio, raw text) or massive datasets where hierarchical automated feature extraction is necessary. What is Model Quantization in edge AI? Quantization is the process of mapping continuous infinite values to a smaller set of discrete finite values. In AI inference, this means converting the 32-bit floating-point weights (FP32) of a trained model into lower precision formats like 8-bit integers (INT8). This significantly reduces the model's memory footprint and allows it to run on the integer ALUs of edge devices, vastly increasing inference speed with a negligible drop in accuracy.