Linear Search Array C# 2022 (Step-By-Step Breakdown)

  Рет қаралды 12,534

Teddy Smith

Teddy Smith

Күн бұрын

Пікірлер: 6
@giantpandaman
@giantpandaman Жыл бұрын
For your LinearSearch function did you consider making the return type a nullable int? Then you return the position of where the item was found and if not found it returns null.
@chadgregory9037
@chadgregory9037 2 жыл бұрын
would people in production prefer a for loop like you show in the video, or how would people feel about this? LinearSearch(array, key) { int i = 0: while (i < array.Length) { array[i] == key ? return true : i++; } return false; }
@TeddySmithDev
@TeddySmithDev 2 жыл бұрын
That’s fancy. I would be impressed because I think most lean toward for loops.
@CRBarchager
@CRBarchager 2 жыл бұрын
@@TeddySmithDev for-loop I if needed to something with the index or just run through the whole thing with a foreach instead. Under the covers it's all converted to a while loop.
@g_man9662
@g_man9662 Жыл бұрын
This actually won't compile. a ternary operator is trying to return some sort of value. This is kinda like trying to put a return on the right side of an = sign.
@Fork0
@Fork0 Жыл бұрын
I think using a while loop for this exact situation is just plain bad. A for loop in this specific situation has everything you need and does everything automatically. A while loop forces you to be very careful with the incrementation. If you suddenly need to add a "continue" somewhere, you have to make sure you're adding the "i++" or your loop will be bugged. There's a time and place for "while" loops and sometimes you need to handle multiple varibles and their increments/decrements, but honestly in this example, I'd always use a for loop.
Binary Search Array 2022 (Step-By-Step Breakdown)
17:18
Teddy Smith
Рет қаралды 6 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
小丑女COCO的审判。#天使 #小丑 #超人不会飞
00:53
超人不会飞
Рет қаралды 16 МЛН
The Dictionary Data Structure in C# in 10 Minutes or Less
10:20
IAmTimCorey
Рет қаралды 43 М.
Learn Binary Search in 10 minutes 🪓
10:04
Bro Code
Рет қаралды 135 М.
Intro To Linked-List in C# 2022 (Step-By-Step Breakdown)
34:30
Teddy Smith
Рет қаралды 20 М.
How to Do a Binary Search in C# (Simple)
4:21
Max O'Didily
Рет қаралды 4,2 М.
Bubble Sort Explained Simply (Step-By-Step)
19:47
Teddy Smith
Рет қаралды 3,9 М.
Data Structures and Algorithms In C#: Big-O Notation
14:54
Teddy Smith
Рет қаралды 28 М.
7 C# Tips and Tricks to impress your .NET Developer friends
7:48
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 577 М.
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН