1. The binary representation of the decimal number -6 in 8-bit two's complement is:
A. 11111010
B. 10000110
C. 11111001
D. 10000011
Answer: A) 11111010
Rationale: The two's complement of -6 in 8-bit binary is 11111010. First, write 6 in
binary (00000110), then invert the bits (11111001), and finally add 1 (11111010).
2. What is the largest number that can be represented by a 4-bit binary number?
A. 15
B. 16
C. 14
D. 17
Answer: A) 15
Rationale: A 4-bit binary number can represent values from 0000 (0 in decimal) to
1111 (15 in decimal). So, the largest value is 15.
3. What is the time complexity of bubble sort?
A. O(n)
,B. O(n^2)
C. O(log n)
D. O(n log n)
Answer: B) O(n^2)
Rationale: Bubble sort compares adjacent elements and swaps them if needed. This
process is repeated for each element, resulting in a time complexity of O(n^2).
4. Which data structure is best suited for implementing a priority queue?
A. Array
B. Stack
C. Heap
D. Queue
Answer: C) Heap
Rationale: A heap is an efficient data structure for implementing a priority queue
because it allows quick access to the highest (or lowest) priority element.
5. The worst-case time complexity of quicksort is:
A. O(n log n)
B. O(n^2)
C. O(n)
D. O(log n)
Answer: B) O(n^2)
, Rationale: In the worst case, when the pivot selection is poor, the quicksort algorithm
has a time complexity of O(n^2).
6. In binary arithmetic, what is the result of 1101 + 1011?
A. 11000
B. 11010
C. 10111
D. 10000
Answer: A) 11000
Rationale: The binary addition of 1101 and 1011 is as follows:
markdown
Copy
1101
+ 1011
-------
11000
7. The main function in C programming language is called:
A. void()
B. main()
C. start()
D. entry()
A. 11111010
B. 10000110
C. 11111001
D. 10000011
Answer: A) 11111010
Rationale: The two's complement of -6 in 8-bit binary is 11111010. First, write 6 in
binary (00000110), then invert the bits (11111001), and finally add 1 (11111010).
2. What is the largest number that can be represented by a 4-bit binary number?
A. 15
B. 16
C. 14
D. 17
Answer: A) 15
Rationale: A 4-bit binary number can represent values from 0000 (0 in decimal) to
1111 (15 in decimal). So, the largest value is 15.
3. What is the time complexity of bubble sort?
A. O(n)
,B. O(n^2)
C. O(log n)
D. O(n log n)
Answer: B) O(n^2)
Rationale: Bubble sort compares adjacent elements and swaps them if needed. This
process is repeated for each element, resulting in a time complexity of O(n^2).
4. Which data structure is best suited for implementing a priority queue?
A. Array
B. Stack
C. Heap
D. Queue
Answer: C) Heap
Rationale: A heap is an efficient data structure for implementing a priority queue
because it allows quick access to the highest (or lowest) priority element.
5. The worst-case time complexity of quicksort is:
A. O(n log n)
B. O(n^2)
C. O(n)
D. O(log n)
Answer: B) O(n^2)
, Rationale: In the worst case, when the pivot selection is poor, the quicksort algorithm
has a time complexity of O(n^2).
6. In binary arithmetic, what is the result of 1101 + 1011?
A. 11000
B. 11010
C. 10111
D. 10000
Answer: A) 11000
Rationale: The binary addition of 1101 and 1011 is as follows:
markdown
Copy
1101
+ 1011
-------
11000
7. The main function in C programming language is called:
A. void()
B. main()
C. start()
D. entry()