Linear Search Algorithm in Data Structures | C++ Program to Implement Linear Search Algorithm

In computer science, a linear search or sequential search is a method for finding an element within a list. It sequentially checks each element of the list until a match is found or the whole list has been searched.
A simple approach is to do linear search, i.e
1. Start from the leftmost element of arr[] and one by one compare x with each element of arr[]
2. If x matches with an element, return the index.
3. If x doesn’t match with any of elements, return -1.
We will be implementing linear search program in C++ Programming Language.
---------------------------------------------------------------------------------------------
Full DSA playlist - • Introduction to Data S...
Full Code & Theory article - simplesnippets.tech/linear-se...
C++ Programming Tutorials for Beginners Course - • Introduction to Comput...
---------------------------------------------------------------------------------------------
Support Simple Snippets by Donations -
Google Pay UPI ID - tanmaysakpal11@okicici
PayPal - paypal.me/tanmaysakpal11
---------------------------------------------------------------------------------------------
Simple Snippets Official Website -
simplesnippets.tech/
Simple Snippets on Facebook -
/ simplesnippets
Simple Snippets on Instagram -
/ simplesnippets
Simple Snippets on Twitter -
/ simplesnippet
Simple Snippets Google Plus Page -
plus.google.com/+SimpleSnippets
Simple Snippets email ID -
simplesnippetsinfo@gmail.com
For More Technology News, Latest Updates and Blog articles visit our Official Website - simplesnippets.tech/
#linearsearch #searchingalgorithms #datastructures #sequentialsearch #algorithms

Пікірлер: 63

  • @SimpleSnippets
    @SimpleSnippets4 жыл бұрын

    Hey Guys, if you want more such tech educational videos on this channel then please support me by subscribing to this channel & also share it with your friends as it helps me create more content just for you ✌

  • @charugupta207
    @charugupta2074 жыл бұрын

    Why this video have so less likes?? It was the best explanation for linear search so far! keep going bro, because of you I understood this concept quite well. Looking forward for your upcoming videos.

  • @SimpleSnippets

    @SimpleSnippets

    4 жыл бұрын

    Thank you so much bro 😁 and yes buddy I'll be making many more videos. In the mean time check out full DSA playlist you'll find many more videos ✌️ And on our channel we have 400+ videos currently 😁

  • @user-z9oay
    @user-z9oay6 ай бұрын

    Thanks. you help me to study for my final exam. pray for meto pass it.

  • @mohammednassf1741
    @mohammednassf1741 Жыл бұрын

    I am an Egyptian student. Your explanation is very nice. Thank you for providing this information

  • @Lalinxdboom
    @Lalinxdboom Жыл бұрын

    best channel for DSA with art explanation

  • @bikramchettri9405
    @bikramchettri94053 жыл бұрын

    Happy that someone recommended this channel in comment box. Very helpful.

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    That's amazing. Thanks to that person who recommended as well 😊🙏

  • @vaibhavchafle2678
    @vaibhavchafle26783 жыл бұрын

    Excellent teaching , I always follow your videos , looking forward for your upcoming videos.

  • @jayeshyedge7171
    @jayeshyedge71715 жыл бұрын

    Yet I didn't gone through this video. But then also I complimented because your videos ,as expected are excellent.

  • @SimpleSnippets

    @SimpleSnippets

    5 жыл бұрын

    Thank you 😇

  • @Shailswap14
    @Shailswap144 жыл бұрын

    Your explaination is crystal clear and to point. I understood the concept very well. I request to make a video on fibonacci search too.

  • @SimpleSnippets

    @SimpleSnippets

    4 жыл бұрын

    Thank you so much Swapnil for such wonderful feedback. And guess what, you are in luck, I already have covered tutorial of fibonacci series & many more topics in my C++ tutorials course, Here is the link - kzread.info/dash/bejne/c3-Cqcl6iLfHos4.html

  • @shamaleejayakodi409
    @shamaleejayakodi409 Жыл бұрын

    This was very helpful for me, Thank you so much ☺️

  • @sudheerm.s6792
    @sudheerm.s67925 жыл бұрын

    bro, thanks for the upload. lesson missed a lot , wil be back .keep it up , we are following you

  • @jayeshyedge7171
    @jayeshyedge71715 жыл бұрын

    Really a very good video. Thanks a lot!!

  • @SimpleSnippets

    @SimpleSnippets

    5 жыл бұрын

    Thank you so much Jayesh for your positive feedback 😇 Please do share the video with your friends too ✌

  • @manikanth.8507
    @manikanth.85073 жыл бұрын

    Why are you not using break statement in if(....) Loop when we got our condition!!

  • @yashsonawane905
    @yashsonawane9052 жыл бұрын

    I was about to comment add break once found element and see you have already shown that :) One more suggestion is that you could have used flag = 0 (initial) and then once found set flag = 1 and break out of the loop. So that explanation of your temp variable could be easier. I have one doubt regarding all searching algorithms though...What if we have duplicates?

  • @umerkhan8297
    @umerkhan82973 жыл бұрын

    You didn't explain why temp is there?

  • @laxmannenavath6623
    @laxmannenavath66234 жыл бұрын

    way of explanation is good

  • @SimpleSnippets

    @SimpleSnippets

    4 жыл бұрын

    Thank you very much. Please do share the videos with your friends too 😇

  • @rohitpandey2386
    @rohitpandey23863 жыл бұрын

    sir this program is not run in the code block properly plz suggest me sir

  • @RealRaze1
    @RealRaze13 жыл бұрын

    what is linear soart ....iam confuse.. give ans and what is difference in seqvential and selection soart

  • @MANISHSHARMA-xk1su
    @MANISHSHARMA-xk1su5 жыл бұрын

    Great...

  • @SimpleSnippets

    @SimpleSnippets

    5 жыл бұрын

    Thanks bro 🤟

  • @mhassankhan8677
    @mhassankhan86773 жыл бұрын

    nice video! what if there are multiple occurrences of a number?

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    I suppose then you have to iterate through the entire list from start to end. ✌ Generally searching operations are performed on unique entities only

  • @azharmohammedpillais8142
    @azharmohammedpillais81424 жыл бұрын

    AMAZING!!!!11

  • @SimpleSnippets

    @SimpleSnippets

    4 жыл бұрын

    Thank you so much for such wonderful comment & feedback buddy. Very happy to hear this from you. Please do share the videos with your friends too. Thats the biggest help & support 😇

  • @hareshparab7808
    @hareshparab78082 жыл бұрын

    thanku bro

  • @SimpleSnippets

    @SimpleSnippets

    2 жыл бұрын

    Welcome bro 🤘😊

  • @ThatLLMGuy
    @ThatLLMGuy5 жыл бұрын

    Doesnt Linear Search have complexity O(n) ? What is the time complexity for the dividing array search?

  • @SimpleSnippets

    @SimpleSnippets

    5 жыл бұрын

    Yes the complexity is O(n). ✌️ I'll discuss in detail about this after we cover searching and sorting algorithms 🤟

  • @saniyamansuri9607
    @saniyamansuri96072 жыл бұрын

    Will it be okay to start this topic before linked list ?. Becouz as a beginner I am finding linked list hard.

  • @SimpleSnippets

    @SimpleSnippets

    2 жыл бұрын

    Yes you can start this topic before linked list. Check the full playlist for the appropriate order.

  • @saniyamansuri9607

    @saniyamansuri9607

    2 жыл бұрын

    @@SimpleSnippets thank you sir ,😄

  • @adiflorense1477
    @adiflorense14773 жыл бұрын

    12:53 Sir, what's the difference between break and temp = 0? is it the same, right?

  • @ranjeet5806

    @ranjeet5806

    3 жыл бұрын

    clear the basics first man. watch his basics c++ video

  • @agirl2564

    @agirl2564

    Жыл бұрын

    @@ranjeet5806 dont be rude

  • @emmanuelakpaklikwasi4300
    @emmanuelakpaklikwasi43002 ай бұрын

    Pls can i know why temp = -1

  • @adiflorense1477
    @adiflorense14773 жыл бұрын

    9:12 Sir, why you initialize temp = -1?

  • @ranjeet5806

    @ranjeet5806

    3 жыл бұрын

    did you waited for the end of the video or just typed this the next moment he initialised it?

  • @agirl2564

    @agirl2564

    Жыл бұрын

    @@ranjeet5806 bro shut up

  • @mahmad8767
    @mahmad87674 жыл бұрын

  • @mallipallianusha7020
    @mallipallianusha70203 жыл бұрын

    Why didn't u use else condition to print "Number is not found "?

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    Well you can always add that.

  • @mallipallianusha7020

    @mallipallianusha7020

    3 жыл бұрын

    Tq... n your videos are really helpful

  • @onlytopwatch4516
    @onlytopwatch45163 жыл бұрын

    is this algorithm is correct from exam point of view ?

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    This algorithm is correct from every POV

  • @mallipallianusha7020
    @mallipallianusha70203 жыл бұрын

    Bro , can u plz do a video of DP!

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    i will ✌

  • @suppirocky
    @suppirocky3 жыл бұрын

    Why wont you explain in C language.Most of the beginners know about C right?...But explaination was good thank you

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    Cause I primarily started off with C++ only. Since majority of concepts in C are included in C++ with added OOPs I thought C++ would be the better route. What do you think ?

  • @suppirocky

    @suppirocky

    3 жыл бұрын

    @@SimpleSnippets Yeah, that's good. But, The C++ Prograning is not covered in our academics yet. Thank you...

  • @zainabbohra2915

    @zainabbohra2915

    3 жыл бұрын

    @@SimpleSnippets bro thankyou so much covering in c++

  • @Zulu369
    @Zulu3693 жыл бұрын

    Terrible Indian accent. Barely understand what he is saying...

  • @SimpleSnippets

    @SimpleSnippets

    3 жыл бұрын

    Unfortunately that's not gonna change anytime soon. I'd suggest you check some other channel for similar topics ✌️😊

  • @pedro_642

    @pedro_642

    Жыл бұрын

    @@SimpleSnippets Hey do not worry, the accent is not bad at all. Thanks for the video my friend!

  • @jayeshnikumbh5983
    @jayeshnikumbh59836 ай бұрын

    best work man! teching code so simply that everyone can understand . thanks a lot bro @simplesnippets

  • @SimpleSnippets

    @SimpleSnippets

    5 ай бұрын

    Glad you liked it

  • @israrqayyum7
    @israrqayyum76 ай бұрын

Келесі