There’s an entry in the zip file for every file or folder and the extraction software can also figure out the structure from file names : for example if an entry has the name “folder/filename.txt” the software recognizes / character as folder separator and knows it needs to create.the folder “folder” if it does not exist, and put “filename.txt” inside that folder.
Fun fact zip files allow paths like “../../../folder1/folder2/file.extension” which would allow writing files outside the folder a user specifies, but most decompression programs will refuse to write outside specified destination folder and either not create file or ‘flatten’ the path (pretend the “go up one level” notation “..” doesn’t exist)
The decompression program.will .read.the records.at.the end of the file and will usually extract the files sequentially, as the records are read. Some programs may detect if two or more records point to same file name and skip writing the data associated with first records to disk as it would be overwritten later anyway. It’s also possible to have empty spaces in zip archives, as a result of deleting entries in the zip file.