GATE 2013
80 questions
MCQ 801-mark 38 · 2-mark 42
Questions 56–60 of 80
Using public key cryptography, X adds a digital signature to message M, encrypts , and sends it to Y, where it is decrypted. Which one of the following sequences of keys is used for the operations?
Answer: (D)
Let us go through the steps:
- Signing: X signs with its own private key. Then X encrypts for Y with Y's public key.
- Y first decrypts with its own private key. Then Y checks the signature with X's public key.
Answer: Encryption: X's private key followed by Y's public key; Decryption: Y's private key followed by X's public key
- Signing: X signs with its own private key. Then X encrypts for Y with Y's public key.
- Y first decrypts with its own private key. Then Y checks the signature with X's public key.
Answer: Encryption: X's private key followed by Y's public key; Decryption: Y's private key followed by X's public key
The procedure given below is required to find and replace certain characters inside an input character string supplied in array A. The characters to be replaced are supplied in array oldc, while their respective replacement characters are supplied in array newc. Array A has a fixed length of five characters, while arrays oldc and newc contain three characters each. However, the procedure is flawed
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
If array A is made to hold the string "abcde", which of the above four test cases will be successful in exposing the flaw in this procedure?
void find_and_replace (char *A, char *oldc, char *newc) {
for (int i=0; i<5; i++)
for (int j=0; j<3; j++)
if (A[i] == oldc[j]) A[i] = newc[j];
}
The procedure is tested with the following four test cases. (1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
If array A is made to hold the string "abcde", which of the above four test cases will be successful in exposing the flaw in this procedure?
Answer: (C)
The code checks each against in order, and replaces it as soon as it matches. The flaw: after a replacement, the new character is compared against the later entries of and may be replaced again (a chained replacement). This needs to equal some with .
Test on "abcde":
- Case 1 (abc to dab): is not in oldc, and are earlier entries, which are already passed. No chain, so the output is the correct "dabde". Flaw not exposed.
- Case 2 (cde to bcd): , , never match a later entry of "cde" ( is , earlier than index 1; is , earlier than index 2). Output is the correct "abbcd". Not exposed.
- Case 3 (bca to cda): becomes () and then becomes (). Output has in place 2 instead of . Exposed.
- Case 4 (abc to bac): becomes () and then becomes (). Output keeps instead of . Exposed.
Cases 3 and 4 only.
Answer: (C)
Test on "abcde":
- Case 1 (abc to dab): is not in oldc, and are earlier entries, which are already passed. No chain, so the output is the correct "dabde". Flaw not exposed.
- Case 2 (cde to bcd): , , never match a later entry of "cde" ( is , earlier than index 1; is , earlier than index 2). Output is the correct "abbcd". Not exposed.
- Case 3 (bca to cda): becomes () and then becomes (). Output has in place 2 instead of . Exposed.
- Case 4 (abc to bac): becomes () and then becomes (). Output keeps instead of . Exposed.
Cases 3 and 4 only.
Answer: (C)
The procedure given below is required to find and replace certain characters inside an input character string supplied in array A. The characters to be replaced are supplied in array oldc, while their respective replacement characters are supplied in array newc. Array A has a fixed length of five characters, while arrays oldc and newc contain three characters each. However, the procedure is flawed
(1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
The tester now tests the program on all input strings of length five consisting of characters 'a', 'b', 'c', 'd' and 'e' with duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw?
void find_and_replace (char *A, char *oldc, char *newc) {
for (int i=0; i<5; i++)
for (int j=0; j<3; j++)
if (A[i] == oldc[j]) A[i] = newc[j];
}
The procedure is tested with the following four test cases. (1) oldc = "abc", newc = "dab"
(2) oldc = "cde", newc = "bcd"
(3) oldc = "bca", newc = "cda"
(4) oldc = "abc", newc = "bac"
The tester now tests the program on all input strings of length five consisting of characters 'a', 'b', 'c', 'd' and 'e' with duplicates allowed. If the tester carries out this testing with the four test cases given above, how many test cases will be able to capture the flaw?
Answer: (B)
The flaw: a character that is already replaced can be replaced a second time later in the j loop. This happens when newc[j] is equal to a later oldc[k] (where k j).
- (1) abc dab: b a, but a comes earlier in oldc so there is no chain
- (2) cde bcd: there is no chain
- (3) bca cda: b c, then c d the flaw is shown
- (4) abc bac: a b, then b a the flaw is shown
Answer: Only two
- (1) abc dab: b a, but a comes earlier in oldc so there is no chain
- (2) cde bcd: there is no chain
- (3) bca cda: b c, then c d the flaw is shown
- (4) abc bac: a b, then b a the flaw is shown
Answer: Only two
The following figure represents access graphs of two modules M1 and M2. The filled circles represent methods and the unfilled circles represent attributes. If method m is moved to module M2 keeping the attributes where they are, what can we say about the average cohesion and coupling between modules in the system of two modules?
Answer: (A)
Count the links of method in the figure. has 2 links to attributes in M1 and 2 links to attributes in M2.
Before the move, the 2 links to M1 attributes are inside the module (they add to cohesion) and the 2 links to M2 attributes cross the module boundary (they add to coupling).
After moves to M2, the 2 links to M2 attributes become internal and the 2 links to M1 attributes become cross-module. So the number of internal links stays the same in total (M1 loses 2, M2 gains 2) and the number of cross-module links stays 2. Neither cohesion nor coupling changes.
Answer: (A)
Before the move, the 2 links to M1 attributes are inside the module (they add to cohesion) and the 2 links to M2 attributes cross the module boundary (they add to coupling).
After moves to M2, the 2 links to M2 attributes become internal and the 2 links to M1 attributes become cross-module. So the number of internal links stays the same in total (M1 loses 2, M2 gains 2) and the number of cross-module links stays 2. Neither cohesion nor coupling changes.
Answer: (A)
Match the problem domains in GROUP I with the solution technologies in GROUP II.
Answer: (C)
- P, Service oriented computing, goes with Publish-find-bind (3): a provider publishes a service in a registry, a client finds it, then binds to it.
- Q, Heterogeneous communicating systems, goes with Interoperability (1): systems built on different platforms must still work together.
- R, Information representation, goes with XML (4): a platform-neutral format for representing data.
- S, Process description, goes with BPMN (2): Business Process Model and Notation, used to describe business processes.
So P-3, Q-1, R-4, S-2.
Answer: (C)
- Q, Heterogeneous communicating systems, goes with Interoperability (1): systems built on different platforms must still work together.
- R, Information representation, goes with XML (4): a platform-neutral format for representing data.
- S, Process description, goes with BPMN (2): Business Process Model and Notation, used to describe business processes.
So P-3, Q-1, R-4, S-2.
Answer: (C)