Questions tagged [theory]
Programming-language-agnostic Questions that focus on the theoretical aspects rather than the actual implementations.
1,805
questions
0
votes
0
answers
18
views
Backup many variables to file, what's the standard way?
This is not a language specific question but more of a programming theory one.
The problem is as follows:
Many (100s) of variables should be easily accessible in the program. This means by name, ...
-2
votes
0
answers
13
views
Is there an example of code that works in different languages, giving different results? [closed]
Maybe I should post it in Code Golf, but then, I don't know how to make a Code Golf task out of it.
I am interested in an example of code which runs, without any modifications, in two different ...
-1
votes
1
answer
23
views
Designing an "Events" Table with Multiple Table References in a Data Model [closed]
Although the original problem was presented to me as an MSSQL database implementation, what I'm discussing here is a general perspective, not specific details.
Let's consider that I have three base ...
0
votes
1
answer
26
views
Some help realizing the flow of code operations in react or web rendering in general
Say I'm writing a simple button in react. The button will display some text onclick and remove it afterwards:
export default function Button(){
const [isShown, setIsShown] = React.useState(false);
...
0
votes
0
answers
10
views
xUnit Theory with list of objects
I am trying to use xUnit Theory to complete a unit test under different scenarios
I have function that returns the 1st instance of an object that meets a certain criteria.
public MyObject ...
0
votes
0
answers
19
views
Static analysis to eliminate data dependencies
I would like to learn better about static code optimization algorithms, specifically eliminating the data dependency of modern compilers.Unfortunately I can't find suitable literature, can someone ...
-1
votes
1
answer
44
views
How are extremely large numbers handled?
How are extremely large numbers handled in video games? Cookie Clicker, for an example, the numbers can get as large as 1 duodecillion (39 zeroes - 1,000,000,000,000,000,000,000,000,000,000,000,000,...
0
votes
0
answers
41
views
Is it possible to access the DOM of a chrome extension (like the internal Chrome PDF viewer) through my own extension?
Basically, I wanted to make a Chrome extension that bookmarks my PDF. Yeah, I know someone already made it (with the limited API #page), but I wanted to make my own to learn. I was thinking this was ...
0
votes
0
answers
16
views
Ned help drawing a dfa from this hypothesis?
This DFA accepts any string over the alphabet {a, b} where the number of 'b's, if present, is even. An example of strings it accept:
Accepted:
a
aa
bb
aaa
abb
bab
bba
aaa
abb
bab
bba
aaaa
aaab
aabab
...
0
votes
0
answers
25
views
how transformer model encoder out put from fcn to decoder and then how things are done at decoder
I have read many articles about transformer model, they all focus on encoder side but no one explain how the output from fully connected network in encoder is processed at the decoder side. I need ...
-1
votes
1
answer
56
views
Why is the accuracy of the training set lower than that of the verification set, and this does not seem to be an overfitting?
At the end of the training for picture classification problems, the accuracy of the training set is 10% lower than that of the verification set, and the loss of the training set is 0.2 higher than ...
0
votes
1
answer
36
views
Theory of Computation: How to determine what language a DFA accepts
dfa
So I have an assignment to find out which language this dfa accepts.
I found many different words that the DFA accepts for example:
w1=0
w2=101
w3=1111
w4=100011
w5=11001
So my problem is that I ...
-2
votes
2
answers
112
views
An algorithm that creates regular expressions
Is there an algorithm that takes a list of strings and returns the shortest regex true only for those strings?
I'll be a bit specific. I have a list of arbitrary strings that I want to filter (allow ...
0
votes
0
answers
8
views
theoretic difference between shallow copies and occurrences?
Suppose I have:
a = MyClass()
my_list = [a,[a,[a]]]
From a theoretical point of view, we should say that my_list[1][1][0], my_list[1][0] and my_list[0] are 'shallow copies' or just 'occurrences' of ...
0
votes
1
answer
19
views
what is the complexity of the summation of n vs the collapsed version of the same series?
so the summation from n to k of n can be coded as
total = 0
for i in range(0,k):
total += i
return total
but that can also be simplified to
return (k*(k+1))/2
but is that really a faster way to ...
4
votes
1
answer
122
views
Exception handling in lambda calculus and functional programming
Is there a way to model exception handling in lambda calculus?
I'm asking this because it is very common to see multiple ways in handling exception states in procedural languages and derivative ...
0
votes
0
answers
45
views
How to make win prob. XGBoost model sum to 100%?
So I am building a football win probability model using tidymodels and XGBoost in R. It is using box score averages (yards, pts., etc.) by each team entering that game -- to mimic what would be ...
0
votes
1
answer
56
views
why is php not looking for names along the namespace hierarchy
<?php
namespace App {
function date(...$args) { echo 'Wow, my date'; }
class A {};
}
namespace App\Core {
echo date('r'); // Thu, 30 Mar 2023 07:34:30 +0000
$a = new A; // ...
0
votes
0
answers
27
views
Find the current market price of your market portfolio according to No Arbitrage condition with negative weighting
In Excel, I have the monthly stock price data for the past five years for Asset A and Asset B. I have calculated the monthly returns, mean returns, variances, and standard deviations for both stocks ...
0
votes
2
answers
64
views
Dynamic Programming with variable dimensions
Resently I encountered this problem:
Given a set of unique base integers and a target value, return the combination of base integers which add up to the target value. The returned combination has to ...
0
votes
0
answers
13
views
How do you construct a parsing table for a context free grammar without useless variables?
LL(1) Parsing
Consider the following context-free grammar without useless variables:
A -> CB
B -> BBCoo
B -> lambda
C -> c
The starting variable is A.
This task is about LL(1) parsing. ...
1
vote
1
answer
68
views
Mapping of theoretical consistency models to C++ memory ordering models
Wikipedia page for Consistency models list four consistency models for shared memory architecture as which require specific explicit synchronization by the programmers (in order from strongest to ...
0
votes
2
answers
80
views
Web scraping in Python without knowing the website structure
[Begginer]
This is a more theoretical question and the attempts made were in Python, a language in which I am more familiar. I got a task where I was supposed to receive multiple URLs (>200) and I ...
0
votes
1
answer
83
views
Need for both CV and train-test-split to assess a model's performance
This is a theoretical question.
Suppose I am working on a supervised learning model to predict employee attrition based on some categorical and numerical features. I have a small dataset of 500 ...
0
votes
0
answers
17
views
Foulkes Method for finding the components in a graph
What is Foulkes method for finding the components in a graph? Based on boolean adjacency matrix, I almost didnt find anything about it on the internet, can you please help by explaining its ...
0
votes
2
answers
63
views
What encoding system/mechanism is used by Python's binary read?
I need to read a file in binary format, which I do like this:
with open("tex.pdf", mode='br') as file:
fileContent = file.read()
for i in fileContent:
print(i,end=" ")
This ...
1
vote
1
answer
65
views
How does mysql execute a query using an index plus a filter
Given a table with columns a, b and c. Assume an index is created on columns a and b, how will MYSQL execute a query with a WHERE clause using criteria a, b and c.
Additional notes: Will MYSQL use an ...
0
votes
1
answer
49
views
Determine start date within time series
I hope you're doing well! I have a theoretical time-series analysis problem I hope that you can help me sort out.
To start, you'll find a reproducible example of my dataset below. Date is in a daily ...
1
vote
1
answer
502
views
Binary to unary turing machine
How to implement a turing machine that converts the input from binary to unary?
Example:
given input-$101
The output should be -1^5=11111
1
vote
1
answer
24
views
Pumping Lemma and Hierachy
I have a question involving the Pumping Lemma for Regular Languages and Pumping Lemma for Context-free Languages:
Is it possible that there's a language which doesn't meet the criteria for the pumping-...
-2
votes
1
answer
27
views
List all the keys that could have been the last key inserted in a Max heap
30
/ \
25 20
/ \ / \
22 18 17 16
/ \ / \ /\
21 13 15 5 2 1
Above is a Max-heap created following a sequence of inserting and removing operations.
If we ...
0
votes
1
answer
43
views
Implementing interface member with arguments that are more derived than in those in the interface declaration?
Is there a way to implement this so that I can use overloaded methods with more derived arguments? The overloaded methods aren't matching the signature as defined in the interface, even though they ...
0
votes
1
answer
50
views
What are the maximum number of duplicates for a given key in a B+-tree
Given a B+-tree with a branching factor of g and s being the number of keys contained, what would be the maximum number of duplicates allowed for a single key lets call this si? And how do we ...
0
votes
2
answers
331
views
Implementing 2fa in two steps
I did a lot of research on how to implement 2fa on my app.
My app will enforce every user to use 2fa (I will use OTP).
I think that in my app, (because every user will need to use 2fa, and I will use ...
1
vote
1
answer
27
views
How to prove that K is the range of inputs for O(n+K) time complexity for counting sort?
How would one prove that K is the range of inputs? How would it be the same as the maximum element? Using geeksforgeeks as an reference where it said K is the range of inputs: https://www....
0
votes
1
answer
187
views
Why the conversion of an NFA to DFA is useful?
Can someone tell me some reasons why the conversion of an NFA to DFA is useful?
Until now I have found the following reasons (I am not sure of them):
DFAs are faster than the NFAs
DFAs are easier to ...
0
votes
1
answer
112
views
What is the difference between abstraction and declarative programming?
Declarative programming seems to be achievable through abstraction. So what's the difference between abstraction and declarative programming?
[ My thought ]
I will call the person using the class &...
0
votes
0
answers
23
views
How do compilers handle records and unions? [duplicate]
My class was assigned a project to create a simple compiler that does basic operations over integers, I, however, have already figured a way of implementing pointers and would like to implement ...
0
votes
0
answers
49
views
Find the weakest precondition - Axiomatic Semantics
What exactly is the weakest precondition and how can I find it for a given expression?
Example:
Give the weakest precondition for:
i) WP[x = 5x;](x mod 10 = 0)
ii) WP[x = z - 2;] (x<2)
I tried:
i)...
0
votes
0
answers
52
views
How is a brute force crossword solver in P?
I'm currently learning theory of computation and the Poly Time Complexity class and describing a brute force algorithm that sucessfully fills out a 5x5 crossword puzzle. The way I describe the ...
0
votes
0
answers
71
views
General purpose data-structure transforms library
I have a ngrx-forms arrangement where a series of Clarity Forms produce a forms model in an NgRx data store. I'm now looking for an elegant and extensible way to take this forms model and turn it into ...
0
votes
0
answers
100
views
Dealing with duplicated rows labeled to different classes in a multi label multiclass problem
Say im working on a multiclass classification problem, I have rows of emails and I want to build a classifier that classifies into different classes i.e. [personal emails, work emails, spam, bills]. ...
0
votes
1
answer
33
views
Does the preprocessing of one algorithm change the conditions of the experiment?
As an example,
We have two algorithms that utilize the same dataset and the same train and test data:
1 - uses k-NN and returns the accuracy;
2 -applies preprocessing before k-NN and adds a few more ...
1
vote
2
answers
306
views
What is a Abstract Machine?
I don't quite get the definition and use case of an abstract machine and how its actually related to a compiler or interpreter
I googled what abstract machines were but understood very little out of ...
0
votes
1
answer
90
views
Is there a generalization of Voronoi Diagrams to curves in the plane? [closed]
I've studied Voronoi Diagrams and Fortune's Algorithm before. What I'm curious about is if there's a generalization of Voronoi diagrams where instead of the input being a set of points, it is instead ...
0
votes
0
answers
42
views
How to deal with HUGE (32GB+) multi-dimensional arrays?
I have a multi-dimensional array of strings (arbitrary length but generally no more than 5 or 6 characters) which needs to be random-read capable. Currently my issue is that I cannot create this array ...
0
votes
0
answers
35
views
Generating all "subtrees" of a given tree
I'm trying to make a tool like this one for the game satisfactory. What I'm currently trying to do is find some way of generating all possible combinations of recipes for a given item. As an example:
...
-3
votes
1
answer
42
views
Can you use self modifying techniques to change the scope of a statement, or position of a curly brace at runtime?
This question pertains to Java specifically.
We need to traverse a tree in preorder inorder and postorder. The issue is commas.
preorder is simple: just don't append a comma before the first node is ...
0
votes
0
answers
17
views
Looking for an overview of possible data operations. Literature Suggestions appreciated
Is there literature about the ways how to interact with Data? Especially is there a correlation between mathematical operators and Data Operators If yes, then how far does that go?
Like:
Plus,
Minus,
...
0
votes
1
answer
49
views
If objects are key value pairs, how can functions be objects in javascript
If all functions in JS are objects, and objects are just collections of key:value pairs - how do complex functions become objects? Say a function thats taking a param number, doing complex ...