An application for testing programmers contains an initial question version and newer question versions, represented by the following schema:
TABLE questions id INTEGER NOT NULL PRIMARY KEY name VARCHAR(50) NOT NULL parentId INTEGER REFERENCES question(id)
The initial question version has parentId set to NULL, other question versions will have parentId set to the previous version. Each question version can be a parent to only one other question version.
Finish the findAllVersions stored procedure so that it returns, in any order, question version ids that are ancestors or descendants of the given questionId, including the questionId parameter.
See the example case for more details.
- Example case: Wrong answer
- Calling the procedure with the first question in the chain: Wrong answer
- Calling the procedure with the last question in the chain: Wrong answer
- Calling the procedure with the question in the middle of the chain: Wrong answer