Posts by Gabriel Taets • 99 points
4 posts
-
2
votes2
answers169
viewsA: Recursive code C++
No variable is required c as our colleague suggested. The problem with your code is at the base of the recursion and in the condition of the ternary operator. When the condition i < size is true…
-
3
votes1
answer559
viewsA: Is there an insertion method for binary tree search faster than trivial?
In general, the insertion in BST is O(N) in the worst case (which is a tree completely hanging to one side), which would actually give an algorithm O(N²). However, this can be easily circumvented by…
-
1
votes1
answer849
viewsA: Operations with complex numbers in C - Root calculation of an equation by the Newton Raphson method
If you’re entering an infinite loop, the problem is while(er>e);, which should always be true. This way, should check whether the assignment you make to er is correct: er=fabs((x2-x1)/x2);, in…
-
0
votes2
answers103
viewsA: How to create a vector2 in C?
In C, Classes are not used, as is done in C++. When we want to store data of different types, we use struct: struct estrutura { int nBase; int nAltura; double fArea; }; and then we can create…