Linked List Coding Interview Questions in Java | Cycle Detection | Find Middle node | Code Decode

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • In this video we have covered linked list coding interview questions which has been asked in Adobe, Amazon, Flipkart, GE, Hike and many more other companies .
    Udemy Course of Code Decode on Microservice k8s AWS CICD link:
    openinapp.co/u...
    Course Description Video :
    yt.openinapp.c...
    Linked List is a part of the Collection framework present in java.util package. This class is an implementation of the LinkedList data structure which is a linear data structure where the elements are not stored in contiguous locations and every element is a separate object with a data part and address part. The elements are linked using pointers and addresses. Each element is known as a node.
    The LinkedList stores its items in "containers." The list has a link to the first container and each container has a link to the next container in the list. To add an element to the list, the element is placed into a new container and that container is linked to one of the other containers in the list.
    Things to Remember about Linked List
    1) head points to the first node of the linked list
    2) next pointer of the last node is NULL, so if the next current node is NULL, we have reached the end of the linked list.
    Displaying the contents of a linked list is very simple. We keep moving the temp node to the next one and display its contents
    Insert at the End of linked list
    1_ Allocate memory for new node
    2) Store data
    3) Traverse to last node
    4) Change next of last node to recently created node
    they are linked with each other using pointers. Each element of the LinkedList has the reference(address/pointer) to the next element of the LinkedList.
    Each element in the LinkedList is called the Node. Each Node of the LinkedList contains two items: 1) Content of the element 2) Pointer/Address/Reference to the Next Node in the LinkedList.
    Given a singly linked list, find the middle of the linked list. For example, if the given linked list is 1-2-3-4-5 then the output should be 3.
    If there are even nodes, then there would be two middle nodes, we need to print the second middle element. For example, if given linked list is 11-2-3-4-5-6 then the output should be 4.
    Given a linked list, check if the linked list has loop or not.
    Most Asked Core Java Interview Questions and Answers : • Core Java frequently a...
    Advance Java Interview Questions and Answers : • Advance Java Interview...
    Java 8 Interview Questions and Answers : • Java 8 Interview Quest...
    Hibernate Interview Questions and Answers : • Hibernate Interview Qu...
    Spring Boot Interview Questions and Answers : • Advance Java Interview...
    Angular Playlist : • Angular Course Introdu...
    SQL Playlist : • SQL Interview Question...
    GIT : • GIT
    Subscriber and Follow Code Decode
    Subscriber Code Decode : www.youtube.co...
    LinkedIn : / codedecodeyoutube
    Instagram : / codedecode25
    #codedecode #linkedlist #middlenodeinlinkedlist

КОМЕНТАРІ • 58

  • @yogitamittal6967
    @yogitamittal6967 2 роки тому +5

    Hi . Great video . The same question was asked to me in L-1 round in Morgan Stanley . Please upload more videos on Linkedlist and arraylist Questions.

    • @CodeDecode
      @CodeDecode  2 роки тому

      Thanks Yogita. Sure we will upload them 👍🙂

    • @ramyal5371
      @ramyal5371 Рік тому

      Could you please let me know other coding questions which were asked in further rounds

  • @nidhimody7809
    @nidhimody7809 Рік тому +2

    This is the best video of LinkedList I have ever encountered. Have always struggled with LinkedList but this was phenomenal. Hats off to your explanation🎉

    • @CodeDecode
      @CodeDecode  Рік тому

      Thanks Nidhi. Keep learning keep shining girl ❤️🌟🌟

  • @akhtar-afreen
    @akhtar-afreen 2 роки тому +1

    Mam! I have been following your videos since a month and a half and I got placed recently as a Full Stack Developer. Many Many thanks to you😇

    • @CodeDecode
      @CodeDecode  2 роки тому +1

      Many congratulations Afreen. 🎉🎉🎊🎊well deserved 👏👏👏👏keep learning keep shining ⭐✨⭐✨

  • @akashsaha9366
    @akashsaha9366 2 роки тому +3

    Thanks maam. You are making me interview ready. The same question was asked me at oracle and adobe.

  • @pranjalsingh1099
    @pranjalsingh1099 2 роки тому +4

    These videos are helpful even for experience .Please also upload basic tree question asked in interviews

    • @CodeDecode
      @CodeDecode  2 роки тому

      Thanks Pranjal. Sure🙂👍

  • @santhoshPatels
    @santhoshPatels 2 роки тому +1

    These videos are really very helpful to crack interviews. Thank you

    • @CodeDecode
      @CodeDecode  2 роки тому +1

      Thanks Santhosh 🙂👍

  • @srisureshshetty
    @srisureshshetty 2 місяці тому

    Great work and Good video. Thanks for providing this kind of tutorial.👍

  • @anushavepuri4152
    @anushavepuri4152 Рік тому +1

    Hi
    Your vedios are very very useful for me to understand concepts and understand the concepts... Really great work.... Appreciate your effort

  • @nishantk6547
    @nishantk6547 2 роки тому +1

    Plz share more such videos
    Thank you for your efforts

  • @varunsiddarth1265
    @varunsiddarth1265 2 роки тому +2

    Eagerly waits for ur video. .🤗🤗

    • @CodeDecode
      @CodeDecode  2 роки тому

      Thanks varun

    • @varunsiddarth1265
      @varunsiddarth1265 2 роки тому +1

      In my new organization I'm started learning microservies so urs videos are helping me lot thanks..

    • @CodeDecode
      @CodeDecode  2 роки тому

      Thanks Varun. Glad to hear this. Is there any thing else you need in the playlist which we should cover

    • @varunsiddarth1265
      @varunsiddarth1265 2 роки тому

      @@CodeDecode defienetly I'll let you know.. right now previous videos helping me .to do things

  • @srivigneshcreations.9204
    @srivigneshcreations.9204 2 роки тому +1

    Tq so much madam love u so much ur vedeos are helping a lot tq a lot .

  • @sourabhjinde8191
    @sourabhjinde8191 2 роки тому +1

    Great 👍👍. Thank you mam. Please create few more videos on linked list like complete reversal, reversing two nodes at time, queues,etc.

    • @CodeDecode
      @CodeDecode  2 роки тому

      Nice topics Sourabh. Sure we will create a video on these 🙂👍

  • @nileshchandode6826
    @nileshchandode6826 Рік тому +1

    You explained very nicely and clearly but speed is high :)

    • @CodeDecode
      @CodeDecode  Рік тому

      Sure Nilesh. Wil try to reduce speed in upcoming videos 👍

  • @tulsininnikal5813
    @tulsininnikal5813 2 роки тому +1

    Thank you mam..thank you so much 👍👍👍👍👍

  • @swapnilmishra697
    @swapnilmishra697 2 роки тому +1

    Great explaination

  • @yatendra__singh
    @yatendra__singh 2 роки тому +1

    Mam please keep your speed little slow while teaching the concept.. because for the first time it is going over head for me.. otherwise concept wise it was excellent

  • @AshishYadav-se4db
    @AshishYadav-se4db 2 роки тому +1

    Great 👍👍. Thank you mam.

  • @neha6000
    @neha6000 2 роки тому +1

    Why only 199 like you deserve more than 1m like

  • @rexsam3134
    @rexsam3134 2 роки тому +1

    Long time didnt hear from you...

    • @CodeDecode
      @CodeDecode  2 роки тому

      Hey, we put video every week man. Please press bell icon so that we don't miss any new uploads 🙂👍

  • @nagendrababumarri7196
    @nagendrababumarri7196 2 роки тому +1

    Pls do few more videos on LinkedList...

  • @nidhichhabra2470
    @nidhichhabra2470 2 роки тому +1

    very helpful video . want you to cover more data structure questions like Btree

    • @CodeDecode
      @CodeDecode  2 роки тому

      Sure Nidhi. We will do that🙂👍

  • @MBilalabdulkany
    @MBilalabdulkany 2 роки тому +1

    Hi just one question, if there are 100 nodes, is this still valid? Since middle node should be 51 isn't it?

  • @ramyal5371
    @ramyal5371 Рік тому +1

    LinkedList allows duplicates so if two nodes having same data means its cyclic??

    • @CodeDecode
      @CodeDecode  Рік тому

      Hey Ramya. u r getting confused in pointer and data in nodes. These are 2 different things . Nodes have data and pointer. Here it says data is duplicate , pointer can point to next node with no cyclic dependency

    • @ramyal5371
      @ramyal5371 Рік тому +1

      For the same program I tried inserting same data as 1 in first node nd again 1 in second node.. Getting output as cycle detection at node 1

    • @CodeDecode
      @CodeDecode  Рік тому

      Can you check pointers Ramya. M sure you messed up with pointers

  • @nareshreddy7975
    @nareshreddy7975 2 роки тому +1

    in else condition in addNodes method
    instead of
    tail.next = new_Node;
    tail=tail.next;
    can we assign directly like this
    tail = new_node;

    • @CodeDecode
      @CodeDecode  2 роки тому +2

      No you can't Naresh. Because u have created a new node but it's yet not linked to any linklist. Hence first u have to add it to the linked list then only u can move tail to next. If u directly do this then u will loose your tail pointer. It will start pointing to anywhere in memory which is not linked to any node in linked list.

    • @nareshreddy7975
      @nareshreddy7975 2 роки тому

      @@CodeDecode Thank you for the reply.. You mean Node also have internal implementation i.e the tail pointer which will take the tail value which we are adding? Is Node a predefined class?

  • @vengateshm2122
    @vengateshm2122 2 роки тому +1

    Please start with graph problems

  • @sumant9189
    @sumant9189 Рік тому

    who is the other instructor mam?

  • @worldofwomen3726
    @worldofwomen3726 Рік тому +2

    Please go some slow u are telling very fast