This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nikita Munkhoev | |
// 2023002 | |
// Recursion | |
class Bunny { | |
final String name; | |
final List<Bunny> babies; | |
Bunny({required this.name, required this.babies}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
Node(this.value, [this.next]); | |
int value; | |
Node? next; | |
@override | |
String toString() { | |
final result = StringBuffer(); | |
result.write(value); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Nikita Munkhoev | |
// 2023002 | |
void main() { | |
final sortedList = [1, 3, 5, 7, 9, 11, 13]; | |
final target = 7; | |
final index = binarySearch(sortedList, target); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void selectionSort(List<int> arr) { | |
int n = arr.length; | |
for (int i = 0; i < n - 1; i++) { | |
int minIndex = i; | |
// Find the minimum in the remaining array | |
for (int j = i + 1; j < n; j++) { | |
if (arr[j] < arr[minIndex]) { | |
minIndex = j; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void bubbleSort(List<int> arr) { | |
int n = arr.length; | |
bool swapped; | |
for (int i = 0; i < n - 1; i++) { | |
swapped = false; | |
for (int j = 0; j < n - i - 1; j++) { | |
if (arr[j] > arr[j + 1]) { | |
// Swap |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Name: Nikita Munkhoev | |
#ID: 2023002 | |
import 'dart:typed_data'; | |
class MyList16 { | |
static const int _elementSize = 2; // 2 bytes per number | |
static const int _defaultCapacity = 8; | |
late Uint8List _data; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Name: Nikita Munkhoev | |
#ID: 2023002 | |
void bubbleSort(List<int> list) { | |
for (int i = 0; i < list.length; i++) { | |
for (int j = 0; j < list.length - i - 1; j++) { | |
if (list[j] > list[j + 1]) { | |
int temp = list[j]; | |
list[j] = list[j + 1]; | |
list[j + 1] = temp; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Name: Nikita Munkhoev | |
#ID: 2023002 | |
import 'dart:typed_data'; | |
class MyList { | |
static const int _defaultCapacity = 8; | |
late Uint8List _data; | |
int _length = 0; |