GATE 2004
199 questions
MCQ 1991-mark 199
Questions 146–150 of 199
A unix-style I-node has 10 direct pointers and one single, one double and one triple indirect pointers. Disk block size is 1 Kbyte, disk block address is 32 bits, and 48-bit integers are used. What is the maximum possible file size?
Answer: (C)
Block size = 1 KB = bytes. A block address is 32 bits = 4 bytes, so one block holds addresses.
Data blocks the I-node can reach:
- Direct: 10 blocks
- Single indirect: blocks
- Double indirect: blocks
- Triple indirect: blocks
Maximum file size = bytes. The triple-indirect part is by far the largest, so the total is just above bytes. No option equals it exactly, and the closest is bytes.
The 32-bit block address and the 48-bit integer do not cut this down. 32 bits can name blocks, which is bytes, and a 48-bit integer can count up to bytes. Both are more than , so the pointer layout of the I-node is the real limit.
Answer: (C)
Data blocks the I-node can reach:
- Direct: 10 blocks
- Single indirect: blocks
- Double indirect: blocks
- Triple indirect: blocks
Maximum file size = bytes. The triple-indirect part is by far the largest, so the total is just above bytes. No option equals it exactly, and the closest is bytes.
The 32-bit block address and the 48-bit integer do not cut this down. 32 bits can name blocks, which is bytes, and a 48-bit integer can count up to bytes. Both are more than , so the pointer layout of the I-node is the real limit.
Answer: (C)
Which of the following commands or sequences of commands will rename a file x to file y in a Unix system ?
I. mv y, x
II. mv x, y
III. cp y, x (rm x)
IV. cp x, y (rm x)
I. mv y, x
II. mv x, y
III. cp y, x (rm x)
IV. cp x, y (rm x)
Answer: (B)
The mv command moves or renames a file. mv source dest renames the file source to dest. cp copies a file. rm deletes a file. (The commas in the statements only separate the arguments.)
- I. mv y, x: renames y to x. This is the wrong direction.
- II. mv x, y: renames x to y. This is correct.
- III. cp y, x (rm x): copies y to x, and then removes x. File y is still there and x is gone. This is wrong.
- IV. cp x, y (rm x): copies x to y, and then removes x. File y now has the old contents of x and x is gone. This is a rename.
So II and IV rename x to y.
Answer: (B)
- I. mv y, x: renames y to x. This is the wrong direction.
- II. mv x, y: renames x to y. This is correct.
- III. cp y, x (rm x): copies y to x, and then removes x. File y is still there and x is gone. This is wrong.
- IV. cp x, y (rm x): copies x to y, and then removes x. File y now has the old contents of x and x is gone. This is a rename.
So II and IV rename x to y.
Answer: (B)
Consider the relation Student (, sex, marks), where the primary key is shown underlined, pertaining to students in a class that has at least one boy and one girl. What does the following relational algebra expression produce? (Note: is the rename operator).
Answer: (D)
The join pairs each student row with a renamed copy of , keeping a pair only if the first student is female, the copy is male, and . So the second part, after , is the set of girls whose marks are at most the marks of some boy.
The whole expression takes all girls and removes those girls. What is left are girls who are not below or equal to any boy, so each has more marks than every boy. Since there is at least one boy, this is meaningful.
Example: boys with 100 and 40, girls with 50 and 30. Each girl is at most the boy with 100, so both are removed and the result is empty. Option (B) would wrongly include the girl with 50, because she has more marks than the boy with 40. Option (C) is the opposite filter (girls who are at least as good as some boy). Option (A) says nothing about boys, so it does not match.
Answer: (D)
The whole expression takes all girls and removes those girls. What is left are girls who are not below or equal to any boy, so each has more marks than every boy. Since there is at least one boy, this is meaningful.
Example: boys with 100 and 40, girls with 50 and 30. Each girl is at most the boy with 100, so both are removed and the result is empty. Option (B) would wrongly include the girl with 50, because she has more marks than the boy with 40. Option (C) is the opposite filter (girls who are at least as good as some boy). Option (A) says nothing about boys, so it does not match.
Answer: (D)
Let R1(,B,(C)) and R2(,E) be two relation schema, where the primary keys are shown underlined, and let C be a foreign key in R1 referring to R2 . Suppose there is no violation of the above referential integrity constraint in the corresponding relation instances r1 and r2 . Which one of the following relational algebra expressions would necessarily produce an empty relation?
Answer: (B)
C in R1 is a foreign key that refers to the primary key D of R2, and there is no violation. So every value in is also a value in :
So is always empty. This is option (B).
The others can be non-empty for some valid instances:
- (A) holds the D values that no R1 tuple refers to. If r2 has a tuple that nobody references (for example, r1 is empty and r2 is not), it is not empty.
- (C) pairs each R1 tuple with every R2 tuple that has a different D. If r1 has a tuple and r2 has two or more tuples, some R2 tuple has a D different from that tuple's C, so the result is not empty.
- (D) gives every C value of r1, because each one has a matching D. It is not empty when r1 has at least one tuple.
Answer: (B)
So is always empty. This is option (B).
The others can be non-empty for some valid instances:
- (A) holds the D values that no R1 tuple refers to. If r2 has a tuple that nobody references (for example, r1 is empty and r2 is not), it is not empty.
- (C) pairs each R1 tuple with every R2 tuple that has a different D. If r1 has a tuple and r2 has two or more tuples, some R2 tuple has a D different from that tuple's C, so the result is not empty.
- (D) gives every C value of r1, because each one has a matching D. It is not empty when r1 has at least one tuple.
Answer: (B)
Consider two tables in a relational database with columns and rows as follows:
Roll_no is the primary key of the Student table, Dept_id is the primary key of the Department table and Student.Dept_id is a foreign key from Department.Dept_id
What will happen if we try to execute the following two SQL statements?
update Student set Dept_id = Null where Roll_on = 1
update Department set Dept_id = Null where Dept_id = 1
Roll_no is the primary key of the Student table, Dept_id is the primary key of the Department table and Student.Dept_id is a foreign key from Department.Dept_id
What will happen if we try to execute the following two SQL statements?
update Student set Dept_id = Null where Roll_on = 1
update Department set Dept_id = Null where Dept_id = 1
Answer: (C)
Statement (i): it sets Dept_id to NULL in the Student table (reading Roll_on as Roll_no). Here Dept_id is a foreign key, not the primary key, and a foreign key is allowed to be NULL. So (i) succeeds.
Statement (ii): it sets Dept_id to NULL in the Department table. Here Dept_id is the primary key, and a primary key can never be NULL. So (ii) fails. It would also leave student 2, who still refers to Dept_id 1, pointing at a department that no longer exists.
So (i) succeeds and (ii) fails.
Answer: (C)
Statement (ii): it sets Dept_id to NULL in the Department table. Here Dept_id is the primary key, and a primary key can never be NULL. So (ii) fails. It would also leave student 2, who still refers to Dept_id 1, pointing at a department that no longer exists.
So (i) succeeds and (ii) fails.
Answer: (C)