diff --git a/BellmanFord/C++/bellmanford.cpp b/BellmanFord/C++/bellmanford.cpp index 996a464e9..8a7349831 100644 --- a/BellmanFord/C++/bellmanford.cpp +++ b/BellmanFord/C++/bellmanford.cpp @@ -7,8 +7,8 @@ using namespace std; struct Edge { - // This structure is equal to an edge. Edge contains two end points. These edges are directed edges so they - //contain source and destination and some weight. These 3 are elements in this structure + /* This structure is equal to an edge. Edge contains two end points. These edges are directed edges so they + contain source and destination and some weight. These 3 are elements in this structure*/ int source, destination, weight; }; @@ -40,11 +40,10 @@ struct Graph* createGraph(int V, int E) void FinalSolution(int dist[], int n) { // This function prints the final solution - cout<<"\nVertex\tDistance from Source Vertex\n"; int i; for (i = 0; i < n; ++i){ - cout<>graph->edge[i].source; cin>>graph->edge[i].destination; cin>>graph->edge[i].weight; @@ -130,4 +129,4 @@ int main() //passing created graph and source vertex to BellmanFord Algorithm function return 0; -} \ No newline at end of file +} diff --git a/BinarySearch/C++/BinarySearch - (recursive).cpp b/BinarySearch/C++/BinarySearch - (recursive).cpp index e26b202d6..19950279a 100644 --- a/BinarySearch/C++/BinarySearch - (recursive).cpp +++ b/BinarySearch/C++/BinarySearch - (recursive).cpp @@ -15,7 +15,7 @@ int binarySearch(int low,int high,int key) int mid = (low + high) / 2; if(a[mid] == key) - return mid // returns the index if key is found. + return mid; // returns the index if key is found. if(a[mid] < key) { diff --git a/CountingSort/C++/CountingSort.cpp b/CountingSort/C++/CountingSort.cpp index 91e2ddc8c..425ba7a19 100644 --- a/CountingSort/C++/CountingSort.cpp +++ b/CountingSort/C++/CountingSort.cpp @@ -15,7 +15,7 @@ void counting_sort(vector &vec) { vector count(RANGE, 0); for (int i = 0; i < int(vec.size()); i++) { - count[vec[i]]++; + count[vec[i]]++; //set all elements of array as marked in count vector } // Make count[i] contain the start position of the element in the output vector. @@ -48,12 +48,12 @@ int main() { vector test_vec = {99, 122, 11, 2, 2, 3, 44, 33, 9, 0, 0}; cout << "The vector before sorting: "; - print(test_vec); + print(test_vec); //printing original array counting_sort(test_vec); cout << "The sorted vector: "; - print(test_vec); + print(test_vec); //printing sorted array return 0; }