PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/Machine Learning/Microsoft

Compare CNN/RNN/LSTM and implement K-means

Last updated: Mar 29, 2026

Quick Overview

This question evaluates understanding of deep learning architectures (CNN, RNN, LSTM) and unsupervised clustering implementation (K-means), covering inductive biases, parameter sharing and receptive fields, LSTM gating and vanishing-gradient behavior, tensor shape reasoning, algorithmic complexity, initialization, and cluster handling.

  • hard
  • Microsoft
  • Machine Learning
  • Data Scientist

Compare CNN/RNN/LSTM and implement K-means

Company: Microsoft

Role: Data Scientist

Category: Machine Learning

Difficulty: hard

Interview Round: Onsite

Part A (concepts): Contrast CNNs and RNNs for (i) 224×224 RGB images and (ii) variable-length text. Explain inductive biases (translation equivariance, locality, temporal order), parameter sharing, receptive-field growth, and ability to model long-range dependencies; when can a 1D CNN replace an RNN/Transformer? For LSTMs, write the gate equations, show how the cell state mitigates vanishing gradients, and compute output shapes for input (batch=32, seq_len=100, feat=64) with hidden size 128 for unidirectional vs bidirectional cases. Part B (coding): Implement K-means from scratch with k-means++ initialization, vectorized assignment/update steps, and convergence on objective decrease. Discuss O(n·k·d) time and memory trade-offs, handling empty clusters, feature scaling and outliers, choosing k (silhouette/elbow/BIC), and prove the objective is non-increasing per iteration. Propose a mini-batch variant and when you’d use it.

Quick Answer: This question evaluates understanding of deep learning architectures (CNN, RNN, LSTM) and unsupervised clustering implementation (K-means), covering inductive biases, parameter sharing and receptive fields, LSTM gating and vanishing-gradient behavior, tensor shape reasoning, algorithmic complexity, initialization, and cluster handling.

Related Interview Questions

  • How do you choose a model? - Microsoft (medium)
  • Explain SHAP in an ML System - Microsoft (medium)
  • Explain normalization, regularization, CTR, imbalance handling - Microsoft (medium)
  • Clean OCR data and build an LLM dataset - Microsoft (medium)
  • Explain SHAP and build an ML project - Microsoft (easy)
Microsoft logo
Microsoft
Oct 13, 2025, 9:49 PM
Data Scientist
Onsite
Machine Learning
7
0

Deep Learning Concepts and K-means Implementation (Onsite ML Interview)

Part A: CNNs vs RNNs and LSTMs

Contrast CNNs and RNNs for the following modalities:

  • (i) 224×224 RGB images
  • (ii) Variable-length text

Explain and compare:

  • Inductive biases: translation equivariance, locality (spatial/temporal), temporal order
  • Parameter sharing
  • Receptive-field growth
  • Ability to model long-range dependencies
  • When a 1D CNN can replace an RNN/Transformer (assumptions and caveats)

For LSTMs:

  • Write the gate equations and define all symbols and shapes
  • Show mathematically how the cell state helps mitigate vanishing gradients
  • Compute output shapes for input (batch=32, seq_len=100, feat=64), hidden size=128 for unidirectional vs bidirectional cases (assume a single layer)

Part B: K-means From Scratch

Implement K-means with the following requirements:

  • k-means++ initialization
  • Vectorized assignment and update steps
  • Convergence based on decrease of the objective (sum of squared distances)

Also discuss:

  • Time complexity O(n·k·d) per iteration and memory trade-offs
  • Handling empty clusters
  • Feature scaling and outliers
  • Choosing k (silhouette, elbow, BIC)
  • Prove the objective is non-increasing per iteration
  • Propose a mini-batch variant and when you would use it

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More Machine Learning•More Microsoft•More Data Scientist•Microsoft Data Scientist•Microsoft Machine Learning•Data Scientist Machine Learning
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.