NEW
Font size
WorksheetsPROGRAMMING Reviewer
Total questions: 22
Worksheet time: 11mins
It is used to execute both the true part and the false part of a given condition. It is used turn run one block of code under certain conditions and another block of code under different conditions.
If-else statement
Else statement
Else if statement
An object-oriented programming (OOP) language that is viewed by many as the best language for creating large scale applications.
Java
Python
C++
It is a key part of the decision-making process from programs.
Statement
Condition
If-else
A group of expressions and/or _________ that you design to carry out a task or an action.
Statement
Condition
If-else
What does an if-else statement evaluate in C++?
It evaluates a condition and execute a block of code based on the result
It evaluates whether a variable is true or false
How can you write a nested if-else statement in C++?
By using a single if-else statement with multiple conditions
By placing one if-else statement inside another if-else statement
Why is it important to use curly braces () in an if-else statement even if there is only one statement inside?
To ensure correct scoping and avoid unexpected behavior
To make the code run faster and to improve code readability
Why might you choose to use if-else ladder instead of nested if-else statements in certain situations?
To increase code complexity
To handle multiple mutually exclusive conditions more efficiently
TRUE or FALSE: Bubble sort is a stable sorting algorithm.
True
False
TRUE or FALSE: Insertion sorting is more efficient than insertion sort for sorting small data sets.
True
False
TRUE or FALSE: Selection sort has a good case time complexity of O(n^2)
True
False
TRUE or FALSE: Bubble sort always performs better than selection sort.
True
False
TRUE or FALSE: Insertion sort performs better than bubbles sort for nearly sorted arrays.
True
False
It is used to rearrange a given array or a list of elements according to a comparison operator on the elements. This help in arranging data in a specific order, making it easier and faster to search, retrieve, and analyze information.
Sorting Algorithm
Insertion Sort
Selection Sort
A sorting algorithm which is commonly used in computer science; it is based on the idea of repeatedly comparing pairs of adjacent elements and then swapping their positions if they exist in the wrong order.
Bubble Sort
Insertion Sort
Selection Sort
It is a sorting algorithm which sorts the arrays by shifting the elements one at a time.
Bubble Sort
Insertion Sort
Selection Sort
It is a simple comparison-based sorting algorithm that works by dividing the input list into two parts: This sorted part and unsorted part.
Bubble Sort
Insertion Sort
Selection Sort
Which of the following best describes the operation of the bubble sort algorithm?
It repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order
It select the maximum element and moves it to the end of the list in each iteration
How does the selection sort algorithm work?
It divides the list into two sub lists, repeatedly merging them to achieve a sorted array
It selects the minimum element and swaps it with the leftmost unsorted element
In selection sort, which of the following best describes the key operation?
Selecting the minimum element and placing it at the beginning
Dividing the array into two subarrays and merging them
What is the key idea behind the insertion sort algorithm?
It divides the array into two subarrays and recursively sorts them
It inserts elements into their correct position one at a time
How does insertion sort work?
It finds the maximum element in moves it to the end of the array
It builds the final sorted array one element at a time by inserting elements into the correct position
