vasipeycheva / data-structures-and-algorithms--2018-2019 Goto Github PK
View Code? Open in Web Editor NEWLections and code from Data Structures and Algorithms course 2018-2019: VIP edition (the course is held by Vasilena, Ivan, Plamen)
Lections and code from Data Structures and Algorithms course 2018-2019: VIP edition (the course is held by Vasilena, Ivan, Plamen)
Shouldn't there be an if checking if it's EOF, because in this way there will be one more iteration of the while loop?
On the following line the name of the function should be getSubTreeRec and the value of the second parameter should be 5, not 0.
On lines 104 and 103 the name of the function should be changed too.
On line 130 of the file dynamicarrayfunctions.h in Practice_07--Sorting-Algorithms/, when you are given an invalid index you are returning 0. However, the return type of this method is const TYPE &. This can be a problem whenever the template class is used with something different from ints. The way to solve this issue is to simply throw an exception, just like you have done on line 139, for the same case.
Moreover, in the same method, when it is called with an appropriate index, you are returning arr[index]. The problem here is that there is no member of the class named arr. What you meant to write is probably return data[index], similar to the method below.
In the file DynamicArrayAlgorithms.h on lines 26 and 30 you are calling a method, respectively First.getSize() and Second.getSize(), every time you iterate over the elements of the arrays. This is from the function merge().
Same goes for the next function, includes(). On line 44 you are calling the method Second.getSize() on every iteration of the loop.
The same problem exists on line 67 in the function filter().
All of this can be made faster by creating a new variable which will be assigned with the size you need. This way, you will be calling the method once, instead of numerous times.
bool insert(node *& root, int data)
{
if (data == root->data)
return false;
if (data < root->data)
{
if (!root->left)
{
root->left = new node(data);
root->subNodes++;
return true;
}
if (insert(root->left, data))
{
root->subNodes++;
return true;
}
}
else
{
if (!root->right)
{
root->right = new node(data);
root->subNodes++;
return true;
}
if (insert(root->right, data))
{
root->subNodes++;
return true;
}
}
return false;
}
You can use stoi() to directly cast to int.
In Student.h line : 32
data.age = atoi(age.c_str()); --> data.age = stoi(age);
http://www.cplusplus.com/reference/string/stoi/
Also stol (long), stoll(long long)...
Поздрави,
Ицо
On the following line of code:
in the function insert_helper, the compiler will go over an additional if-statement.
The problem is that if element is greater than root->key, the code in the previous else-if statement will be executed. In other words, we shouldn't make the compiler check if element is smaller than root->key.
This can be fixed by turning the if-statement into an else-if statement.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.