Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
From where does it derive its meaning:
1) Topography, as in region, geography etc.
OR
2) From one of its mathematical meanings: the set of all open subsets of a topological space(http://www.merriam-webster.com/dictionary/topology)
Thanks,
Chris.
P.S: Please do not mention the meaning related to computer science from the dictionary as that is what I am trying to figure out here.
Probably first use of term "Topological sorting" is from Kahn, Arthur B. (1962), "Topological sorting of large networks". Term "Topological sorting" derives from "topological ordering", which is defined in this article:
A list in topological order has a special property. Simply expressed:
proceeding from element to element along any path in the network, one
passes through the list in one direction only
So it would be "topological" in mathematical meaning, but not strictly the one you mentioned. It would be "topological" rather in the sense of Topological Graph Theory
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 months ago.
Improve this question
I was given an algorithm as below and my aim is to prove its incorrectness. The thing is that it woud be too obvious to use just counter-example, that is why I was looking for a more formal approach. I have thought the proof by induction, but in the past I had use it only to prove the correctness of an algorithm and I can't really figure out the opposite way.
GoodSort(A, left, right)
{
if (A[left] > A[right])
swap(A[left], A[right]);
if (left+1 >= right)
return;
pivot = floor((right-left+1)/3);
GoodSort(A, left, right-pivot);
GoodSort(A, left+pivot, right);
}
For any purpose but a class assignment where it's forbidden, a proof by counterexample, e.g. [3,2,4,0,1,4], would be ideal. As some commenters said, clarity and simplicity is desirable.
Assuming this is a class assignment and you need to categorize the set of inputs (or a set of inputs) where this will fail that's broader than a single counterexample, take some minimal input that fails, and analyze why it fails, then generalize that.
An algorithm can either be correct or incorrect, if you are having a hard time finding ways to prove its incorrectness you can rather try to prove its correctness. If you reach a nonsense you can then conclude that the algorithm is incorrect. This method is called Reductio ad Absurdum
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
Given a machine that can compute the kth smallest item of an Array A in 𝑂(√𝑛) time. Find a recursive function that can sort A in linear time corresponding to n which is the length of A.
First I tried to optimize some of the sorting algorithms I knew using this new property but the best I could do was O(n^3/2) and currently I'm wondering whether if it is possible or not.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
Often, I come across the following terminology in coding interviews.
Given an array or string, find the
sub-array
sub-sequence
sub-string
What difference they have?
For example, I see an integer array can be split into
n*(n+1)/2
sub arrays. Do they become subsets as well? Should sub-arrays are contiguous?
For calculating the sub-sequences of a string, why to use
2^str_length - 1
After searching online, I ended up with this link
https://www.geeksforgeeks.org/subarraysubstring-vs-subsequence-and-programs-to-generate-them/
But I still feel ambiguous as what is the universal term for calling a part of an array/string? and how to compute them?
In general, arrays and strings are both sub-sequences. The "sequence" part indicates that the order of elements is important somehow. "substring" is usually contiguous; "sub-array" and "sub-sequence" are unclear. If you're in a job interview and not certain of the interpretation, your first job is to ask. Sometimes, part of the job interview is making sure you can spot and resolve ambiguities.
UPDATE after question update
I find the referenced page quite clear.
First, note that string and array are both specific types of a sequence.
subsequence is the generic term: elements of the original sequence
appearing in the same order as in the original, but not necessarily contiguous. For instance, given the sequence "abcdefg", we have sub-sequences "a", "ag", bce", etc.
Elements repeated or otherwise not in the original ordering would include "ga", "bb", bcfe", etc. None of these is a sub-sequence.
"Subset" is a separate type. In a set, repeated elements do not exist, and ordering does not matter.
Does that clear up your problems?
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Given a Binary Tree, write a function to check whether the given Binary Tree is Complete Binary Tree or not.
A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. source: wikipedia
My approach is do BFS using queue and count the no of nodes. Run a
loop till the queue is not null but break once you find one of the
below condition holds good:
left node is not present for a node
left node is present but right node is not present.
Now we can compare the count that we get from the above approach and
the original count of the nodes in the tree. If both equal then
complete binary tree else not.
Please tell me whether the approach is correct or not. Thanks.
This question is same as that of this. But i wan to verify my method here.
Edit:
The algorithm is verified by #Boris Strandjev below. I felt this is the easiest algorithm to implement out of some algorithms available in net. Sincere apologize if you do not agree with my assertion.
Your algorithm should solve the problem.
What you are doing with the BFS is entirely equivalent to drawing the tree and then tracing the nodes with your finger top-down and left-right. The first time you can not continue you stop tracing with your finger. If you have not counted all the nodes then the structure is not as expected obviously.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I'm not sure if this is a stupid question but I couldn't really find anything on Google. Given a few data points for a function f(x) would it be possible to bruteforce what the function f(x) itself might be?
This will rely on some prior knowledge of f(x).
If you know that the function is constant, one point is enough; a line, then two points, etc. for polynomial functions.
But if you have no restrictions, this isn't possible. Assuming function here means something like a real-valued function on the real numbers, there are (uncountably) infinitely many functions which will take the specified values on any finite set of data points.
This is mostly math question. It depends on number of data points that are available. You are basically fitting data to a function. You need two data points for straight line, etc. The commercial solution is TableCurve 2D, http://en.wikipedia.org/wiki/TableCurve_2D. I would search for nonlinear fit on Google.
Fitting algorithms are also described in Numerical Recipes (http://en.wikipedia.org/wiki/Numerical_Recipes). The simplest algorithm would look for deviations between assumed function and data points. If you assume certain error on your data points, you can calculate chi-square and goodness of your fit.