WorksheetsMIDTERM REVISION
Total questions: 25
Worksheet time: 13mins
What approach does Merge Sort use?
(Merge Sort hangi yaklaşımı kullanır?)
Early stopping
Divide & Conquer
In-place, stable
Greedy
Worst-case execution of Merge Sort:
(Merge Sort'un en kötü durum çalışması:)
O(n)
O(n²)
O(n log n)
O(2ⁿ)
What is the purpose of the key variable in Insertion Sort?
(Insertion Sort’ta key değişkeni hangi amaçla kullanılır?)
To perform the merge step.
It is the pointer that moves through the array.
It holds the new element to be inserted.
It holds the swap count.
What is the purpose of the swaps flag used in Bubble Sort? (Bubble Sort'ta kullanılan swaps bayrağı ne işe yarar?)
Calculating the array size
Splitting the array in half
Terminating the loop early if no elements have been changed
Storing the key element
Which of the following does not belong to the Divide & Conquer structure? (Aşağıdakilerden hangisi Divide & Conquer yapısına ait değildir?)
break the problem apart
solve subproblems
combine solutions
solve with only one repeat
What approach does Bubble Sort use?
Early stopping
Divide & Conquer
In-place, stable
Greedy
What approach does Insertion Sort use?
Early stopping
Divide & Conquer
In-place, stable
Greedy
What is the purpose of size-i-1 in the bubble sort expression:
(Bubble Sort içinde geçen size-i-1 ifadesinin amacı nedir?
This is to use memory more efficiently and reduce processing overhead by resizing the array at each outer loop step.
It increases the array size.
It reduces the number of swaps.
Since the largest element is placed at the end of each iteration, it is not rechecked.
The merge function creates two subarrays: What are these subarrays used for?
(Merge fonksiyonunda iki alt dizi oluşturuluyor: Bu alt diziler hangi amaçla kullanılır?)
Reducing the size of the array.
Reducing memory usage.
Recording the number of swaps.
Temporarily storing the left and right subarrays.
The following merge loop guarantees which one?
(Aşağıdaki merge döngüsü: Neyi garanti eder?)
The array is not reversed.
The elements are merged stably.
Memory is reduced.
Time complexity is not linear.
What does the Merge Sort function do, in that order?
(Merge Sort fonksiyonu sırasıyla ne yapar?)
Split the array → Copy from left to right → Print
Split → Sort → Merge
Swap → Sort → Print
Print → Sort → Swap
Why does Merge Sort use m+1 in recursive calls?
(Merge Sort recursive çağrılarda neden m+1 kullanır?)
To skip the middle element
To free memory
To indicate the beginning of the right substring
To ensure linear code execution
Why is Merge Sort recursive?
(Merge Sort neden recursive’dir?)
It sorts sub-arrays by calling itself.
Memory management is automatic.
It requires fixed-size arrays.
Because it does not require swap operation.
Which sorting algorithm does the given pseudocode belong to? (Verilen pseudocode hangi sıralama algoritmasına aittir?)
Bubble Sort
Merge Sort
Insertion Sort
Selection Sort
What is guaranteed when the condition given in the merge function is fulfilled? (Merge fonksiyonunda verilen şartı tamamlandığında ne garanti edilir?)
The elements are reversed.
The sorting is complete.
At least one sub-array is exhausted.
Both sub-arrays are completely exhausted.
The following Insertion Sort inner loop: in which case it will not work?
(Aşağıdaki Insertion Sort iç döngüsü: hangi durumda çalışmaz?)
If key is less than or equal to the element to its left
If j == 0
If i == 0
If the array is not sorted
What is the purpose of the following code snippet in a C++ program?
(Aşağıdaki kod parçası C++ programında ne amaçla kullanılır?)
It is used to populate the array by assigning each input from the user to its corresponding index in the array.
It automatically sorts all elements in the array from smallest to largest and prints them to the screen.
It doubles the size of the array in memory, allocates new memory space, and copies the elements.
It is used to process only the middle elements of the array and ignore the remaining elements.
What is the purpose of this function in that line?
(Bu fonksiyonun ilgili satırdaki amacı nedir?)
Deletes the elements of the array and frees the memory.
Divides the array into two sub-arrays, preparing them for the merge operation.
Prints the sorted array to the screen, showing the final state of the array.
Sorts the array and simultaneously recreates it in memory.
What will be the output of this code?
1 1
0 9
1 9
0 1
Is there an error in the loop written to fill the elements of the array with a certain size?
(Boyutu belli olan (size) dizinin elemanlarını doldurmak için yazılan döngüde hata var mıdır?)
No error
There is a risk of out-of-bounds
No input is received
Only one element is read
What will be the output of this code?
2
7
1
2 1
What is arr after the following steps?
Start:
int arr[3] = {4, 3, 1}
Step:
swap(arr[0], arr[1])
After:
swap(arr[1], arr[2])
1 4 3
3 4 1
3 1 4
4 1 3
What is wrong with this code?
The swaps variable is defined incorrectly.
The second parameter is missing in the bubbleSort(arr); call.
The definition of arr[n] is incorrect because n is not a constant.
The for loop must have i <= n.
What is the purpose of this code?
Add two numbers and print the result.
Reset the values of variables.
Create a new array in memory.
Swap the values of two integer variables.
What is the output of this code?
0
1
2
3
