Please Login To Continue

Method 2 Linked List (make visited nodes)

Lesson 4 of 10 • 0 upvotes • 5:47mins

Avatar

Rakesh Naga Chinta

Method 2 linked list How to detect loop using Floyd's cycle detection algorithm This solution requires modifications to basic linked list data structure. Have a visited flag with each node. Traverse the first linked list and keep marking visited nodes. Now traverse second linked list, If you see a visited node again then there is an intersection point, return the intersecting node. This solution works in O(m+n) but requires additional information with each node. A variation of this solution that doesn’t require modification to basic data structure can be implemented using hash. Traverse the first linked list and store the addresses of visited nodes in a hash. Now traverse the second linked list and if you see an address that already exists in hash then return the intersecting node.

Continue on app
1

Top 10 Algorithms in Interview Questions: Introduction

6:31mins

2

Dynamic Programming Floyd Warshall Algorithm

10:19mins

3

Depth First Search or DFS for a Graph

5:47mins

4

Method 2 Linked List (make visited nodes)

5:47mins

5

Breadth First Search or BFS for a Graph

9:27mins

6

Boggle (Find all possible words in a Board of Characters)

8:21mins

7

Kruskal's Minimum Spanning Tree Algorithm

5:53mins

8

Given a singly Linked List and a position, delete a Linked List node at the given position

7:45mins

9

Disjoint set or (union - find) Algorithm of a Graph

10:07mins

10

Finding Bridges in a graph intro to the Algorithm

11:39mins

Crack Campus Placements with Unacademy

Get subscription and access unlimited live and recorded courses from India's best educators
Structured syllabus
Structured syllabus
Daily live classes
Daily live classes
Ask doubts
Ask doubts
Tests & practice
Tests & practice

Similar Plus Courses

thumbnail
ENROLL
EnglishCurrent Affairs

UCAN - Science and Technology July Monthly Current Affairs

Himabindu

Unacademy is India’s largest online learning platform. Download our apps to start learning


Starting your preparation?

Call us and we will answer all your questions about learning on Unacademy

Call +91 8585858585
Company
About usShikshodayaCareersBlogsPrivacy PolicyTerms and Conditions
Products
Learner appLearner appEducator appEducator appParent appParent app