#include <stdio.h>
#include <conio.h> //function to print the bins:
void printBins(float bins [500] [500],int items )
{
for (int j=1;j<=items;j++)
{
for (int i=1;i<=items;i++)
{
printf(" %1.3f",bins[i][j]);
}
printf("\n");
}
} int main()
{
int items, x=1,c=1, i=0, j=1, countOfBins=1;
float z,sum=0 ,inputitems[500], bin[500][500]; printf("Enter the number of items:");
scanf("%d", &items); //scanning how many elements the user wants to enter
if (items<=0)
{
printf("Can't bin-pack on zero elements");
getch();
}
else
{
do{
printf("\nEnter item number %d: ",x);
scanf ("%f",&z); //scanning the elements the user inputs if ((z<0)(z>1)) //assuming my bins range from 0 to 1 only
{
printf ("\nitem number %d is not in range of 0 to 1",x);
goto stop;
}
else //if all the inputs were in the correct range
{
inputitems[x]=z; //save my elements in an array called inputitems
x++;
}
}while (x<=items); //end of do-while statement
//technique number 1:
printf ("\nIn Next Fit online technique:");
loop:
while (c<=items)
{
if (sum+inputitems[c]<=1) //to check if you have any more room to fit in the bin
{
i++; //assuming that each row represents a bin
bin[i][j]=inputitems[c]; //place element from inputitems array into a 2D array called bin
sum += inputitems[c];
c++;
goto loop; //go back to the while statement to check condition
}
else
{
j++;
countOfBins++; //to count the number of bins we used
i=1;
sum=0;
bin[i][j]=inputitems[c];
sum += inputitems[c];
c++;
goto loop;
} } //end of while loop printf("\nNumber of bins used: %d \n", countOfBins);
printf("\nstructure of bin\n(FYI any empty rows shown, are equal to the number of items that you have entered)\n");
printBins(bin,items);//to print the bins used with their elements //end of first technique, can;t stop: getch();
}//end of very first else }//end of main //I could not figure out any of the other 4 techniques of Bin Packing... any help please?
yes we can do it,in c
hi.... for DIT fft algorithm, refer to this link, it has c-code for that. http://cnx.org/content/m12016/latest/
Yes. More generally, every algorithm (defined as a sequence of finite steps to solve a problem that can be easily understood by a human) can be converted into machine code such that the algorithm can be understood by a machine. The C programming language is just one such method of converting algorithms into working machine code.
Ronaldo! 'c' coding of Ricart-agarwala algorithm
Algorithms are created using pseudocode, which is a combination of natural language (such as English) and commonly understood programming concepts. Pseudocode is a machine-independent language, but it is far too abstract for a machine to understand. It is intended for humans only. As programmers, our job is to translate these algorithms into a form the machine can process in order to produce the required machine-dependent code. For this we use programming languages, such as C, C++ and Java. The more abstract the programming language, the easier it is to convert an algorithm into working code. Of all the high-level programming languages, C has the least amount of abstraction, however we can make use of third party libraries to increase the amount of abstraction, or we can use the language itself to create our own abstractions.
You don't write an algorithm for a C++ program, unless you are documenting the C++ program after-the-fact. The normal procedure is to write the algorithm first, in a language independent fashion, and then translate that stated algorithm into C++ code, or into whatever language you wish.
yes we can do it,in c
The source code, in C, will depend on what type of lossless compression algorithm will be used. A source code should be available from various computer scientists in your area.
This is a request, not a question.
hi.... for DIT fft algorithm, refer to this link, it has c-code for that. http://cnx.org/content/m12016/latest/
You are going about this backwards. First, define the program. Second, describe its algorithm. Third, if needed, write pseudo code. (Sometime, algorithm and pseudo code is the same process.) Fourth, or third, write real code.
Yes. More generally, every algorithm (defined as a sequence of finite steps to solve a problem that can be easily understood by a human) can be converted into machine code such that the algorithm can be understood by a machine. The C programming language is just one such method of converting algorithms into working machine code.
The C code for Prim's algorithm can be found in the following link. https://sites.google.com/site/itstudentjunction/lab-programming-solutions/data-structures-programs/program-to-find-minimal-spanning-tree-using--prims-algorithm
Ronaldo! 'c' coding of Ricart-agarwala algorithm
Algorithms are created using pseudocode, which is a combination of natural language (such as English) and commonly understood programming concepts. Pseudocode is a machine-independent language, but it is far too abstract for a machine to understand. It is intended for humans only. As programmers, our job is to translate these algorithms into a form the machine can process in order to produce the required machine-dependent code. For this we use programming languages, such as C, C++ and Java. The more abstract the programming language, the easier it is to convert an algorithm into working code. Of all the high-level programming languages, C has the least amount of abstraction, however we can make use of third party libraries to increase the amount of abstraction, or we can use the language itself to create our own abstractions.
Lempel-Ziv-Welch (LZW) encoding is patented, thus we cannot show you a working example. However, the basic algorithm is well-documented on various websites including Wikipedia. If you can follow the algorithm, you can write the code. But you cannot distribute the code without the requisite licence.
Algorithm is a step by step process to solve a particular task.