Forwarded from β€
6. π What character is used to comment in Assembly
Anonymous Quiz
27%
A) //
20%
B) #
20%
C) ;
33%
D) <!-- -->
Forwarded from β€
7. π What is the command to jump to a line in loops (similar to goto in C++)?
Anonymous Quiz
50%
A) JMP
8%
B) JNP
0%
C) JPM
42%
D) JUM
Forwarded from β€
8. β‘οΈ Which operation is faster?
Anonymous Quiz
0%
A) Fetching from ROM
7%
B) Fetching from RAM
93%
C) Fetching from CPU registers
Forwarded from β€
9. β³ How many cycles does it take to fetch data from CPU registers and from RAM?
Anonymous Quiz
25%
A) 10 cycles for register, 100 cycles for RAM
17%
B) 10 cycles for register, 1000 cycles for RAM
50%
C) 1 cycle for register, 100 cycles for RAM
8%
D) 100 cycles for register, 1000 cycles for RAM
Forwarded from β€
10. π§ If registers are much faster, why can't we use them instead of memory?
Anonymous Quiz
7%
A) CPUs are small in size
79%
B) Registers cannot hold data for longer periods
14%
C) Registers have smaller sizes (16, 32, 64 bits)
π How many questions did you ace? π₯
Letβs see how many of you are ready for the exam! π Drop your score below!
Out of 23 questions, how many did you get right? π€
Letβs see how many of you are ready for the exam! π Drop your score below!
Out of 23 questions, how many did you get right? π€
Anonymous Poll
25%
π All of them! (23/23)
25%
π Almost there! (20-22)
25%
π‘ Got a solid score! (15-19)
13%
π₯ Some tough ones! (10-14)
13%
π
Well, I tried! (0-9)
Mosh-cheat-sheets.zip
7.1 MB
π Cheat Sheets by Mosh π
Quick reference for Java, Python, SQL, and Git! π
βοΈ Java Cheat Sheet
π Python Cheat Sheet
π SQL Cheat Sheet
π» Git Cheat Sheet
Stay tuned for more! π₯
ππ @AceCoding Presents! ππ
#Java #Python #SQL #Git #CheatSheet
Quick reference for Java, Python, SQL, and Git! π
βοΈ Java Cheat Sheet
π Python Cheat Sheet
π SQL Cheat Sheet
π» Git Cheat Sheet
Stay tuned for more! π₯
ππ @AceCoding Presents! ππ
#Java #Python #SQL #Git #CheatSheet
π2
Whatβs wrong with the above snippet of code?
Anonymous Quiz
40%
a. Perfectly fine
14%
b. Sum is not printed
21%
c. Runtime error
24%
d. Compilation error
π₯4
Predict the output:
int i = 0;
while (++i < 5);
cout << "i: " << i << endl;
Choose your answer for the above code.
Anonymous Quiz
31%
π
°οΈ i: 4
21%
π
±οΈ i: 5
18%
π
ΎοΈ i: 6
18%
β Infinite loop
13%
β Compilation error
Predict the output:
int x = 5;
int y = 10;
(x > y ? x : y) = 50;
cout << "x: " << x << ", y: " << y << endl;
Choose your answer for the above.
Anonymous Quiz
4%
π
°οΈ x: 50, y: 50
4%
π
±οΈ x: 10, y: 50
65%
π
ΎοΈ x: 5, y: 50
19%
β Undefined behavior
8%
β Compilation error
choose your answer for the above.
Anonymous Quiz
24%
π
°οΈ [3, 4, 1, 2]
0%
π
±οΈ [4, 2]
0%
π
ΎοΈ [3, 1]
6%
4
6%
2
12%
3
0%
1
18%
β Undefined behavior
35%
β Compilation error
π Types of Errors in a Program: π₯β‘οΈπ
ππ @AceCoding Presents! ππ
π₯ Compilation Error: (Cannot compile, cannot run)
Occurs when the code has syntax issues, preventing it from being compiled. Common examples include missing semicolons, mismatched parentheses, or undeclared variables.
Example: int x = ;
β‘οΈ Runtime Error: (Compiles but cannot run, compilation comes before code execution or running)
Happens while the program is running. It usually occurs due to illegal operations like division by zero, accessing invalid memory, or infinite loops.
Example: int x = 5 / 0;
π Logical Error: (Code compiles and runs but won't result a correct output)
Occurs when the code runs without crashing, but it produces incorrect results due to flawed logic or assumptions. It can be tricky to spot as the program compiles and runs fine.
Example: int a = 5; int b = 2; cout << a - b; (Expecting multiplication but using subtraction)
ππ @AceCoding Presents! ππ
π Simple Sorting Algorithms implementation in in C++
1. Insertion Sort
2. Bubble Sort
β Optimized version of bubble sort, which will give a TC of O(n) best case (array is already sorted)
3. Selection Sort
βοΈ Which Sorting Algorithm is Best?
- Insertion Sort is efficient for small or nearly sorted datasets.
- Bubble Sort is simple but slow for large datasets (O(nΒ²) time complexity).
- Selection Sort is also O(nΒ²) but has a fixed number of swaps.
ππ @AceCoding Presents! ππ
1. Insertion Sort
void insertion_sort(int arr[], int size) {
int temp, i, j;
for (i = 0; i < size; i++) {
temp = arr[i];
j = i;
while (j > 0 && arr[j-1] > temp) {
arr[j] = arr[j - 1];
j--;
}
arr[j] = temp;
}
}2. Bubble Sort
void bubble_sort(int arr[], int size) {
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if (arr[i] > arr[j]) {
swap(arr[i], arr[j]);
}
}
}
return;
}β Optimized version of bubble sort, which will give a TC of O(n) best case (array is already sorted)
void bubbleSortOptimized(int arr[], int size) {
for (int i = 0; i < size - 1; i++) {
bool swapped = false;
for (int j = 0; j < size - 1 - i; j++) {
if (arr[j] > arr[j + 1]) {
swap(arr[j], arr[j + 1]);
swapped = true;
}
}
if (!swapped) break;
}
}3. Selection Sort
void selection_sort(int arr[], int size) {
int min_index;
for (int i = 0; i < size; i++) {
min_index = i;
for (int j = i + 1; j < size; j++) {
if (arr[j] < arr[min_index]) {
min_index = j;
}
}
swap(arr[i], arr[min_index;
}
}βοΈ Which Sorting Algorithm is Best?
- Insertion Sort is efficient for small or nearly sorted datasets.
- Bubble Sort is simple but slow for large datasets (O(nΒ²) time complexity).
- Selection Sort is also O(nΒ²) but has a fixed number of swaps.
ππ @AceCoding Presents! ππ
Here you can see the trade-offs of different sorting algorithms π
ππ @AceCoding Presents! ππ
ππ @AceCoding Presents! ππ
Data Structures Using C++.pdf
5.3 MB
Data Structures Using C++
Data Structure Worksheet.docx
20.4 KB
Data Structure Worksheet