Skip to content

Instantly share code, notes, and snippets.

@1onest4r
1onest4r / test.dart
Created September 24, 2025 13:36
sep_24_HW
class Node {
Node(this.value, {this.next});
int value;
Node? next;
@override
String toString() {
final result = StringBuffer();
result.write(value);
@1onest4r
1onest4r / binary_search.dart
Created September 20, 2025 10:50
sep_20 HW
void main() {
// final myList = [1, 2, 4, 5, 5, 6, 7, 8, 9, 10];
final myList = [1, 1, 1, 2, 2, 2, 3, 3, 4, 5];
final searchItem = 4;
final index = binarySearch(myList, searchItem);
if (index == null) {
print('not found');
} else {
print("found searchitem at index $index");
@1onest4r
1onest4r / insertion_sort.dart
Created September 16, 2025 02:44
HW for sep_16 online lesson
void main() {
print("Original:");
final myList = [6, 9, 4, 1, 8, 5, 4, 3];
print(myList);
insertionSort(myList);
print("Sorted:");
print(myList);
}
@1onest4r
1onest4r / test.dart
Last active September 12, 2025 03:19
finished it faster than i expected
void main() {
final mylist = [6, 5, 4, 3, 2, 1];
bubbleSort(mylist);
//expecting [1, 2, 3, 4, 5, 6]
print(mylist);
}
void bubbleSort(List<int> mylist) {
for (int j = 0; j < mylist.length -1; j++) {
@1onest4r
1onest4r / test.dart
Created September 11, 2025 02:47
home work for sep 9th increased byte size test
import 'dart:typed_data';
void main() {
final myList = MyList();
// Test with small numbers (1 byte)
print("Testing small numbers (1 byte each):");
myList.add(10);
myList.add(255);
print("List: $myList");
@1onest4r
1onest4r / sep_4_HW .dart
Created September 6, 2025 13:11
added a few functions, plus operator
import 'dart:typed_data';
void main() {
final myList = MyList();
print(myList.length);
myList.add(10);
myList.add(1);
print(myList.length);
print(myList);
@1onest4r
1onest4r / List_example
Created September 3, 2025 10:29
Example of adding an item to list
import 'dart:typed_data';
void main() {
final myList = MyList();
print(myList.length);
myList.add(10);
print(myList.length);
print(myList);
@1onest4r
1onest4r / Time_complexity
Created September 1, 2025 13:38
Time complexity models.
/*
1. Constant time complexity.
2. Linear time complexity.
3. Quadratic time complexity.
4. Logarithmic time complexity.
*/
import 'dart:math';
void main() {