You have to implement a data structure to represent graphs,directed or undirected,that tries to avoid the wasted space in the representation of a graph with adjacency matrix and the difficulty of searching the edges with adjacency list representation.We consider that the vertices are numbered from 1 to nverts and the exit degree of each vertex is at most MAXDEG. If deg[i] is the exit degree of the vertex i then the neighbors of the vertex i can be saved at the matrix edge[i][j], 1<=j<=deg[i].
Write a program that reads the datas from a file: if the graph is directed or undirected(1 or 0), the number of vertices (nverts),the number of edges (nedges) and the first and the last vertex of each edge.Write the function dfs that, with argument the data structure that you implemented before for the representation of a graph, prints the edges by the depth-first search of a graph. What I've done so far is: I wrote a program that reads these information from a file, calculates the exit degree of each vertex and creates the matrix edge[i][j]. What data structure do I have to implement???
Output to terminal: 0 2 3 1 4 5 but it should be: 0 2 4 5 3 1
Here's my code:
#include<stdio.h> #include<assert.h> /* maxVertices represents maximum number of vertices that can be present in the graph. */ #define maxVertices 100 void Dfs(int graph[][maxVertices], int *size, int presentVertex,int *visited)
What I have done : Created functions to accept inputs from user and read,print out adjacent matrix.
What I need : How do I start DFS in adjacent matrix so that I can output the vertices of each connected component of a graph? I'm confused with adjacent matrix and the term 'component'.
#include <stdio.h> #include <iostream> #define maxV 8 using namespace std; int V,E,x,y; int a[maxV][maxV];
i have come across this code for calculating the depth of a binary tree.
int maxDepth(Node *&temp) { if(temp == NULL) return 0; else { int lchild = maxDepth(temp->left); int rchild = maxDepth(temp->right);
[Code] ....
In these recursive calls i am really clue less about how the statements i numbered from 1 to 4 would be executed...in every recursive call...???
Lets temp has left depth of 3 and right depth of 100 then...in last 97 recursive calls max(temp->left) would be doing...????? how these recursive mechanism work here... I want to know specifically how these left node and right node recursive calls are co-ordinating with each other????
I wrote this code, but now need to apply a limit to the recursive depth. This is the format that I have to use. How would I pass a limit so that it stops after a given number? I'm just confused about where to apply it.
int compute_edit_distance(char *string1, char *string2, int i, int j, int limit) { if (strlen(string1) == i) return strlen(string2) - j; if (strlen(string2) == j) return strlen(string1) - i; if (string1[i] == string2[j]) return compute_edit_distance(string1, string2, i + 1, j + 1, limit);
#include <iostream> #include <stack> using namespace std; struct valpos//structure which carries information about the position of the cell and its value { int val; int row; int col;
I am trying to implement a Task scheduler where i have n number of tasks. The Idea behind my task scheduler is that in a loop of queues of a vector, task should get enqueued to the shortest queue among the loop of queues, which is done by the following code.
#include <vector> #include <queue> std::vector<std::queue<int> > q int min_index = 0; task t // implemented in the other part of the program
[Code] ....
Next i am trying to extend this paradigm to reduce the overhead time of the scheduler, Instead of searching the shortest queue every time, search after some condition ie. search the shortest queue after 5 tasks gets enqueued to the shortest queue.
i need to do something like this
#include <vector> #include <queue> std::vector<std::queue<int> > q task t // implemented in the other part of the program while(q[min_index].size()!=q[min_index].size()+5) // check whether current min_index queue's size is increased 5 more times if not goto enqueue
inputting a search array. I tried putting a binary search but I can't get it to work. everything else works up until I put the value I am searching for in the array, then it just crashes.
How it suppose to work: input 2 coordinates with a value each then it calculates the distance between them then it suppose to let user search the coordinates for a value and state if found which coordinate it is at.
This is the first time I'm trying to program in C# and I'm having some trouble.I can't find a way to compile whatever I do.I don't think it's a problem of what I wrote but I might not have what is necessary.I tried: C:>csc fisrt.cs csc was not a valid command.
well the question is how to compile objects in a subdirectory?
Code:
./bo/%.o : %.c $(CC) $(CFLAGS) <$
the command abouve will compile my objects but leave them in the same directory. However I want them in a different directory. in ./bo directory. How to achieve that ? I just realize that if i remove ./bo/ from the line it does not work..
I am currently learning C and im in the middle of completing my assignment. It has to calculate parking whilst account for a few values here is the assignment sheet for specifics. Design Specifications Write, compile and test a C program with appropriate use..It's practically error less yet when i compile it doesn't come up with what i need.
I want to start developing Android apps in C++, but I do not know what I could use to compile the source code into an apk. I know that C++ is probably not the best choice for Android development, but I already know it and I do not want to learn Java.
I have download the SOIL library [URL] for loading textures in OpenGL, however it doesn't come with a SOIL.lib file but a file called libSOIL.a and it says I need to compile it myself.
I hate vague errors where I don't even know where to start looking for an error. Error happens immediately and it says "Unhandled exception at 0x5981c9c7 (msvcr100d.dll) in experiment.exe: 0xC0000005: Access violation reading location 0xabababab."
I have called a C function inside C++ code. The .so which gets created is a 32 bit while I am looking for 64 bit . What all options should be mentioned in the Make file to eventually compile and get shared object of ELF64 CLASS ?
Excerpts from Makefile -----------------------------