2
votes
3answers
740 views

How to reduce execution time and compile time of this program?

I have one programming question: The sine and cosine of x can be computed as follows. sin(x) = x - x3/3! + x5/5! - x7/7! - x9/9! + … cos(x) = 1 - x2/2! + x4/4! - x6/6! + x8/8! - ...
2
votes
2answers
2k views

Conversion of expression from Prefix to Postfix notation (Problem with precedence) [closed]

I have been attempting to write a code that converts Prefix expressions to Postfix expressions. So far here's what I have made (note that I am new and hence it may not be efficient!) ...
4
votes
3answers
345 views

Nearest Neighbour classification algorithm

The following code is from a university assignment of mine to write a classification algorithm (using nearest neighbour) to classify whether or not a given feature set (each feature is the frequency ...
3
votes
2answers
171 views

PHP function to compare two Roman numerals

This was for an assignment. I had to write a function to compare two roman numerals. This had to return true only if the second number was larger than the first and ...
3
votes
2answers
228 views

Homework Review - Storing three integer values

Consider an 8-bit complier, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as: ...
16
votes
9answers
5k views

Most efficient way in C++ to strip strings

If I want to strip a string completely of its whitespaces, punctuation and numbers (i.e. anything that is not A-Z, a-z), what is the most efficient way of doing it in C++? I tried this: ...