How does recovery work when server is shutdown before a checkpoint? So for any query that makes changes to data:

SQL Server pulls the page from disk into memory if it doesn't already exist in memory.
Lock the page/row and make the data changes.
Writes the changed to the log in memory.
Release the page/row lock.
Send acknowledgement to user

Then, whenever there is a checkpoint:

Write the log to disk
Write dirty page to disk

Suppose the server gets shutdown due to power failure just before a checkpoint. Then is the data from memory that wasn't burnt to disk lost? Or does SQL Server write the log to disk before sending acknowledgement to user?
In full durability, the default, the commit completes only when the data is physically written to the log file - it's only data pages that are later written to disk on checkpoint by the lazy writer.
There's a per-database setting called delayed durability that can override and allow the transaction to be committed but only written to the log file when the buffer is full, offering faster transactions but the risk of losing (as yet) unwritten committed transactions.
More info