What is the name of this graph algorithm?
I need to apply the following algorithm in one of my projects. I know what it does algorithmwise, but I can't seem to find an application for this. Is there a name for this algorithm?
Pseudocode:
input: G = (V, E): planar graph (Vertices, Edges)
output: W: a subset of V
function someFunc(G)
if V.length == 0 then
return []; // array
else
v = some vertex of V;
N = []; // array
// for every edge
for (a, b) in E or (b, a) in E) do
// if the edge connects to the vertex,
// add the other vertex end to the Narray
if a == v then
N.push(b);
end
end
// \notation means: left hand set minus the values in the right hand set (setdifference)
// e.g. [1, 2, 3] \ [2, 3, 4] = [1]
W1 = [v].union(someFunc(inducedSubgraph(V \ [v])));
W2 = N.union(someFunc(inducedSubgraph(V \ [v] \ N)));
return W1.length < W2.length ? W1 : W2;
end
end function
The inducedSubgraph function is an external function which removes the given vertices (+ adjacent edges) from the graph.
See also questions close to this topic

What must be true in order to sort objects?
So my title is my question... What is the basic requirement or what must be true in order to sort objects? Here are some of the choices:
A. They must be wrapper classes of primitives (Integer, Double, etc.)
B. They must be Comparable.
C. At least one instance variable must be a primitive.
D. They must be Strings
E. Objects are not sortable, only primitives are sortable.

How do I calculate finishing times for an iterative implementation of DFS?
I'm trying to do one of the assignments in the Stanford Algorithm MOOC. I need to find SCCs with Kosaraju's algorithm. I already have a working recursive solution, not too difficult. But using it on a large graph, python gives a max recursion depth error. I'll probably need to use a iterative implementation of DFS, but I have no idea how to actually get the finishing times with an iterative DFS. Any help would be appreciated!

Knight Dialer Dynamic Programming implementation
I am solving one question asked in the leetcode but not getting the idea how to do this with Recursion and Dynamic Programming , can anyone explain and give the proper way how to approach this question .If you help me with some code implementation , it would help me out . Thanks for your time .
What i got the idea is that : get the neighbours of each dialer number ,when knight rider jumps.
Suppose if we are 0 position then , i can jump to 6 and 8. if knight is at 1 then he can take jump on 7 and 9 and so , i can write like this
1: (6,8) 2: (7,9) 3: (4,8) 4: (3,9) 5: () // can't jump any where 6: (1,7) 7:(2,6) 8:(1,3) 9: (2,4) 0: (4,6)
The link is https://leetcode.com/problems/knightdialer/

Struct with pointers changes value without reassigning
I debugged the program below. It finds the correct result but then
mmat
in the recursive functionri
gets changed without reassigning it by this part of the codepmat[q][h].ptes=NULL;
andi
get as final result that all the non preassigned pointers are null. I got the same problem with a global variablemat **mmat
instead of passing it by reference inri
. Does anybody know the reason?typedef struct tes_{ struct seg_{ char c; int v; }seg[2]; }tes; typedef struct mat_{ tes *ptes; int rot; } mat; int max=0; int main() { FILE *f; char frase[M], buff[M]; int n,i,j,r,c,q=0,z=0,e=0,*pos,*esc; tes *vtes; mat **pmat, **mmat; printf("Inserire nome file input tessere: "); scanf("%s",frase); f=fopen(frase,"r"); if (f==NULL) exit(1); fgets(frase,50,f); sscanf(frase,"%d",&n); vtes=malloc(n*sizeof(tes)); for (i=0;i<n;i++) {fgets(frase,M,f); sscanf(frase,"%c %d %c %d",&(vtes[i].seg[0].c),&(vtes[i].seg[0].v),&(vtes[i].seg[1].c),&(vtes[i].seg[1].v));} fclose(f); printf("Inserire nome file input scacchiera: "); scanf("%s",frase); f=fopen(frase,"r"); if (f==NULL) exit(1); fgets(frase,M,f); sscanf(frase,"%d %d",&r,&c); esc=(int*)malloc(r*c*sizeof(int)); pmat=(mat **)malloc(r*sizeof(mat *)); mmat=(mat **)malloc(r*sizeof(mat *)); for (i=0;i<r;i++) {pmat[i]=(mat *)malloc(c*sizeof(mat)); mmat[i]=(mat *)malloc(c*sizeof(mat));} for (i=0;i<r;i++) { fgets(frase,M,f); q=0; for (j=0;j<c;j++) { z=0; while (frase[q]!='/') { buff[z]=frase[q]; q++; z++; } q++; buff[z]='\0'; z=0; if (atoi(buff)==1) pmat[i][j].ptes=NULL; else {pmat[i][j].ptes=&(vtes[atoi(buff)]); esc[e]=atoi(buff); e++;} while (frase[q]!=' '  frase[q]=='\n'  frase[q]=='\0') { buff[z]=frase[q]; q++; z++; } q++; buff[z]='\0'; pmat[i][j].rot=atoi(buff); } } pos=(int *)malloc((ne)*sizeof(int)); q=0; for(i=0;i<n;i++) { // pos contiene tutte le tessere inseribili for (j=0;j<e;j++) if(esc[j]==i) break; if (j>=e) {pos[q]=i; q++;} } ri(pmat,&mmat,vtes,pos,ne,r,c); printf("Max valore %d\n",max); for (i=0;i<r;i++) { for (j=0;j<c;j++) { printf("%c %d // %c %d\t",mmat[i][j].ptes>seg[(0+mmat[i][j].rot)%2].c,mmat[i][j].ptes>seg[(0+mmat[i][j].rot)%2].v,mmat[i][j].ptes>seg[(1+mmat[i][j].rot)%2].c,mmat[i][j].ptes>seg[(1+mmat[i][j].rot)%2].v); } printf("\n"); } return 0; } void ri(mat **pmat, mat ***mmat, tes *vtes, int *pos, int i, int r, int c){ int j,q,h,z,*pos2; if (i==0) { if(check(pmat,vtes,r,c)) { *mmat=pmat; } return; } for (j=0;j<i;j++) { for (q=0;q<r;q++) { for (h=0;h<c;h++) { if (pmat[q][h].ptes==NULL) break; } if (h<c) break; } if (q==r && h==c) return; pos2=malloc((i1)*sizeof(int)); for (z=0;z<i;z++){ if (z<j) pos2[z]=pos[z]; else if (z>j) pos2[z1]=pos[z]; } pmat[q][h].ptes=&(vtes[pos[j]]); pmat[q][h].rot=0; ri(pmat,mmat,vtes,pos2,i1,r,c); pmat[q][h].rot=1; ri(pmat,mmat,vtes,pos2,i1,r,c); free(pos2); if ((*mmat)[0][1].ptes==NULL) { printf("prob"); } pmat[q][h].ptes=NULL; if ((*mmat)[0][1].ptes==NULL) { printf("prob"); } } } int check(mat **pmat,tes *vtes, int r, int c){ int i,j, cont=0; for (i=0;i<r;i++) { for (j=0;j<c1;j++) { if (pmat[i][j].ptes>seg[(0+pmat[i][j].rot)%2].c!=pmat[i][j+1].ptes>seg[(0+pmat[i][j+1].rot)%2].c) break; } if (j==c1) {for (j=0;j<c;j++) cont+=pmat[i][j].ptes>seg[(0+pmat[i][j].rot)%2].v;} } for (i=0;i<c;i++) { for (j=0;j<r1;j++) { if (pmat[j][i].ptes>seg[(1+pmat[j][i].rot)%2].c!=pmat[j+1][i].ptes>seg[(1+pmat[j+1][i].rot)%2].c) break; } if (j==r1) {for (j=0;j<r;j++) cont+=pmat[j][i].ptes>seg[(1+pmat[j][i].rot)%2].v;} } if (cont>max) { max=cont; return 1; } return 0; }

finding all k subsets using recursion
I'm trying to find a way to make a recursive algorithm that will give all the klength subsets of a set of numbers (0 > n), but I cannot send a list to the function as an argument.
Eventually I want to return a list of lists
I thought on starting from the end, using some kind of DP. None of the things I've tried got even close to it
Thank you

Recursion gives erroneous results in Python 3
I was trying to experiment with memoization of the Ackermann Function.
Here is the Ackermann Function:
F(x, y) = y + 1 if x == 0 = F(x  1, 1) if x > 0 and y == 0 = F(x  1, F(x, y  1))
And here's the code I came up with:
memo = dict() def ackermann(i, j): if memo.get((i, j)) is None: x = calculate_ackermann(i, j) print(i, j, x) memo[(i, j)] = x return memo[(i, j)] def calculate_ackermann(i, j): if i == 0: return j + 1 elif j == 0: return ackermann(i  1, 1) else: return ackermann(i  1, ackermann(i, j  1)) def main(): for i in range(10): for j in range(10): print(f"{i}, {j} : {ackermann(i, j)}") main()
When the
for
loops are removed andackermann(1,0) is directly called from
main, then it returns the correct result, but in its current form, it returns
None` at (1,0). Couldn't understand the reason even after debugging. I probably am missing something about the nature of call stack of Python.Why is it returning
None
at (1, 0)? 
Broadcasting from Facebook page
I have a Facebook page and I was using Chatfuel as a bot script to send some broadcasts but now I got over 10k users and I must pay for it so I thought about making my own broadcasting script...
When I strated to read FB developer docs I found thay it works and made it work but the problem is that till the app is verified I can't send a broadcast to all fb page fans ... Recording to developer.facebook.com
If your Facebook app is in development mode, broadcast messages will only be sent to users that have been granted the Admin, Developer, or Tester roles for your app.
So what I'm asking right now is if there is any why to get a verified access_token to my Facebook page to make this work or if I want to verify my app how much does it take or and If you have any suggestions or other ideas to make it work?
Lastly, can I get the access_token that Chatfuel for example uses to acces my Facebook page?
Thanks

Show data point only on selected data point?
I am using GraphView library (http://www.androidgraphview.org/legend/) to build my chart. I have a listener in my chart and the purporse is to start with zero data points at the begining. I want to when I click on a specific position from the chart to show the data point icon from the position I clicked.
Example of what I have:
Example of what I want:
This is my code:
class MainActivity : AppCompatActivity() { lateinit var series:LineGraphSeries<DataPoint> override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val series = LineGraphSeries( arrayOf( DataPoint(9.0, 9.0), DataPoint(10.0, 10.0), DataPoint(11.0, 11.0), DataPoint(12.0, 12.0), DataPoint(13.0, 13.0), DataPoint(14.0, 14.0))) graph.addSeries(series) var staticLabelsFormatter = StaticLabelsFormatter(graph) staticLabelsFormatter.setHorizontalLabels(arrayOf<String>("2018", "2019", "2020","2021","2022","2023")) graph.viewport.isScrollable = true graph.gridLabelRenderer.gridStyle = GridLabelRenderer.GridStyle.NONE graph.gridLabelRenderer.isVerticalLabelsVisible = false graph.gridLabelRenderer.labelFormatter = staticLabelsFormatter series.color = Color.BLACK series.thickness = 6 series.isDrawBackground = true series.isDrawDataPoints = true series.isDrawDataPoints = false series.backgroundColor = Color.parseColor("#0D000000") series.setOnDataPointTapListener { series, dataPoint > Toast.makeText( applicationContext, "Series1: On Data Point clicked: $dataPoint", Toast.LENGTH_SHORT ).show() } } }

What's the best way to teach pseudocode ? Ideas sought?
Hi I'm looking for ideas of good ways  preferably practical  to help 17 18 year old students learn pseudocode.

How to split a text into arrays and than into single words?
Given a set X = {r1, r2,. , , , rN}. The set contains N reviews ri one Online store handler. Each array ri = [w1, w2,. , , , wMi] contains the words wj of the review as String. The first entry in r with index 1 is the first word of the review and the entry with index Wed is the last word. We look for an array y = [y1, y2,. , , , yL] and an array c = [c1, c2,. , , , cL]. The array y contains every text fragment (with k words) from X exactly once (so no duplicates) and the ith entry in the array c indicates how often yi occurs in X. The array y should be sorted in descending order (at the position with index 1 the most frequent fragment is). Your algorithm should work for any k.

What method to use in "ATM" based program
I've started with a assignment for a ATM code, I'm supposed to use text file in some way or another. so far I've got this:
print("Hello, and welcome to the ATM machine!\n") a_pin = {1111, 2222, 3333, 4444} def process(): pin = int(input("\nplease enter below your 4digit pin number: ")) if pin in a_pin: if pin == (1111): f = open("a.txt", "r") elif pin == (2222): f = open("b.txt", "r") elif pin == (3333): f = open("c.txt", "r") elif pin == (4444): f = open("d.txt", "r") print( """ MENU: 1: view your current balance 2: make a withdraw 3: make a deposit 4: exit """) option = input("\nwhat would you like to do? ") if option == "1": print(f.read()) elif option == "2": y = str(input("\nHow much would you like you like to withdraw? ")) f.write(y) print("Excellent, your transaction is complete!") elif option == "3": z = str(input("\nHow much would you like to deposit? ")) f.write(z) print("Excellent, your transaction is complete!") elif option == "4": input("Please press the enter key to exit.") else: print("\nthat was a wrong pin number!") x = input("\nwould you like to try again? '(y/n)' ") if x == "y": process() else: input("\npress the enter key to exit.") process()
The code works as of now, but I want to save some time by asking how to most effectively overwrite content on the text files when withdrawing/depositing. I was thinking of pickled files... but will be very happy for any suggestions, since normal commands like write dont really work for this task, if i want to display the new ammount to user after a withdraw/deposit. Many thanks!