Questions tagged [cycle-detection]

42 questions
0
votes
0 answers

How to to check the cycles count in time series data using Python

I have a battery voltage data with respect to Datetime, collected data for one month I need to find out the number of cycles of battery hers is my data…
0
votes
1 answer

In course schedule II : Leetcode, how can we ensure when there are multiple answers the solution is the one with increasing order of course number?

When there are multiple solutions, I want to return the solution where courses are in ascending order. How can I do that by the topological sort algorithm?
0
votes
2 answers

Count number of cycles in a Directed graph

Question: Write a program which gives us the number of cycles in a Directed graph. Approach 1: I know that we can detect cycles in graph using Depth First Search and return the answer in terms of a simple boolean value. I have written a code for…
KSP
  • 94
  • 1
  • 11
0
votes
1 answer

Why aren't cyclic lists considered lists in Scheme?

I haven't found any questions regarding this for the Scheme programming language, so I hope this isn't a duplicate. While doing some dabbling in the interpreter I encountered a peculiar occurrence: (define li (list 'a 'b 'c 'd 'e)) (list? li) ;; ->…
Snusifer
  • 485
  • 3
  • 17
0
votes
1 answer

Different approach to detecting cycle/loop in a linked list

So I know about Floyd's cycle detection algorithm but while going over the problem I came up with another idea to solve it. If we can store the 'nextpointer' of every node in a vector/list while we traverse the linked list and the count if the…
0
votes
2 answers

Cycle detection in Linked List using address of nodes

I have learned recently that: (typically)heap in memory always grows upward refer to-> https://unix.stackexchange.com/questions/466443/do-memory-mapping-segment-and-heap-grow-until-they-meet-each-other I didn't understand most of it but when I…
0
votes
1 answer

Writing a function to detect a cycle in a linked list (Floyd's alg)... Logic looks correct but can't find the bug

I am trying to detect a cycle in a linked list I created (I'm practicing for interviews questions). I understand the logic involved in Floyd's tortoise-hare algorithm but the function is always returning false... Here's my linked list: class…
0
votes
1 answer

Find all vertices in a cycle in a directed graph

I have a directed graph i.e matrix of order n x n. I need to find all the cycles present in it along with the vertices involved in the cycle. Here is an example: A B C D 0 1 1 1 1 0 1 0 1 0 0 0 1 0 0 0 The output should…
user3035457
  • 23
  • 1
  • 4
0
votes
1 answer

ArrayList of ArrayList (for Cycle Detection)

Well this question is more about an efficient algorithm than the implementation, so I won't post code. (won't really help you to understand the question) To introduce you to the question: I'm developing a program to calculate automovilistics crash…
0
votes
2 answers

Find circular replacement patterns

Suppose I would like to expand a string by replacing placeholders from a dictionary. The replacement strings can also contain placeholders: $pattern = "#a# #b#"; $dict = array("a" => "foo", "b" => "bar #c#", "c" => "baz"); while($match_count =…
chiborg
  • 26,978
  • 14
  • 97
  • 115
-1
votes
1 answer

My program stop itself in a part of code. How to fix it?

I am doing a program that verifies a cycle in a tree. It's fine with small data, but when data increasing, it stops. Help me, please. Cromosoma *kruskalModificado(Gen *setGenes, int numGenes, int numVertices, Cromosoma *cromosoma){ int…
-3
votes
2 answers

Can we assign address of two nodes as a next of a one LinkedListNode in C#?

I am solving one program from linked list data structure in c#, where I need to check that given linked list is NULL terminated or ends with cycle. I want to check it with different test cases, but not able to pass cyclic linked list as an…
Prasad Telkikar
  • 15,207
  • 5
  • 21
  • 44
1 2
3