📝 Acyclic graph file directories in Operating System (26 MCQs)
Sharing Files Through Directed Acyclic Relationships
An acyclic graph directory structure extends tree-based organisation by allowing a file or subdirectory to be referenced from multiple locations without creating directed cycles. This approach supports shared files and common directory structures while maintaining a controlled navigation model. The operating system manages links, reference information, and deletion rules to ensure shared objects remain accessible without introducing infinite traversal paths.
Why Multiple Directory References Are Useful
Tree structures require each ordinary directory entry to belong to one parent, which can force duplicated files or directory trees when several users need the same information. Acyclic graph organisation permits shared references and reduces unnecessary duplication. However, multiple references complicate deletion because removing one pathname should not destroy an object still referenced elsewhere.
Link Management and Reference Counting
The file system creates another reference to an existing object through a suitable link mechanism. When a pathname is resolved, the operating system follows the reference to the shared file or directory. Reference counts or equivalent metadata can track how many links remain. When a link is removed, the underlying object is reclaimed only when no required references remain and other open references no longer depend on it.
Sharing One Document Between Two Directories
Suppose /home/ali/projects and /home/sara/projects both contain a reference to a shared specification file. Both users can access the same underlying object through different paths. Updating the shared file changes the common contents rather than creating two independent copies, provided the references represent genuine shared access to that object.
Reduced Duplication and Link-Management Complexity
Acyclic graph directories support file sharing, save storage space, and allow common subdirectories to appear in multiple locations. Their management requires careful handling of reference counts, permissions, and deletion. Shared writable objects may also introduce consistency and security concerns. The acyclic restriction simplifies traversal by preventing cycles that could otherwise produce infinite directory searches.
Common Errors About Acyclic Graphs
'An acyclic graph allows unlimited circular directory links' is incorrect because cycles are specifically excluded. 'Deleting one reference always deletes the shared file' is incorrect because other references may remain. 'Every pathname identifies an independent physical copy' is incorrect because multiple directory entries can reference the same underlying object.
Exam Focus: Link Counts and Safe Deletion
Identify how multiple directory entries can reference one file or subdirectory without forming a cycle. Trace link creation, traversal, and deletion. Explain why reference counting helps prevent premature object removal. Compare acyclic graphs with tree structures and general graphs, focusing on shared references, deletion complexity, and cycle prevention.
Key Terms of Acyclic Graph Directories
- Acyclic graph - Directed structure without cycles.
- Shared reference - Multiple paths to one object.
- Link count - Number of directory references.
- Hard link - Additional name for an inode.
- Cycle - Path returning to an earlier node.
- Reference management - Tracks shared-object usage.
📝 All Acyclic graph file directories in Operating System MCQs
Q1. Which file extension typically indicates a Microsoft Word document?
📖 Explanation: The .doc extension is historically associated with Microsoft Word because the program registers that suffix as its native format. When a user double‑clicks a file ending in .doc, the operating system looks up the association and launches Word to display the contents. The other choices represent executable binaries (.exe), image files (.jpg), and audio files (.mp3), none of which Word uses for its native documents. Understanding this mapping helps users name files correctly and ensures the right application opens them.
Q2. What extension is commonly used for compiled Java bytecode files?
📖 Explanation: Compiled Java source code is stored in .class files, each containing bytecode that the Java Virtual Machine can interpret. The .java suffix denotes source files, while .jar is a packaged archive of many .class files and resources. An .exe is a Windows executable and unrelated to Java. Recognizing the .class extension lets developers and tools locate the correct binary output after compilation.
Q3. Which extension denotes a Unix shell script that can be executed directly?
📖 Explanation: The .sh suffix signals a plain‑text script written for a Unix shell such as Bash or sh. When the file has execute permission, the kernel can invoke the interpreter to run the commands inside. The other extensions represent a generic text file (.txt), a Word document (.docx), and a Portable Document Format file (.pdf), none of which the shell can execute as scripts.
Q4. Why does the operating system rely on file extensions to determine how to open a file?
📖 Explanation: Extensions serve as concise identifiers that the OS uses to look up which program or system component is registered to handle that type. By matching .pdf to a PDF viewer or .exe to the executable loader, the system can launch the appropriate handler automatically. The other statements describe unrelated properties: binary data is stored regardless of name, encryption is a separate process, and size is unrelated to naming.
Q5. How do executable extensions like .exe and .com differ from script extensions like .sh in terms of content?
📖 Explanation: An executable file such as .exe or .com holds machine‑language instructions that the CPU can run directly after loading. In contrast, a .sh script is a readable text file containing commands that a shell interpreter parses and executes line by line. The size of a file does not guarantee its type, encryption is optional, and scripts are not compiled into binary form before execution.
Q6. What is the primary purpose of archive extensions such as .zip or .tar?
📖 Explanation: Archive formats like .zip and .tar allow users to bundle several files and directories into one container, often applying compression to reduce total size. This simplifies distribution, backup, and storage. Encryption may be an optional feature, but the core function is grouping and optionally compressing data. Converting to binary is unrelated; many archive formats retain the original file types inside the container.
Q7. If a file named report has no extension, how might an application determine its type?
📖 Explanation: Many programs inspect the file header—often called a magic number—to identify the format regardless of the name. For example, a PDF begins with %PDF, and a PNG starts with \x89PNG. Size alone gives no reliable clue, and guessing based on the name is error‑prone. Ignoring the file would prevent any processing, so header analysis is the most robust method.
Q8. Why can the same file extension be associated with different file types on different operating systems?
📖 Explanation: Operating systems keep separate tables that map extensions to applications or handlers. Windows might open .txt with Notepad, while a Linux desktop could open the same .txt with Gedit. The extension itself does not enforce a single meaning; the association is defined by the OS configuration. Extensions do not mutate, and encryption does not affect the suffix.
Q9. Why might a developer choose to omit extensions from source files in a project that uses a build system?
📖 Explanation: Modern build tools can be configured with patterns or explicit lists that identify source files, object files, and headers without relying on suffixes. By omitting extensions, developers avoid accidental misclassification and can rename files without breaking the build. Extensions do not cause compilation errors, they add negligible size, and they are not a security risk in themselves.
Q10. In the context of file type handling, what is the role of MIME types compared to filename extensions?
📖 Explanation: MIME (Multipurpose Internet Mail Extensions) describe the nature of a file's data—such as text/plain or image/jpeg—allowing applications and web browsers to process content correctly regardless of its name. While extensions are a convenient shortcut for local systems, MIME types are the protocol‑level description used in HTTP and email. Neither supersedes the other; they complement each other for robust identification.
Q11. Analyze how the use of ambiguous extensions (e.g., .bin) can lead to security vulnerabilities when files are executed.
📖 Explanation: An extension like .bin offers no clear indication of purpose; a user might assume it is a harmless data file, while the OS may load it as an executable if the execute bit is set. Attackers exploit this ambiguity by disguising malware, leading users to run harmful code unintentionally. The other options describe unrelated effects; size visibility and automatic encryption are not inherent to the extension.
Q12. Discuss the impact of case sensitivity on file extensions in cross‑platform development.
📖 Explanation: Unix‑like systems treat file names, including extensions, as case‑sensitive, so MyFile.TXT and myfile.txt are distinct files. Windows, however, ignores case, allowing both names to refer to the same file. When code or scripts assume a particular case, they may fail on a case‑sensitive platform, leading to file‑not‑found errors. Directory name sensitivity is a separate issue, and extensions themselves are still part of the name.
Q13. Evaluate the consequences of relying solely on extensions for file type detection in a system that supports plug‑ins.
📖 Explanation: Plug‑ins often inspect the actual data inside a file to determine compatibility. If a system only checks extensions, a malicious or corrupted file with a trusted suffix (e.g., .dll) could be loaded, bypassing content validation and exposing the host to exploits. While plug‑ins can be designed to respect extensions, they generally perform deeper analysis, making sole reliance on suffixes unsafe. The other statements misrepresent plug‑in behavior.
Q14. How does the concept of an acyclic‑graph directory structure relate to the avoidance of circular references in file systems?
📖 Explanation: An acyclic‑graph (DAG) model means that following directory links—whether real directories or symbolic links—never leads back to a node already visited, thereby preventing infinite loops during traversal. This property is essential for utilities like recursive copy or search, which would otherwise get stuck. Allowing cycles would break many algorithms, while the DAG constraint does not prohibit legitimate hierarchical relationships.
Q15. A user attempts to run a script named backup.sh but the OS does not recognize it as executable. Which step should they take to resolve the issue?
📖 Explanation: On Unix‑like systems, a script must have the executable bit set (e.g., using chmod +x backup.sh) for the kernel to treat it as a runnable program. Changing the suffix to .exe or .txt does not affect execution rights, and moving the file to a system directory does not automatically grant permission. Setting the correct permission enables the OS to invoke the appropriate interpreter.
Q16. In a typical C development workflow, which extension indicates an object file produced after compilation?
📖 Explanation: After the compiler processes a source file (e.g., foo.c), it generates an intermediate object file with the .o extension containing machine code that is not yet linked. Header files use .h, source files use .c, and final executables use .exe on Windows. Recognizing .o files helps developers locate compiled units and manage linking steps efficiently.
Q17. A user wants to bundle several documents into a single file for easy transfer. Which extension should they choose?
📖 Explanation: The .zip extension represents a widely supported archive format that can contain multiple files and directories, optionally compressing them to reduce size. This makes it ideal for transferring a collection of documents. An .exe is an executable program, .docx is a single Word document, and .mp4 is a video file, none of which serve the bundling purpose.
Q18. A multimedia player cannot open a file named movie.mp4. Which of the following is the most likely cause?
📖 Explanation: Most playback failures stem from missing codecs—the software components that decode the video and audio streams inside the container. Even though the .mp4 extension signals a standard format, without the appropriate codec the player cannot interpret the data. File corruption is possible but less common, and the extension does not restrict content type. Operating system blocks are rare for media files.
Q19. A web server serves a file with a .pdf extension, but the file actually contains an image. What problem does this cause for clients?
📖 Explanation: Web browsers rely on the MIME type sent by the server (e.g., application/pdf) to decide how to handle a resource. If the content is actually an image (e.g., image/png) but the server advertises application/pdf, the browser may fail to render it, showing an error or prompting a download. The mismatch does not cause automatic correct display, nor does it make the client ignore the resource.
Q20. A developer wants their Java program to open only files with a .java extension. Which approach best ensures this restriction?
📖 Explanation: The simplest and most reliable method is to examine the filename and confirm it ends with the exact .java suffix before opening it. This prevents accidental processing of other file types. While reading the file header could provide additional safety, Java source files have no unique magic number, making suffix checking the most straightforward solution.
Q21. A backup script must skip files larger than 100 MB. Which command correctly filters files by size on a Unix system?
📖 Explanation: The find utility uses the -size test, where + indicates 'greater than' and the unit M stands for megabytes. Thus, find . -size +100M selects files larger than 100 MB, allowing the script to exclude them from the backup. The other options either use kilobytes (k) or represent sizes less than the threshold, which would not achieve the intended filter.
Q22. A user renames a file from report.docx to report.txt. What is the most likely outcome when opening the file in a word processor?
📖 Explanation: Most modern word processors examine the file's internal structure rather than relying solely on the extension. A .docx file contains a ZIP archive with XML parts, which the application can still recognize even if named .txt. Therefore, the document will usually open correctly, though the new name may cause confusion for users expecting plain text. The file is not corrupted merely by renaming.
Q23. A Linux installer includes a shared library with a .so extension. What must the system do before programs can use it?
📖 Explanation: Shared object files (.so) are loaded by the dynamic linker (ld.so) when a program starts or when dlopen is called. The system does not treat them as executables, so they need not be marked executable, nor does the PATH variable apply (it is for executables). Converting to .dll would break compatibility on Linux.
Q24. An administrator wants to enforce that only files with recognized extensions can be executed. Which policy best achieves this goal?
📖 Explanation: A whitelist of allowed extensions (e.g., .exe, .sh, .bin) can be enforced via security modules that check the suffix before permitting execution. This approach directly addresses the requirement without broadly disabling execution or relying on path‑based restrictions. AppArmor focuses on program behavior, not file extensions, and disabling execute bits would prevent all legitimate binaries from running.
Q25. A file system uses an acyclic‑graph directory structure to avoid loops. A user attempts to create a symbolic link that would introduce a cycle. What should the system do?
📖 Explanation: To preserve the DAG property, the file system must reject any operation that would create a cycle, such as a symbolic link pointing to an ancestor directory. Allowing the link would break traversal algorithms, while converting to a hard link is impossible for directories on most systems. Issuing a warning without preventing the cycle would still permit the problematic structure.
Q26. A multimedia application decides to use MIME type detection instead of extension checking to support .mp3 and .wav files. Which advantage does this approach provide?
📖 Explanation: MIME type detection examines the actual data inside a file, allowing the application to correctly identify audio streams even if the filename extension is wrong or missing. This improves compatibility and user experience. While it may aid in selecting codecs, the primary benefit is handling misnamed files. It does not inherently affect opening speed or file size.