[Solved] Algorithm design manual solution to 1-8

https://cs.stackexchange.com/ is probably better for this. Also I’m pretty sure that $$ formatting only works on some StackExchange sites. But anyways, think about what this algorithm is doing at each step. We start with p = A_n. Then we take p = p*x + A_{n-1}. So what is this doing? We now have p = … Read more

[Solved] A Codility test that needs to be solved

The function can look as it is shown in the demonstrative program #include <iostream> #include <algorithm> #include <vector> long long int solution( const std::vector<int> &v ) { long long int max_sum = 0; for ( auto it = v.begin(); ( it = std::find_if( it, v.end(), []( int x ) { return !( x < 0 … Read more

[Solved] An Algorithm/PHP code for word finding game [closed]

I am so sorry , I posted this question here, as suggested by one of the users, I googled a few different things online an dhave found a ruby file which has been built for the same purpose. And , if anybody would like to access it, they may check it out online at http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/298382 … Read more

[Solved] Encrypt ip addresses [closed]

Use Base64. It is widely used and probably already supported on your target framework. Just as base 10 allows only 10 possible glyphs within a character, base 64 allows 64 glyphs per characters. To express a 32 bit number such an an IP address, you would need at a base 64 number that has at … Read more

[Solved] Similarity measure in classification algorithm

There a number of possible measures of similarity. Ideally, you should derive one yourself that takes account of the reason why you are doing this classification, so that good similarity scores amount to something that performs well when you use it in practice. Here are a few examples. 1) Cosine similarity. Treat the two sets … Read more

[Solved] Given 1 < a < 10, 1 ≤ n ≤ 100000, show how to compute the value of 1 × a + 2 × a^2 + 3 × a^3 + . . . + n × a^n efficiently, i.e. in O(log n)!

If this is homework I guess your professor explained you how to compute Fibonnacci numbers and expect you to use the same trick. So basically remark that: |1+a+ a²+…+ a^n| |a 0 1| |1+a+ a²+…+ a^(n-1)| | a+2a²+…+na^n| = |a a 1| | a+2a²+…+(n-1)a^(n-1)| |1 | |0 0 1| |1 | |a 0 1|^n |1| … Read more

[Solved] Generateing all possible 16 digit number requireling less storage location

If I understand you correctly then all that code is just to avoid printing numbers that have more than eight zeroes You can do that like this my $credit_card_number = “$a$b$c$d$e$Fc$g$h$i$j$k$l$m$n$o$p”; print $credit_card_number, “\n” unless $credit_card_number =~ tr/0// > 8; But I still think your enterprise is a fruitless one solved Generateing all possible 16 … Read more