fix: memory allocation method (#1220)

* Fix : memory allocation method

"new" is not used in C , because of that the compiler was giving compilation error.
Instead malloc was used for memory allocation.

* updating DIRECTORY.md

* Update data_structures/graphs/kruskal.c

Co-authored-by: Stepfen Shawn <m18824909883@163.com>

* updating DIRECTORY.md

---------

Co-authored-by: github-actions[bot] <github-actions@users.noreply.github.com>
Co-authored-by: Stepfen Shawn <m18824909883@163.com>
This commit is contained in:
Rishav Kumar 2023-03-17 23:31:44 +05:30 committed by GitHub
parent acbaf4a291
commit 9997c8bdf0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -27,11 +27,11 @@ struct Graph
// Creates a graph with V vertices and E edges
struct Graph *createGraph(int V, int E)
{
struct Graph *graph = new Graph();
struct Graph* graph = (struct Graph*)(malloc(sizeof(struct Graph)));
graph->V = V;
graph->E = E;
graph->edge = new Edge[E];
graph->edge = (struct Edge*)malloc(sizeof(struct Edge) * E);
return graph;
}

View File

@ -27,7 +27,7 @@
| 24 | [Swap Nodes in Pairs](https://leetcode.com/problems/swap-nodes-in-pairs) | [C](./src/24.c) | Medium |
| 26 | [Remove Duplicates from Sorted Array](https://leetcode.com/problems/remove-duplicates-from-sorted-array) | [C](./src/26.c) | Easy |
| 27 | [Remove Element](https://leetcode.com/problems/remove-element) | [C](./src/27.c) | Easy |
| 28 | [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string) | [C](./src/28.c) | Medium |
| 28 | [Find the Index of the First Occurrence in a String](https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string) | [C](./src/28.c) | Easy |
| 29 | [Divide Two Integers](https://leetcode.com/problems/divide-two-integers) | [C](./src/29.c) | Medium |
| 32 | [Longest Valid Parentheses](https://leetcode.com/problems/longest-valid-parentheses) | [C](./src/32.c) | Hard |
| 35 | [Search Insert Position](https://leetcode.com/problems/search-insert-position) | [C](./src/35.c) | Easy |