ITPEC IP April 2018 Question 17

Topic: SoftwareAlso asked in October 2019 and November 2021

The diagram below shows the directory structure for a part of a certain file system. Which of the following is the reference from the current directory D3 (indicated with an asterisk “∗”) to the file “a” under the directory D4 (indicated with an arrow)? Here, files are specified as follows:

[Methods to specify files](1)A file is referenced as “directory name\⋯\directory name\file name”, where the directory names on the path are listed and separated with “\” (backslash) in sequence, followed by “\” and the file name.(2)The current directory is represented by “.” (one period).(3)The directory one level above is represented by “..” (two periods).(4)When a reference begins with “\”, it is assumed that the root directory is omitted from the beginning of the reference.(5)When a reference does not start with “\”, “.”, or “..”, it is assumed that “.\”, which means that the reference is under the current directory, is omitted from the beginning of the reference.
D1D2D3D4D5

Explanation

..\D2\D4\a — go up from D3 to the common parent D1, then down through D2 to D4.

D3 and D2 are both directly under D1, so one .. takes the reference from D3 to D1. From D1, the path goes down to D2, then D4, and ends with the file name: ..\D2\D4\a.

Answer (b)

Why not others:

  • •(a) — the second .. moves above D1, where there is no D2 as shown
  • •(c) — it does not start with \, . or .., so by rule (5) it is read as .\D1\D2\D4\a, a D1 under D3, which does not exist
  • •(d) — by rule (5) it is read as .\D2\D4\a, looking for D2 under D3, but D2 is under D1

Key rule: A relative path climbs with .. to the nearest common ancestor of the current directory and the target, then names each directory on the way down.

Software · AI-written, may contain errors

This question comes from an official ITPEC past paper. ITPEC Practice is an independent study tool and is not affiliated with ITPEC. See the official IP past-paper collection or Report an issue.