I am looking for a compression algorithm which compress sequence of random numbers (will be in sorted order but some of the numbers may be missing). The compressed data will be sent to other component where decompression will take place.
I have this image/video compression project that is to be done in C. I've been given this source code by my supervisor which is supposed to be a working one.
Assuming I have a sequence of 5 images in .pgm format (image41.pgm, image42.pgm .... image45.pgm). Some of the code involved is
When I tried to compile the code using make file (shell script), I got this error message "In function 'readPgm' format '%d' expects argument of type 'int *', but argument 3 has type 'unsigned char *' "
Can identify what the problem is and how to rectify it?
I have to write a program that uses negative numbers in a conjecture algorithm. The program terminates when a number is reached that was already outputted. I can not get it to work and I have been racking my brain for a week.
#include <iostream> using namespace std; int main() { int x[1000], y[1000], i=0, j=0, count=0, w=0, z[1000], t = 0;
My program generates an array of random numbers. I want to then search a specific number within the array. If the number is in the array then a message apopears on the console saying that its there. I'm using the binary search algorithm to do this.
#include <iostream> #include <ctime> #include <cstdlib> #include <iomanip> #include <cstring> using namespace std; int size; int getSize() { return size; }
I am writing a simple console-based tic-tac-toe game. I am trying to write a function to check whether someone has won the game.
The board data is saved in an array called board: Code: int board[3][3] with each element corresponding either to an empty spot, an X, or an O, using the numbers 0, 1, and 2, respectively. For clarity:
Code: #define EMPTY 0 #define X 1 #define O 2 Here is my function: Code: int check_state(int board[3][3]) { int winner = 0;
A few days ago I got a "bright idea" to see if I could match a string, with an arbitrary length from 1 to 12, to its formulated sequence by using an algorithm to find all possible combinations of the integer combinations from 0 to 9 at each length (1 to 12).
Example: Desired numerical combinations from integers 1 to 3:
And so on until the nth length (in my case a length of 12).
First off, I would like to say that this is not as easy as I thought. I clearly underestimated the problem seeing as I've spent hours attempting to write a working algorithm, but feel like I've made no progress.
I can't exactly explain this one. It works if the length is 2 or less; however, the order of the output is horrendous.
Attempt 3: I tried using recursion, but only found myself getting more and more lost the further I tried developing my function. Cannot find my work for this attempt.
I would really like to figure this out on my own, but I am very stuck as you can see. I also lack time that I can spend working on this since im a full time student.
I wrote a version of find_all() which searches through containers for matches and returns another container that holds iterators pointing to each match. When I compared what I wrote to what the authors of Professional C++ wrote, I found the two find_all() functions to be very different.Here they are:
I have VRP algorithm written in C++, run with command prompt Windows. input (command line) -> VRP.exe -> output (txt file)
Now I want to built a website to run it as SaaS. How to run an exe application(compiled c++) in server used as Saas? What kind of programming do I have to use? Ruby or html5 or others? I don't know how to start.
To construct and write down algorithm of determination of the sum of squares of consecutive integers with recursion use. I tried to do something:
public static int RecSumSquare(int x, int n) { if (n < 0) throw new ArgumentException("n should be greater than zero"); if (n == 0) return 0; else return x*x+RecSumSquare(x, n - 1); }
But I don't know as the beginning and the end of this algorithm will look.
I'm still a beginner at C++ programming, I have tried to implement some optimization algorithms (related to database) in C++, I cannot say it is going as far as I thought it will be, some errors does not even make sense, I will cut to the chase, I need to implement SA (Simulated Annealing) in C++, SA, which is an example of the Randomized Algorithms, functions on the concept of randomness and probability. In addition, I searched the internet with no (let say "accurate") code that might give me insight on how to begin, I only found one code for SA that I could understand, and edited it (which will be shown below), still looking to enhance and correct it more.
If the concept of Simulated Annealing is not clear, you may refer to the following papers which can be found in a simple Google search: Simulated Annealing Algorithms: an overview.An Introduction to Interacting Simulated Annealing. Query Optimization (there is a sub-section for Simulated Annealing in this paper that explains SA briefly) ....
write an algorithm using stack to determine if an input of string is in the form xCy where y is the reverse of x.x and y are strings of A and B. eg : AABACABAA
I'm trying to implement the flocking algorithm in C++. I've tried to implement it myself by making all the particles 'home-in' on the player. When 2 particles then collide within their larger bounding boxes they home-in to each other. And when the 2 particles are actually touching they repel each other until they are outside of their bounding boxes and find another particle to home-into.when I run my application the particles all home into the player and come to a stand still along the Y-axis above the player.
All the particles in question are stored in a Vector, with a pos and velocity.
for(int i = 0; i < swarm.size(); i++) { for (int j = 0; j < swarm.size(); j++) { if (swarm.at(i)->getParticleModel()->getPosition().x < gameObjects.front()->getParticleModel()->getPosition().x) { if (swarm.at(i)->getParticleModel()->getTouching() == false)
I made this program in C++ that should, by a genetic algorithm, build a word identical to the initial one improving itself recursively.
The code is:
main.cpp #include <stdio.h> #include <cstdlib> #include "Genetic.h" using namespace std;
[Code] ....
The problem is: when running with gdb it gave me this
warning: Could not load shared library symbols for linux-vdso.so.1. Do you need "set solib-search-path" or "set sysroot"? CREATA LA PRIMA POPOLAZIONE PARTE L'EVOLUZIONE TROVATO BEST: fzlrq TROVATO BEST: hglhe
Program received signal SIGSEGV, Segmentation fault. 0x000000000040720e in Genetic::Gene::Gene (this=0x7fffff7ff030) at Genetic.h:20 20 struct Gene {
The line corresponds to the struct declaration. Every 1000 executions it runs well.
Genetic Algorithm Library in C++? I looked for in the web, there are a lot of them, have you tried some? Is there one up to date or with a good community?
I've been stuck on a divide a conquer algorithm problem for about an hour now, and I'm not sure how to solve it. I need to use divide-and-conquer to implement an algorithm that finds the dominant element of an array of positive integers and returns -1 if the array does not have a dominant element (a dominant element is one that occurs in more than half the elements of a given array).
No sorting may be used, and the only comparison that may be used is a test for equality.
I understand the general process I need to follow to solve this problem, but I'm not sure exactly how to convert my thoughts to code. I know that if a number x is the dominant element of an array A, the x must be the dominant element in either the first half of A, the second half of A, or both.
Here is what I have so far.
#include <iostream> #include <string> #include <vector> using namespace std; int find_dominant(int *A, int p, int r) {
i have been trying to call out the tea algorithm from wikipedia. However i keep getting a segmentation fault. Am i calling it out the wrong way? Below are the snippets
methods taken from wikipedia
void encrypt (uint32_t* v, uint32_t* k) { uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */ uint32_t delta=0x9e3779b9; /* a key schedule constant */ uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */ for (i=0; i < 32; i++) { /* basic cycle start */ sum += delta;
[code]....
i tried to encrypt a test text and casting it to the uinstd32_t type. However it always gives me a segmentation fault.