In a virtual memory system, the virtual address space is divided into pages, and each page is mapped to a physical address. The mapping between virtual and physical addresses is done using a page table.
In this case, the physical memory is 4GB, which is equal to 4 * 2^30 bytes. The page size is 4KB, which is equal to 4 * 2^10 bytes. Therefore, the number of pages in physical memory is 4 * 2^30 / (4 * 2^10) = 2^20 pages.
The page table entry size is 4B, which is equal to 4 * 2^3 bytes. Therefore, each page table can hold 2^(12-3) = 2^9 page table entries.
The virtual address space is 45-bit, which means that there are 2^45 different virtual addresses. To map all these addresses, we would need 2^45/2^12 = 2^33 page tables.
Since each page table can hold 2^9 page table entries, and we need 2^33 page tables to map all the virtual addresses, we would need 2^33 / 2^9 = 2^24 page tables.
Since each page table exactly fits into a single page, we would need 2^24 page tables to map all the virtual addresses. And since each page table is represented by one entry in the page table, we would require 2^24 page table entries.
Therefore, the number of levels of page tables would be 1.