CS-OA cs-vo Faang

[TikTok] AMS Grad Assessment 2024 Start -12 to 16 Feb (Generic)

Q1.A key component of the architecture for a high-traffic website is its load balancer, which distributes network or application traffic across many servers to ensure no single server is overwhelmed.

Which pair of pseudo-code snippets correctly implement a Round Robin and a Least Connection load balancing algorithm?

Pick ONE OR MORE options

Array servers = getServerList() Function getNextServer() Server nextServer = servers[randomWeightedIndex()] return nextServer

// Round Robin Array servers = getServerList() Integer index = 0 Function getNextServer() Server nextServer = servers[index] index = (index + 1) % servers.length return nextServer

Array servers = getServerList() Function getServerWithLeastConnections() Server leastConnectionServer = servers[0] for each server in servers if server.connectionCount < leastConnectionServer.connectionCount leastConnectionServer = server return leastConnectionServer

// Least Connection Array servers = getServerList() Function getServerWithLeastConnections() Server leastConnectionServer = servers[0] for each server in servers if server.connectionCount < leastConnectionServer.connectionCount leastConnectionServer = server return leastConnectionServer

Array servers = getServerList() Integer index = 0 Function getNextServer() Server nextServer = servers[index] index = (index + 1) % servers.length return nextServer

Array servers = getServerList() Array weights = getServerWeights() // Assuming each server has an associated weight Integer index = 0 Integer cumulativeWeight = sum(weights) Function getNextServer() while weights[index] <= 0 weights[index] += cumulativeWeight index = (index + 1) % servers.length weights[index] -= 1 return servers[index]

// Round Robin Array servers = getServerList() Function getNextServer() Server nextServer = servers[0] for each server in servers if server.connectionCount < nextServer.connectionCount nextServer = server return nextServer

Array servers = getServerList() Function getRandomServer() Server randomServer = servers[randomIndex()] return randomServer

// Least Connection Array servers = getServerList() Integer index = 0 Function getServerWithLeastConnections() Server leastConnectionServer = servers[index] index = (index + 1) % servers.length return leastConnectionServer

Q2 Compare and contrast Dijkstra's Algorithm with the Bellman-Ford Algorithm in the context of finding the shortest path in a weighted graph. Consider their mechanisms, complexities, and scenarios where one may be preferred over the other.

Use the following pseudo-code snippets to highlight key differences in their approaches.

The maximum strength possible is 14.

If you're afraid that you can't solve the OA on your own, please scan the code to contact me or telegram

Leave a Reply

Your email address will not be published. Required fields are marked *