Is there a name for the class of algorithms that are the most efficient for a particular task?

This would be analogous to the Kolmogorov Complexity of a string, except in this case, I’m interested in the algorithm that solves a given problem using the least number of steps.

We would therefore have to be able to show that any other algorithm is of the same order of complexity as the algorithm in question.

I’m asking because I’m working on a paper that makes use of this concept, and I was surprised when I realized that I’m not aware of any name for this concept, though I’ll concede I’m risking embarrassment if there is such a name, that I’m simply unaware of.

Is creating a joining/bridging table the most practical and efficient way of normalizing numerous M:M relationships in a database?

Let me start with an example:

Table users:

ID | Name --------- 1, Kirk 2, John 

Table class:

ID | Class ---------- 1, MATH 2, FIN 

Now, based on what I studied so far, in order to properly normalize this database, I’d create another table, a joining/bridging table:

Table class_enrollment:

UID | CID 1     1 1     2 2     1 2     2 

Well, it works fine in these kinds of examples.

But, what if my database has 35 or 50 M:M relationships? Is it really best to create yet another 35/50 joining tables?

What’s the most efficient way to add Dex to damage with an Elven Curved Blade?

I like the feat Dervish Dance, but it requires a scimitar. Although an Elven Curve Blade’s flavor text says it is “essentially a longer version of a scimitar”, I don’t believe that’s enough of a justification for allowing that feat with this weapon.

I am building a level 1 magus and am looking ahead at feat options. I expect I will take a high dex build and get into weapon finesse. I definitely intend to stay in the magus class, so I’m looking for a feat (or trait) to accomplish this goal.

Is there another way to gain a Dex bonus to attack damage via feats and the like?

What’s my most efficient use of spell slots to help my AC?

I’ve got a wizard with 11 Dex and I’m trying to figure out what my most efficient use of spell slots is to help me from getting hit.

We typically have 2-4 very difficult encounters per day and I want to balance my spell slot uses where I can provide as much firepower as needed. The monsters are generally higher CR as opposed to mobs. It’s usually approximately 1:1 in terms of PCs:NPCs and if it isn’t, it’s fairly close. Mob fights have been much less common.

Spending slots on defense with potentially diminishing returns due to the actual AC values is where I am looking to be most efficient.

Currently 5th level and have the following spells available:

1st level – mage armor and shield
2nd level – mirror image

Scenario A is casting mage armor in the morning and having AC 13 throughout the day. The difference between 10 and 13 seems minimal and that i’m likely going to get hit no matter what. But casting shield will boost to 18 which is legitimate. But then I’ve burned 2 spell slots on this method.

Scenario B is casting mirror image in a fight I think I’ll need it. Leave my AC at 10 and hope the images take the hits. Can still use shield if AC 15 will save me at some point.

I’m open to other scenarios as well, just trying to figure out the optimal strategy to get the best return on my spell slot usage for defense vs offense.

My offensive strategy

Most of my offensive spells are evocation and that’s where I’m mostly going to spending my spell slots. I’ll have a couple of control type spells that aren’t, but a lot of the instant-damage I do will be evocation.

While I try to stay away from enemies and not be in melee range, it’s going to happen at times. It’s those times (and ranged attacks), that I’m most concerned about keeping myself alive after.

Why are bottom-up selector matching algorithms more efficient?

Most implementations of CSS-like selectors (that is, patterns that may match paths in a tree) seem to use a bottom-up approach. That is, for each node in the tree, they check for a match against the rightmost element of the selector pattern. If the node matches, they search up its ancestors checking for a match against the second-to-rightmost element of the selector pattern, and so on.

My question is, why is this more efficient than starting from the top and working down (left-to-right in the selector pattern)? In both approaches it seems like you have to examine every path, and both approaches can benefit from short-circuiting.

Most efficient way to query a date range in Postgresql

I have a table with a timestamp with tz column. I want to perform a count / group by query for rows within a certain date range:

select count(1), url  from mytable  where viewed_at between '2019-01-01' and '2020-01-01'; 

viewed_at has a btree index applied, but when I view explain... it doesn’t appear to be using the index:

postgres=# explain select count(1), url from app_pageview where viewed_at < '2019-01-01' group by 2 order by 1 desc limit 10;                                                       QUERY PLAN                                                        -----------------------------------------------------------------------------------------------------------------------  Limit  (cost=2165636.99..2165637.02 rows=10 width=32)    ->  Sort  (cost=2165636.99..2165637.24 rows=101 width=32)          Sort Key: (count(1)) DESC          ->  Finalize GroupAggregate  (cost=2165609.22..2165634.81 rows=101 width=32)                Group Key: url                ->  Gather Merge  (cost=2165609.22..2165632.79 rows=202 width=32)                      Workers Planned: 2                      ->  Sort  (cost=2164609.20..2164609.45 rows=101 width=32)                            Sort Key: url                            ->  Partial HashAggregate  (cost=2164604.82..2164605.83 rows=101 width=32)                                  Group Key: url                                  ->  Parallel Seq Scan on app_pageview  (cost=0.00..2059295.33 rows=21061898 width=24)                                        Filter: (viewed_at < '2019-01-01 00:00:00+00'::timestamp with time zone)  JIT:    Functions: 13    Options: Inlining true, Optimization true, Expressions true, Deforming true (16 rows) 

I have generated ~100M rows of dummy data to test this out.

How can I make it more efficient?

Would storing the viewed_at field as two different fields be any use (date and time)

What is the most efficient way to select element specific to the H1

Let's say I'm stupid, but I really want to know the most efficient way to select this specific element:

<a href="/" title=""><h1>MySite</h1></a>
Code (markup):

Here's what I've got from the internet and it's still not specific to the H1 tag:

 a[title] {     color: red; } a[title]:hover {     color: orange;     text-decoration: none; } 
Code (markup):

I want this element as a unique one and style it differently.

Thank for your help,

What is a really efficient learning path for web development?

its my first interaction in stack exchange, and I’m fairly new to web development, so please take it easy on me if this is not a good question.

The thing is that I’m having a hard time learning web dev. As many of us do, I’m learning by myself using YouTube and Udemy courses. And yes, they show how things are done, but its very difficult to understand what is happening behind the scenes.

I don’t just want to write code, of course, I want to really understand how web development works, how the web works for developers, and what is going on behind the code I write.

And yes, I could go on studying and trying to figure it all out until I really understand it, but that will take a lot of time.

It would be so much better if I just know what’s the things I should study and how.

Anyways, I thing many of you will just not understand my question, but if you pretend that you are a beginner, you will understand what I mean.

I know how to code, I just wanna know how web development works. Please give me some light.

Before coding anything, what is the things I must know about the web and web dev?

Thank you. 🙂