80 Replies
How do you know there is a problem?
come on man
after all the other threads you just drop the entire program without explaining anything and expect someone to fix it?
looks like there is lore I don't know
significant lore
i think this has spanned 4 threads now
4-5 threads and 2+ weeks of time, probably around 10 helpers involved at this point... for binary search over strings and ints
Sorry for not mentioning my problem with the code
Th problem with the code is that it's not prompting to do the searching for searching Binary https://gist.github.com/Programmer-Faraj/062cfae47d7084660edb4ce546d502ed
Faraj#6089
Quoted by
<@!973964186956726313> from #I need help with Binary search alphabetically (click here)
React with ❌ to remove this embed.
You would probably need decent names of the variables und methods. Prefferably in English.
Sorry, it's written in Swedish. But I could translate to English too.
Let me try
It‘s a bit hard to read right know but i‘ll run it and see if i can make sence of it 🙂
On a first sight i think you need to think abou some more methods
There‘s a lot of code in that switch
Here is the English version, although the translation might not be very accurate, but you'll get the idea https://gist.github.com/Programmer-Faraj/53fb8998584150d4264d19a2cc9dda85
hmm it's not whole yet
Well! I know this project can be condensed to a less implementation, but the problem is not here, the problem is what I mentioned above.
Really
jup you're missing 300 lines 😄
OMG 😆
also i see you're using a list
Lists have they own sorting method
I know all that bro. But, I need to learn implementing the Binary search, Bobble sort both for numbers and strings.
Otherwise, I would've used the methods that you mentioned and save a ton of headache.
your sort algorhytm seems alright
upload the complete code in english and i'll probably understand where the problem is 🙂
Man, I tried to translate to English, but after some failures, I couldn't do it. It's sooo dame long 😆
The sort algo is correctly implemented, but I need to implement the checking if the list is sorted or not and this is where I got stuck.
Surely you just sort the list just before you need to use it?
But isn't Bubble sort's job to sort the list?
Can't you just use List<T>.Sort()?
Or is it part of the assignment to make bubble sort?
A part of assignment is to learn algorithms and how they work. They have giving me un-completed project for practicing the bubbl, binary leaner which's the above one and another one which I had to create it from the beginning which's this one and functions based on the requirements. https://gist.github.com/Programmer-Faraj/8963d73d17e16380e1ed108758e80270
Implementing their un-completed project was a bit tuff for me, since creating my own is much easier.
I learned that you apply bubble for sorting unsorted list and binary for searching the element, but I didn't know that you need to check if the list/array is sorted or not using a function.
Well that‘s easy use a boolean variable
You‘re using one for the loop. Same principle
Initialize with false at start and change it in your sorting method
Explain to me again what binary search means. I‘m getting confused cause i learn that stuff in german 😃
Aha! Ok! I'm not really familiar with the implementation that you mentioned. But I would like to see an example.
You mean using a while loop?
Oh! Really. So you're German citizen and I'm from Sweden btw.
Sure, I can do that.
You don’t even need a loop
Pass the array and the boolean to the other method and then simple if Statement
something like that for example
You could even mess around with out parameters if you wanted
Binary search is the fastest search as I learned from the tutorials. We use Binary search to search for a specific element either integers or strings or even char should be included too. The way Binary search works is like the following. Let's say we have a list/array first we compare if the element that we're searching for is in the middle. if it is in the middle then we hit the target. If not, then we split the list/array in half and we compare if the element that we're searching for is greater than the the middle, then we will throw the left side of the array and compare on the right and if it's not, if it's less than the elements on the right then we throw the right side and only compare on the left side until we narrow the list/array and it gets smaller and smaller until we find the element that we're searching for or hit the target.
ah ok i understand now
Ok! Well!That's very easy. But, I'm not sure if this will solve the problem.
Yeah! It's not that hard to understand it and the integer implementation is super easy, but I struggled for a week applying it to strings.
it should work the same
Since you would need to use these methods Compare(x, y) or StringComparer.OrdinalIgnoreCase.Compare() or CompareTo()
but be sure you apply ToLower or ToUpper when you search
Exactly, you mean case-sensitive or insensitive.
yep
You have an idea about it already
I learned it recently
well i did walked the same way you do now 🙂
Ok
This video explains it clearly
Daniel Simionescu
YouTube
Binary Search in C# (Beginner Tutorial)
Let's implement the Binary Search algorithm in C#
Code
https://danielsimionescu.com/csharp/arrays/binarysearch.html
GitHub
https://github.com/danielsimionescu/csharp-binarysearch
Codementor
Book a session with me here:
https://www.codementor.io/danielsimionescu1996
Gear
Laptop: Asus F550JK i7-4720HQ, 15.6 FHD, GTX 950M, 250GB SSD, 12GB RAM, ...
I heard that it's a requirement when doing interviews, but not sure if these algorithms are must.
well i should be able to write one but you'll mostly use the ones built in the classes
they're vastly more efficient
About - Project Euler
A website dedicated to the fascinating world of mathematics and programming
check this out
it's a nice practice for algorhythms
some problems can be brute forced
but others will take your programs hours to solve them with brute force
it's a nice practice
You're right. The .NET is updating every year and you have some really good and easy LINQ where you can implement all these algorithms in less and readable code, why the hell go through all this mess 🤷🏻♂️
Really! I'll check this link and review the content.
Aha! Recently, I was recommended of one of the members about practicing by using this link. Thanks for recommending it.
well those are the basics and you need to understand them in order to use them correctly
Which ones?
i meant such sort and search algorhytms
and they will not always work as they are
if you are comparing object you need to set your own rules about the sorting
but that's implementing of interfaces so you still have a bit to learn till you get to that part
Ok! Yeah! It's always good to learn them when you need to implement them in a various projects.
that's the point you will need to do it in more complex projects 🙂
Ok! Really. You mean rules like cultural, ordinal case-sensitive and etc..?
Oh god, not another level of complication
What do you mean by interfaces?
You're reading my mind lol no complex stuff
it could be pretty wide range of varieties depends on the project you'er not there yet 🙂 don't worry about it just yet 🙂
Aha! Ok! I get your point. I haven't touch any advanced stuff yet.
not so easy to be explained until you got your hands on OOP
but it'll come in good time 🙂
Ok
I have some knowledge about OOP and I know that you can use interface methods type
sometimes you must in order that you program works
Ok
interfaces help for the communication between classes
Yeah
it has basicaly only method signatures
and what exactly the method does it's up to your implementation
Ok! I get what you mean. I haven't used it, but I will in the future.
Man you have some good knowledge, you don't seem a beginner like me
Believe me i am 😅
I‘m strugling with a simple Snake game at the moment
Really, you're not alone. I'm the same bro. How long have you been learning the c# fundamentals?
well i started last summer myself
but the actual course with a tutor started arround october
sooo little over 6 months now
Oh! Me too man 😆 it's been a year for me only in the fundamentals and people criticize me so often for spending a year.
everybody needs their own time
You've got be kidding with me 😄 I started my course with a local school online on October too 😆 that's very funny.
so ignore those comments
i am not overly happy with my progress as well but i've sen worse 😄
starting an internship next month
that's where the magic is suposed to happen
but i need to learn PHP and Typo3 for it
and i really don't have the time cause of the school project 😄
I know, I don't pay attention on what they say, everyone is different in learning and this is a new skill and we all agree that it will take time, unless you're a genius like Elon Musk or Bill Gates.
It's hard skill and many people give up
Yeah! Many people struggle as so called thought learner.
Well, that's a good progress starting internship, isn't that where you work for free just for learning sake?
Why do you need to learn those languages?
I know man, it's been a week since my deadline has ended for my another current course and I barely can submit it my assignments now.
yep
cause they are working with those
Aha! So they're demanding you to learn these languages to use them at your position!
I would really like to do an internship with the c# just to test the software developing environment and see how things work in a career level.
couldn't get such i would've liked that too
but there was actualy only one company in the area who worked with c# and i didn't get it there
Oh! Really.
Maybe you should try like LinkedIn or other sites might help you to find for c#
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.