From eead44336ddeb70f7f9918f6a189764a8f65e851 Mon Sep 17 00:00:00 2001 From: mehal007 Date: Sat, 28 Oct 2017 23:09:39 +0530 Subject: [PATCH 1/3] updated improved some comments and an output section --- BellmanFord/C++/bellmanford.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 +} From 67ebddcd0b73af97f51e551b20ca83e89b231258 Mon Sep 17 00:00:00 2001 From: mehal007 Date: Sat, 28 Oct 2017 23:16:58 +0530 Subject: [PATCH 2/3] syntax error just a semicolon --- BinarySearch/C++/BinarySearch - (recursive).cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) { From 714e7940bef99a1bbd689cb60f9c3ec28e21f3f2 Mon Sep 17 00:00:00 2001 From: mehal007 Date: Sat, 28 Oct 2017 23:37:28 +0530 Subject: [PATCH 3/3] user-friendly added some comments --- CountingSort/C++/CountingSort.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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; }