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
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.
Thanks Yogita. Sure we will upload them 👍🙂
Could you please let me know other coding questions which were asked in further rounds
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🎉
Thanks Nidhi. Keep learning keep shining girl ❤️🌟🌟
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😇
Many congratulations Afreen. 🎉🎉🎊🎊well deserved 👏👏👏👏keep learning keep shining ⭐✨⭐✨
Thanks maam. You are making me interview ready. The same question was asked me at oracle and adobe.
Thanks Akash 🙂👍
These videos are helpful even for experience .Please also upload basic tree question asked in interviews
Thanks Pranjal. Sure🙂👍
These videos are really very helpful to crack interviews. Thank you
Thanks Santhosh 🙂👍
Great work and Good video. Thanks for providing this kind of tutorial.👍
Hi
Your vedios are very very useful for me to understand concepts and understand the concepts... Really great work.... Appreciate your effort
Thanks 😊👍👍
Plz share more such videos
Thank you for your efforts
Sure Nishant 🙂👍
Eagerly waits for ur video. .🤗🤗
Thanks varun
In my new organization I'm started learning microservies so urs videos are helping me lot thanks..
Thanks Varun. Glad to hear this. Is there any thing else you need in the playlist which we should cover
@@CodeDecode defienetly I'll let you know.. right now previous videos helping me .to do things
Tq so much madam love u so much ur vedeos are helping a lot tq a lot .
Thanks Vignesh 🙂👍
Great 👍👍. Thank you mam. Please create few more videos on linked list like complete reversal, reversing two nodes at time, queues,etc.
Nice topics Sourabh. Sure we will create a video on these 🙂👍
You explained very nicely and clearly but speed is high :)
Sure Nilesh. Wil try to reduce speed in upcoming videos 👍
Thank you mam..thank you so much 👍👍👍👍👍
you're welcome tulsi
Great explaination
Thanks swapnil
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
Sure Yatin
Great 👍👍. Thank you mam.
🙂🙂👍👍
Why only 199 like you deserve more than 1m like
Thanks Neha🙂
Long time didnt hear from you...
Hey, we put video every week man. Please press bell icon so that we don't miss any new uploads 🙂👍
Pls do few more videos on LinkedList...
Sure Nagendra 🙂👍
very helpful video . want you to cover more data structure questions like Btree
Sure Nidhi. We will do that🙂👍
Hi just one question, if there are 100 nodes, is this still valid? Since middle node should be 51 isn't it?
LinkedList allows duplicates so if two nodes having same data means its cyclic??
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
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
Can you check pointers Ramya. M sure you messed up with pointers
in else condition in addNodes method
instead of
tail.next = new_Node;
tail=tail.next;
can we assign directly like this
tail = new_node;
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.
@@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?
Please start with graph problems
Sure 👍🙂
who is the other instructor mam?
Please go some slow u are telling very fast
Sure gayathri 🙂👍