Skip to main content
73 votes
Accepted

Using a different algorithm depending on the size of the input

Why don't we just use a different algorithm based on the size of the input? We do. Hybrid algorithms are used all the time. Why shouldn't/couldn't I make a function like this (written in pseudo-C#-...
Jörg W Mittag's user avatar
44 votes
Accepted

What do you call it when you change the Big O execution time of a function

It is typically called "performance optimization", but I would not call it "refactoring", since this term typically refers to changes in code which don't change its visible behaviour. And a change in ...
Doc Brown's user avatar
  • 210k
42 votes
Accepted

Time Complexity of Parallel.ForEach

Time complexity is not about how long an algorithm takes to solve, it is about how much longer it takes as the input grows. That is, even the most complex (in terms of time complexity) algorithms can ...
Vector Zita's user avatar
  • 2,472
40 votes
Accepted

What are the complexities of a binary search?

The full term for this is "Time Complexity" and you'll want to use that if you are searching. This is a core concept in computer science. I am not going to attempt to explain it in detail ...
JimmyJames's user avatar
  • 27.7k
30 votes
Accepted

Is there a term for over-complication of OOP?

The most frequent term I heard to describe such designs is overengineering. The original meaning of that word, however, is not related to software development, and outside of software development it ...
Doc Brown's user avatar
  • 210k
16 votes

How to prevent over-engineering from Developers?

Simple. Peer review. Think you can code better then me? Bring it! Show me your simple style. Wow me with how easy it is to adapt as requirements change. I'll marvel at how easy it is to understand....
candied_orange's user avatar
13 votes

What do you call it when you change the Big O execution time of a function

I don't think there is a standard term, a commonly used is optimizing though improving, or speeding up would also be correct making the clarification that you are talking about code changes and not ...
ichantz's user avatar
  • 368
13 votes

How to measure the complexity in practice in your large software project?

The standard, tried and tested way is to profile the code. You perform dynamic analysis of the running system to measure timings, memory usage etc. Then analyse the results to find performance ...
David Arno's user avatar
  • 39.4k
12 votes

Does the signature of a method create a dependency between the implementation of that method, and the code that invokes it?

To give your question more context, let us remember what Ousterhood is trying to explain in the section of the book. Let me cite the first sentence from the paragraph where you got your cite from: ...
Doc Brown's user avatar
  • 210k
11 votes
Accepted

Should I introduce tools even if I might not need them right now

Some design decisions cannot be easily undone. That's why they are made early. Despite the warnings about premature optimization, it's actually a good idea to make decent design decisions from the ...
Robert Harvey's user avatar
9 votes

Trying to understand P vs NP vs NP Complete vs NP Hard

I will try to give you less informal definition for the same. P problems : problems that can be solved in polynomial time. Contains problems which can be efficiently solvable. NP problem : problems ...
kanishk verma's user avatar
9 votes

inheritance and polymorphism decrease readability

Neither inheritance nor polymorphism decreases readability. Using any OOP concept for the wrong reasons does. Avoiding repeated code is not a good reason to use inheritance, you can do that by ...
Martin Maat's user avatar
  • 18.5k
9 votes

Using a different algorithm depending on the size of the input

I'm coming at this from an engineering rather than an academic answer. Two algorithms mean twice as much code to write, test, and maintain. It's also twice as much code which could potentially break. ...
Liath's user avatar
  • 3,436
8 votes
Accepted

How to keep track of growing catalog of business rules?

Requirements need to be documented. You are already attempting to do that, but requirements are often broken down into a number of categories: Business requirements — Things like "A blog post ...
Greg Burghardt's user avatar
8 votes

What are the complexities of a binary search?

The average time is smaller than the worst-case time, because the search can terminate early, but this manifests as a constant factor, and the runtime is in the same complexity class. Using a linear ...
Simon Richter's user avatar
7 votes
Accepted

Big-O notation and halting problems

If you had such a tool, you could run it on any algorithm to figure out what it's Big-O was. If it returns a value less than infinite, then apparently the algorithm halts within time proportional to ...
RemcoGerlich's user avatar
  • 3,320
7 votes
Accepted

how do you automate multiple reports requirements that are complex?

Programmatically transforming Excel sheets is not the way to go. I would review the whole procedure completely and use a database as data source for the reports. Either let the users enter the source ...
Olivier Jacot-Descombes's user avatar
7 votes

What do you call it when you change the Big O execution time of a function

As others have said, "optimizing" is the general term for improving the performance of an algorithm. However, optimizing often means improving constant factors. If I wanted to concisely but clearly ...
Derek Elkins left SE's user avatar
7 votes
Accepted

Am I allowed to simplify terms while calculating Big O?

Not only can you, it is in very definition of O-complexity. The O-complexity is not really as simple as most laymen programmers understand it. Simply said, the O is defined asymptotically. That ...
Euphoric's user avatar
  • 37.5k
7 votes

Big O Complexity when iterating in 3 dimensions

Personally I would put it as O(bx*by*bz). The reason being I assume that the parameters can all change arbitrarily to one another, for example you could get the following input: bx=30000, by=30, bz=40....
Sahil Tara's user avatar
7 votes
Accepted

Efficiency of different Processors and GPUs

Quote from Motorola, 1986, 68020 processor manual: “Estimating precise execution times is very difficult, even if you understand the processor completely”. That was a relatively primitive processor. ...
gnasher729's user avatar
6 votes

Can too much abstraction be bad?

One thing that hasn't been mentioned so far is the KISS principle and YAGNI: Keep it simple and stupid; You aren't gonna need it. Sometimes, there are very good reasons for abstractions: You are ...
Martin Thoma's user avatar
6 votes

Cyclomatic Complexity spread over non-reusable functions

Function Reuse First and formost, functions are a prinicple means of abstraction (SICP) not necessarily a means of reuse. The main problem within software engineering is tackling complexity in the ...
backscattered's user avatar
6 votes
Accepted

How to measure the complexity in practice in your large software project?

Large software projects consist of many different components, and not all of them are typically a bottleneck. Quite the opposite: for almost any program have seen in my life where low performance was ...
Doc Brown's user avatar
  • 210k
6 votes
Accepted

Ahead-of-time compilation to native machine code of dynamically typed languages

Actually, it is easy to compile python to native machine code, in fact the Cython compiler can do it. However, the Cython compiler converts code like: A = B + C Into something like the following C ...
Winston Ewert's user avatar
6 votes
Accepted

Using dedicated functions for opposites/inverse

Don’t not avoid negatives. Sure the cpu doesn’t mind them but humans suck at parsing them. However, the idea that every function should automatically have some complementary function is silly over ...
candied_orange's user avatar
6 votes

Using dedicated functions for opposites/inverse

bool IsLate() { return (Now > DueDate); } What's the complement method here? IsEarly? IsNotLate? What if DueDate is undefined or null (depending on the language)? Are you going with this ...
catfood's user avatar
  • 1,615
6 votes

What are the complexities of a binary search?

The data in this table is not telling you how long a search takes. Its telling you how the time and storage may scale with the amount of data being searched. Lets take a real world example. Suppose ...
Stilez's user avatar
  • 507
6 votes
Accepted

Reducing Cognitive Complexity of Single-Responsibility "Arrow-Code"

According to your own comment, you do not build the result based on parameters but you rather mapped specific parameter combinations to some constant. So why not use some ParameterTuple=>Constant ...
Matthias's user avatar
6 votes
Accepted

fastest way to find number of smaller elements to the right of an array

Your reasoning seems correct. Making n iterations over an O(n) operation means O(n²) total complexity in general. Whether the insertion actually has O(n) time complexity depends on the data ...
amon's user avatar
  • 135k

Only top scored, non community-wiki answers of a minimum length are eligible