ProgrammingHardTCS Digital · Capgemini
What will be the output of the following pseudocode?
What will be the output of the following pseudocode?
Integer m[3][3] = {{2, 0, 1}, {1, 3, 2}, {1, 1, 1}}
Integer det = m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0])
Print det- A. 4
- B. 2
- C. 0
- D. 6
Correct answer: C. 0
Expanding along the first row: 2(3·1 − 2·1) − 0 + 1(1·1 − 3·1) = 2(1) + 1(−2) = 0. The matrix is singular.
Practise more Pseudocode and Code Tracing questionsPseudocode and Code Tracing: notes and key points
More Pseudocode and Code Tracing questions
- What will be the output of the following pseudocode? Integer m[4][4] = {{4, 3, 2, -1}, {3, 2, 1, -1}, {1, 1, -1, -2}, {-1, -1, -2, -3}}…
- What will be the output of the following pseudocode? // list: 1 -> 2 -> 3 -> 4 -> 5 -> NULL Integer n = 5, k = 2 Node tail = last node…
- What will be the output of the following pseudocode? Insert into an empty BST, in this order: 50, 30, 70, 20, 40, 60, 80, 35, 45, 65…
- What will be the output of the following pseudocode? // undirected graph; neighbours are visited in increasing order Edges: 1-2, 1-3, 2-4…
- What will be the output of the following pseudocode? // undirected graph; neighbours are visited in increasing order Edges: 1-2, 1-3, 2-4…
- What will be the output of the following pseudocode? Integer parent[1..8] for (each i from 1 to 8) parent[i] = i Function find(Integer x)…