## [Solved] Big O, how do you calculate/approximate it?

I’ll do my best to explain it here on simple terms, but be warned that this topic takes my students a couple of months to finally grasp. You can find more information on the Chapter 2 of the Data Structures and Algorithms in Java book. There is no mechanical procedure that can be used to … Read more

## [Solved] How to avoid used many if statements in definition?

Use a for loop to iterate over the months: def prepareadres(city,y,m,d): months = [31,28,31,30,31,30,31,31,30,31,30,31] d = d + 1 d0 = 0 m0 = 0 for month in months: if d > month: d = d – month m += 1 if d == sum(months): print(“year complete”) #print(df.iloc[0, :-2]) if (m < 10) and (d … Read more

## [Solved] How to prevent optimization on a class field in C#

I have a local copy here with Parse written as the rather opaque: public void Parse(string[] args) { // deliberately opaque, not that it would make any difference string fieldName = (new string(‘S’, 1) + “ilentX”).Substring(0, 6); GetType().GetField(fieldName).SetValue(this, true); } It works fine. I do not believe the problem is what you think it is. … Read more

## [Solved] time complexity for following function

Upto my knowledge, most common time complexity notation is Big-O, I’ll share same in this answer. Time complexity is O(1), with an assumption that Math.Pow calculation is O(1) and .ToString() method is O(1). It is O(1) because each step will be executed only once. In gerenal, if we take .ToString().Length time complexity into account then … Read more

## [Solved] How does GCC store member functions in memory?

For the purpose of in-memory data representation, a C++ class can have either plain or static member functions, or virtual member functions (including some virtualdestructor, if any). Plain or static member functions do not take any space in data memory, but of course their compiled code take some resource, e.g. as binary code in the … Read more

## [Solved] Can someone help me find the bottleneck in this code?

That’s because allLogs is lazy in nature — it will actually hit the database when first enumerated through in the foreach (see “Deferred query execution” here). If you materialize the collection before hand like the following, you will see that it steps through the foreach quickly: db.StatusLogs .Where(sl => sl.ID.Value.Equals(foo)) .GroupBy(sl=>sl.bar) .ToList(); // <– pull … Read more

## [Solved] What code is faster? [closed]

None! They are both the same code. They are written differently, but take the exact same instructions and comparisons to achieve the result, therefore, they are the same. So, none of them is faster than the other. 2 solved What code is faster? [closed]

## [Solved] In plain C, without using strlen or any library function that uses strlen, how do you find whether one string is contained in another?

Removing the variable flag is deceptively easy by the way, as the only cases (using your algorithm as shown) where your function should return true is if either s1 is empty or the condition !*c is true. In all other cases it should return false. So your function, without any other modifications, could easily be … Read more

## [Solved] How to save coordinates/AXIS (x;y) for the array of 100 elements?

enter image description here Int16: 2 bytes Int32 and int: 4 bytes Int64 : 8 bytes So Int = Int 32 by default , and for example if you’re using 100 x 2 (for X and Y axis) x 32 (bytes) = 6400 bytes. However if you’re using array of Int’s , you waste a … Read more

## [Solved] Optimize Javascript code [closed]

You could use a JQuery function called toggleScript, that will make your code shorter. Also it would be better to call all your variables not only num1 and num2 in order to make your code more readable. When you saved an element into a variable – you don’t have to call \${} one more time, … Read more

## [Solved] Optimization of java code for reducing complexity [closed]

The big O complexity of the algorithm is O(N) where N is the array size. You cannot improve on that … for the arguments provided and producing the same output. There are some things that can be done to improve efficiency though. Hint: look for a computation that is performed on each loop iteration that … Read more

## [Solved] How to loop an if statement with different values? [closed]

I was able to figure out something a little bit less messy by using an array, probably still not the best way of doing it but it’s the best that I could come up with. length_of_charts = int(input(“Enter how many songs you have in each of your weekly charts: “)) lengths = [3, 5, 10, … Read more

## [Solved] Pso based image enhacment [closed]

You only need to carefully read the section B. Proposed methodology. It says something like this: Now our aim is to find the best set of values for these four parameters which can produce the optimal result and to perform this work PSO is used. P number of particles are initialized, each with four parameters … Read more

## [Solved] Scrolling page is laggy [closed]

Check out YSlow; it may give you some useful performance-related advice. solved Scrolling page is laggy [closed]

## [Solved] How to reduce redundant coding in java?

I assume that the isHttps variable check is there for a reason(?) and therefore the second cast should actually be HttpURLConnection, meaning there is a typo in the question? If so the most methods used in the question are available in the parent class URLConnection without a cast, but not all. Fortunately HttpsURLConnection is a … Read more