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
void main() { | |
final myList = [2,5,8,10,13,16,17,18,20,24,26,29,33,37,41,44,50,55]; | |
print('Original list: $myList'); | |
int target = 20; | |
int foundIndex = binarySearch(myList, target); | |
if (foundIndex == -1) { | |
print('Number $target not found!'); | |
} else { |
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 main() { | |
final myList = [8, 9, 3, 5, 1, 3]; | |
print("Unsorted: $myList"); | |
bubbleSort(myList); | |
print("Sorted: $myList"); | |
} |
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
import 'dart:typed_data'; | |
void main() { | |
final myList = MyList(); | |
print(myList.length); // 0 | |
myList.add(10); | |
myList.add(420); | |
myList.add(9000); | |
print(myList); // [10, 420, 9000] |
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
import 'dart:typed_data'; | |
void main() { | |
final myList = MyList(); | |
print(myList.length); // output: 0 | |
myList.add(10); | |
myList.add(5); | |
myList.add(3); | |
print(myList.length); // output: 3 |
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
import 'dart:typed_data'; | |
void main() { | |
final myList = MyList(); | |
print(myList.length); | |
myList.add(10); | |
print(myList.length); | |
print(myList); | |
} |