antidigest / algorithms Goto Github PK
View Code? Open in Web Editor NEWSo that someone keeps trying to find the solutions !
So that someone keeps trying to find the solutions !
Hey!
If I may, I have a little suggestion.
It is considered best practice, when writing code, to implement the algorithm in a generic form, i.e., your program should run regardless of the size of the array (in this case). For instance, your for loop (in Insertion Sort) uses the condition j < 6 (because the length of the array you used is 6). This program will break if I use any array which doesn't have the length 6.
I know that you have understood the algorithm by heart and just want to demonstrate this fact, but get in the habit of writing generic code from day 1. Believe me, its going to do wonders for you in future!
(for example, take the Insertion Sort Algo, implement it inside a separate function (lets call it insertion_sort ()) which accepts an array as an argument (or a pointer to the array plus its length). This way, I can use any sort of array (with any primitive data type like char, float, int, etc.) of any size, simply call a function from main () and poof! Its done!).
This means all I have to write in my file is:
//COPY YOUR FUNCTION DEFINITION
int main () {
int A [] = {-2, 893, 89, 29, 189};
length = sizeof (A) / sizeof (A [0]);
insertion_sort (A, length);
//logic to print the sorted array
return (0);
}
Try to make it as smooth as possible for someone else who might want to use your code.
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.