Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a custom function to compute the spectral clustering of a graph.

Hard

Problem Statement

Create a custom function to compute the spectral clustering of a graph.

Sample Input

Adjacency Matrix: 
 [,1] [,2] [,3]
[1,] 0 1 1
[2,] 1 0 1
[3,] 1 1 0

Sample Output

Cluster assignments: 1, 2, 1

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
spectral_clustering <- function(adj_matrix, k) { # Your logic here } # Call the function
Log in or sign up to run or submit your code.Log inSign up
Input
Adjacency Matrix: 
 [,1] [,2] [,3]
[1,] 0 1 1
[2,] 1 0 1
[3,] 1 1 0
Expected Output
Cluster assignments: 1, 2, 1