Bellman-Ford algorithm implemented with queues in C

I am in the midst of applying a bellman ford algorithm using a queue and my code works for all cases where the source vertex is 0 however outputs garbage when the source vertex is changed. I think there must be an issue with the line “foredge;edge<(nn);edge);” Thanks.


include

include

include

int readGraphWeighted(int n, int m, int graph[]){ int i; int size = n*n; for(i = 0; i < size; i++){ graph[i] = 0; }

int edgeA; int edgeB; int weight; for(i = 0; i < m; i++){ scanf(“%d %d %d”, &edgeA, &edgeB, &weight); graph[edgeA*n + edgeB] = weight;

} }

int findVal(int element, int queueSize, int queue[]){

//if element is in the queue then function returns 0 //else it returns 1 int i; int toReturn=1; for(i=0;i<queueSize;i++){     if(element==queue[i]){         toReturn=0;     } } return toReturn; 

}

int main(){

//initialize all necessary int n; int m;  scanf("%d %d",&n,&m);   int d[n]; int p[n]; int graph[n*n]; int queue[n]; int source; int edge; int queueSize=0; int head=0;   //intermediary variables int i; int row; int col;  //read in all information needed readGraphWeighted(n,m,graph); scanf("%d",&source);  //intialize everything as instructed for(i=0;i<n;i++){     d[i]=INT_MAX;     p[i]=-1;     queue[i]=0; }  queue[head]=source; queueSize++; d[source]=0; p[source]=source;  //**main body of program**   while(queueSize !=0){     //pop     edge=queue[head];     queueSize=queueSize-1;     head++;      //for every edge     for(edge;edge<(n*n);edge){          if(graph[edge] !=0){             //if we reach a value in graph record its row and col             row=edge/n;             col=edge%n;              //if the value in d is larger replace it             if(d[col]>d[row]+graph[edge]){                 d[col]=d[row]+graph[edge];                  //update predecessor                 p[col]=row;                  if(findVal(col,queueSize,queue) == 1){                      //push                     queue[queueSize-1]=col;                     queueSize++;                 }             }         }     } } printf("\nRESULTS:\nsource vertex: %d\n",source); printf("D: "); for(i=0;i<n;i++){     printf("%d, ",d[i]); } printf("\n"); printf("P: "); for(i=0;i<n;i++){     printf("%d, ",p[i]); } 

}


Is the ATA Security Feature Set implemented on all SATA HDD’s? [on hold]

Is the ATA Security Feature Set implemented on all SATA HDD’s? From what I’ve read, it’s an optional part of the specification, but it seems like pretty much all drives implemented it.

The reason is for certain Xbox mods HDD locking is required, so if all SATA HDD’s support it then that advice can be given to others, as it’s yet to be clarified in the community from what I can tell.

Time complexity of finding predecessor for a dictionary implemented as a sorted array

I’m currently reading “The Algorithm Design Manual” by Steven Skiena. On page 73, he discusses the time complexity of implementing $ Predecessor(D, k) $ and $ Successor(D, k) $ and suggests that it takes O(1) time.

If the data structure looks something like

[(k0, x), (k1, x), ...] 

where the keys k0 to kn are sorted, given k, I thought the successor(D, k) would first have to search the sorted array for k ( $ O(log n) $ ) and then get the successor ( $ O(1) $ ) since the array is sorted, and hence the overall time complexity should be $ O(log n) $ instead of $ O(1) $ as mentioned in the book. This should also apply for predecessor(D, k).

For an unsorted array, the time complexity for predecessor and successor remain as $ O(n) $ since searching the unsorted array also takes $ O(n) $ .

Did I misunderstand something?

SSL/TLS Extended Validation implemented in fraudulent domains

People trust green bars, because it is proven to not to be of malicious origin.

This seems to be the questions of hundreds and many are concerned about it, picture that; a team of fraudsters(or at least one), promote their website to many people with the use of Facebook and Twitter advertising who can be easily set up in no time. (1).

The fraudulent websites created a site, looking real etc.. and as already said they have an EV certificate verified implemented. In what ways could such thing be successfully be done, how do certificate distributors verify who that who is(if it can be faked)? (2).

Can a hashing function be implemented insecurely?

After working on a an imaginary security related project, it was decided that the project is going to use the imaginary hashing function X.

There are various implementations of the hashing function available as packages, all varying in terms of adoption rates and popularity.

Given that any package returns correct hashes for a small amount (n=10) of test cases, are there any serious security implications that could occur? My understanding is that a hashing function should return a irreversible value, and given that any implementation does this correctly, they should all be equally working & therefore secure.

Right?

How is Sandboxing implemented?

What I would like to know is two fold: First off, what is sandboxing? Is it the trapping of OS system calls and then secondly deciding whether to allow it to pass through or not? How is it implemented to begin with? Would it be by way of hooks in the SSDT (kernel level)?

Running a git-based program (Bup) on Ubuntu WSL gives error “[Errno 38] Function not implemented”

My Ubuntu setup is running great and things to seem to be working well for other things I’m doing but with one particular program (Bup) which is a backup solution built on top of git.

Running this command gives the errors [Errno 38] Function not implemented

bup save -n InitialCommit /mnt/c/BackupTest 

From basic Googling it seems to be Python or git related and possibly related to multithreaded processing not being supported, but I’m not sure if that is what’s happening here.