GATE 2023
65 questions
MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35
Questions 61–65 of 65
Consider the following table named Student in a relational database. The primary key of this table is rollNum.
The SQL query below is executed on this database.
The number of rows returned by the query is ______
The SQL query below is executed on this database.
SELECT *
FROM Student
WHERE gender = 'F' AND
marks > 65;
The number of rows returned by the query is ______
Answer: 2
Check the rows where gender = 'F' and marks 65:
- Aliya, 70: True
- Aliya, 80: True
- Swati, 65: False (65 is not more than 65)
SELECT * gives the whole row, so the repeated name is not a problem.
Answer: 2
- Aliya, 70: True
- Aliya, 80: True
- Swati, 65: False (65 is not more than 65)
SELECT * gives the whole row, so the repeated name is not a problem.
Answer: 2
Consider a database of fixed-length records, stored as an ordered file. The database has 25,000 records, with each record being 100 bytes, of which the primary key occupies 15 bytes. The data file is block-aligned in that each data record is fully contained within a block. The database is indexed by a primary index file, which is also stored as a block-aligned ordered file. The figure below depicts this indexing scheme.
Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of blocks takes block accesses in the worst case.
Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is _____
Suppose the block size of the file system is 1024 bytes, and a pointer to a block occupies 5 bytes. The system uses binary search on the index file to search for a record with a given key. You may assume that a binary search on an index file of blocks takes block accesses in the worst case.
Given a key, the number of block accesses required to identify the block in the data file that may contain a record with the key, in the worst case, is _____
Answer: 6
Find the index size in steps:
- Records in one data block = So the number of data blocks = 25000 / 10 = 2500.
- The primary (sparse) index keeps one entry for each data block. That gives 2500 entries, and each entry is bytes.
- Entries in one index block = So the number of index blocks = .
Now do binary search on the index: block accesses are needed to find the data block.
Answer: 6
- Records in one data block = So the number of data blocks = 25000 / 10 = 2500.
- The primary (sparse) index keeps one entry for each data block. That gives 2500 entries, and each entry is bytes.
- Entries in one index block = So the number of index blocks = .
Now do binary search on the index: block accesses are needed to find the data block.
Answer: 6
Consider the language L over the alphabet {0, 1}, given below:
The minimum number of states in a Deterministic Finite-State Automaton (DFA) for L is _____.
The minimum number of states in a Deterministic Finite-State Automaton (DFA) for L is _____.
Answer: 4
The DFA counts the 1s seen in a row:
- q0: start, or the last symbol was 0 (no 1 pending)
- q1: one 1 in a row
- q2: two 1s in a row
- q3: three 1s in a row, a dead state (non-final) that loops on 0 and 1
Transitions: on 1, q0 q1 q2 q3. On 0, q0, q1 and q2 all go back to q0. q0, q1 and q2 are final.
The 4 states are distinguishable. q3 rejects everything, while the other three accept the empty string. From q2 the string "1" is rejected, but from q0 and q1 it is accepted. From q1 the string "11" is rejected, but from q0 it is accepted. So no state can be merged.
Answer: 4
- q0: start, or the last symbol was 0 (no 1 pending)
- q1: one 1 in a row
- q2: two 1s in a row
- q3: three 1s in a row, a dead state (non-final) that loops on 0 and 1
Transitions: on 1, q0 q1 q2 q3. On 0, q0, q1 and q2 all go back to q0. q0, q1 and q2 are final.
The 4 states are distinguishable. q3 rejects everything, while the other three accept the empty string. From q2 the string "1" is rejected, but from q0 and q1 it is accepted. From q1 the string "11" is rejected, but from q0 it is accepted. So no state can be merged.
Answer: 4
An 8-way set associative cache of size 64 KB (1 KB = 1024 bytes) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET.
The number of bits in the TAG is ____.
The number of bits in the TAG is ____.
Answer: 19
One way has a size of bytes.
The INDEX bits and the OFFSET bits together are used to address one way. So they add up to 13 bits. The block size does not matter here.
Number of TAG bits:
Answer: 19
The INDEX bits and the OFFSET bits together are used to address one way. So they add up to 13 bits. The block size does not matter here.
Number of TAG bits:
Answer: 19
The forwarding table of a router is shown below.
A packet addressed to a destination address 200.150.68.118 arrives at the router. It will be forwarded to the interface with ID _____.
A packet addressed to a destination address 200.150.68.118 arrives at the router. It will be forwarded to the interface with ID _____.
Answer: 3
Compare 200.150.68.118 with each entry (longest prefix wins):
- 200.150.0.0/16 match
- 200.150.64.0/19 (third octet 64-95) 68 is in range, match
- 200.150.68.0/24 match
- 200.150.68.64/27 (last octet 64-95) 118 is outside, no match
The longest match is /24 interface 3.
Answer: 3
- 200.150.0.0/16 match
- 200.150.64.0/19 (third octet 64-95) 68 is in range, match
- 200.150.68.0/24 match
- 200.150.68.64/27 (last octet 64-95) 118 is outside, no match
The longest match is /24 interface 3.
Answer: 3