instruction
stringlengths
35
29.1k
On a 2d plane, there is a large circle centered at $(0, 0)$ with a radius of $R_{{o}}$. It encloses $\sim 100$ or so smaller circles distributed randomly across the parent circle otherwise with known radii and positions with respect to the origin. (It is possible that some smaller sub-circles are partially or entirely ...
Run-Length Encoding is the simple form of lossless data compression in which compression in which runs (execution) of data are stored as a single data value and count rather than as the original run (execution). Now the definition is there but what's an intuitive way of thinking about this?
The number of parameters a function has (and thus the number of arguments it can take) is known as arity. What is the name for the number of values a function returns? I'm not asking for the "size" of a function's return values. A function returning a tuple returns a single, composite, value.
I have no cs background (algorithm and data structure), but need to find a data analysis related job since my major is math / statistics. However, (I am trying to avoid software engineering related jobs) no matter which position I applied, from finance to bioinformatics, almost every technical interview involves hash t...
On page 383, section 10.2. of the Algorithms for Planning as State Space Search chapter of the textbook Artificial Intelligence: A Modern Approach, the following passage appears: In this passage, the authors write that in the air cargo example they use there are $50^{10} \times 200^{50+10} \approx 10^{155}$ states. I...
I'm trying to improve my skills in analysis of algorithms. I think Sedgewick's "introduction to the analysis of algorithm" is a good, I'm reading carefully the first chapter, at least I'm trying. And the following is mentioned: The first, popularized by Aho, Hopcroft, and Ullman and Cormen, Leiserson, Rivest, and St...
In this figure x,y,z are the nodes on which rotation is performed and T1, T2, T3, T4 are the subtrees. I have understood how the rotation is working and have no trouble with that. The problem I am having is determining the final balance factor of nodes in the tree. In the first case before rotation, the balance of fac...
Background Good-Turing (GT) smoothing is used in language models to estimate the counts of words in the test set that have not been seen in the training set. In GT smoothing, $N_c$ is the count of things observed $c$ times (so a count of a count). As an example, the sentence "Sam I am I am Sam I do not eat" has unigra...
I'm currently preparing for an exam in compiler construction. The course is mainly about optimization in the backend of the compiler. For the optimization we have to do data flow analysis by hand. In one example I do not understand how gen and kill sets are determined. My solutions differ a lot although I stuck to the ...
There is a theorem that states that arithmetic is undecidable: i.e. $Th(\mathcal N)$, the set of all sentences in the standard arithmetic structure $\mathcal N=(\mathbb N,+,\cdot , 0,1)$ where the symbols are interpreted in the standard way, is undecidable. Godel's first incompleteness theorem states that there does ...
I came across this problem that asks you to implement a regular expression matcher with support for '.' and '*', where '.' Matches any single character. '*' Matches zero or more of the preceding element. isMatch("aa","a") → false isMatch("aa","aa") → true isMatch("aaa","aa") → false isMatch("aa", "a*") → true isMatch(...
We have given array of $n$ integers in the range $[1, k]$. We want to design algorithm that can modify the array and also find the length of the shortest subarray containing at least one of each integers in the range $[1,k]$. $k$ can go up to 50, but $n$ can be large number, up to 100000. I know that the offline versi...
Given a digraph $G$ and $f, g : E(G) \mapsto \mathbb{R}$, how would you find a cut $(X,\bar{X})$ with $s \in X$ and $t \in \bar{X}$ such that $\sum_{e \in \delta^+(X)}{f(e)} - \sum_{e \in \delta^-(X)}{g(e)}$ is minimized? $\delta^+(X)$ is the set of edges going out of $X$ and $\delta^-(X)$ is the set of edges going int...
Given a graph $G$, I want to find a shortest tour visiting each vertex. Different to the classical formulation of TSP, my tour needs to be divided into several subtours, each upper-bounded by a certain length. We can imagine that the salesman needs to return to the starting point to refill its car. The problem is to fi...
I have to build a simple publish-subscribe system in say C++ for example that can handle multiple subscriber. I have never done anything like that although I have made HTTP server and client, but not a publish subscriber system so I thought to ask few questions here first. I know I am reinventing the wheel but I need ...
Given an directed acyclic AND-OR graph, where each non-terminal nodes are labelled as either AND or OR. The terminal nodes are the nodes which have no outgoing edges. Children of a node are the vertices all the outgoing edges of the node points to. A solution graph for a node $S$ on an AND-OR graph $G$ is defined as a ...
I have the phrase "abracadabra" and I want to encode it through the Huffman method. I first took the frequencies of each letters; $$a=5$$ $$b=3$$ $$c=1$$ $$d=2$$ $$r=2$$ But I'm not sure as to how the diagram should look like. I made a few and some of them are correct. Also what determines the direction the branches ta...
I was reading up on finite automata and I came across an interesting fact near the end of the Wikipedia page. The classic example of a simply described language that no DFA can recognize is bracket or Dyck language, i.e., the language that consists of properly paired brackets such as word "(()())". Intuitively, ...
Because os is a special kind of program so does that also mean a normal program can run without os ?
Wondering how to represent a map object such as the following mathematically: var foo = { a: 10, b: 'bar', c: true } You could say that it was a function like this: foo(x, y, z) where $x$ is an integer, $y$ is a string, and $z$ is a boolean. But the question then is how to say the names of the keys a, b, c. Som...
I have a directed graph, which can be cyclic, where each node contains a value. Nodes are not labeled, and different nodes can contain the same value. The outgoing edges of a node are ordered, or labeled, (1, 2, 3, ... N), where N is the number of outgoing edges from the node. (That is, it's a k-ary tree, if such a te...
We know that the halting problem $A_{TM}$ and the diagonal language K are mapping reducible to each other. Furthermore both are complete with respect to the mapping reduce relation. I would like to prove that any r.e. language is mapping reducible to K directly without reducing to $A_{TM}$. How can this be done?
I know that the answer is no but I'm not sure why. Here's where I started. We know that all data with length $n$ Bits and minimum $1$ Bit can be compressed, either lossless or lossy. But how do I continue? Why is it impossible to compress all the data without loss?
Wondering what algorithms look like for implementing a complex JOIN query handler. Taking a look at this paper Building Query Compilers they talk about Query Graphs and Join Trees and Cost Functions for determining how well join trees are when the engine figures out how to organize the steps in the query. What I'm part...
I'm doing some Automata Theory exercises through a book and I'm trying to solve the exercise below but I can't figure out how to solve it. Construct a regular expression that describe the following language given the alphabet $\Sigma = \{0, 1\}$, $$A = \{w \in \Sigma^ * : |w|_0 = |w|_1 \}\cup \Sigma^*\{00,11\}\Sigma^*....
The top two competing entropy coders at the moment are Arithmetic Coding (AC) and Asymmetrical Number Systems (ANS). A very interesting difference between the two is that AC is FIFO and ANS is LIFO. That is, in AC the first symbol you encode into the bitstream is also the first symbol you decode. However with ANS the l...
Working on some cs theory and solving a problem on computationally [=recursively] enumerable languages: A language $A\subseteq \{0,1\}^*$ is co-c.e. if and only if there is a decidable language $B\subseteq \{0,1\}^*$ such that, for all $x\in\{0,1\}^*$, $x\in A \Leftrightarrow (\forall w\in \{0,1\}^*) \langle x,w\r...
Calculating hashes for nodes in an acyclic graph is well known using a Merkle tree. With some simplifying assumptions, a simple algorithm will also calculate hashes for nodes in a cyclic graph... but it runs in quadratic time, making it impractical to use except for very small graphs. Is it possible to do better? Graph...
In a doubly-connected edge list (DCEL) data structure, each vertex v stores a pointer to one arbitrary half-edge, v.inc, which has v as its origin, that is, v.inc.origin == v. However, there may be multiple half-edges which have v as its origin. How do I access or iterate all half-edges which have v has their origin?
I have an example question from a textbook where it asks to prove that $\Sigma_k DTIME(2^{n^k}) \neq DSPACE(2^n)$. There isn't a solution provided in the textbook. I've been working with a solution involving padding but I haven't been able to come up with a solution. Any tips would be appreciated! Thanks in advance.
How do I calculate the time complexity of the following method? Would you please provide explanation? I know it's going to involve sqrt(n) * <something>. I Just don't know what that <something> is. public void timeComplexity(int[] arr){ int n = arr.length; int sqrt = (int) Math.sqrt(n+1); for(int i=2; i<sqr...
I'm implementing Parberry's algorithm for closed Knight's tour problem. Brief idea of the algorithm: split the board in $4$ parts, find the tour on them recursively then delete $1$ edge in each part and add $4$ edges that will connect each part with two adjacent parts. At the end of page 5 (of the pdf viewer) the aut...
Consider an undirected network $G = (V,E)$ in which edge $e$ $\in$ $E$ fails after (deterministic) time $t(e) > 0$. Network failure occurs at the first instant in which $G$ is no longer connected. Let $m = |E|$ and assume the values $\{t(e): e \in E\}$ are distinct. You wish to determine the instant $\tau$ at which th...
The time complexity of Fleury's algorithm is $O(|E|^2)$ because for each edge I have to check whether it is a bridge or not and that takes $O(|V|+|E|)$ time. But, instead of that if I store my bridges in a hash table by a traversal at the beginning and then print the Eulerian tour (checking for each bridge in $O(1)$ us...
I have a problem that is similar to the interval scheduling algorithm but it involves priorities. My data sets consist of the following data: Cars with the start and end time of parking, along with their one or more attributes (e.g. electric vehicle, motorcycle, handicapped). Parking spots along with zero or more attr...
Let us assume we have a program of size $k$ that solves any instance of SAT of size $N < n$ in $poly(n)$ time. For every input of size $N \geq n$ the program is allowed not to solve it. Then we might imagine an infinite sequence of programs of sizes $k_0 \leq k_1 \leq\ ...\ \leq k_i\leq\ ...$ which solves SAT up to the...
I am working on a mapping reduction problem. Define the union of two languages $L_1,L_2\subseteq\{0,1\}^*$ to be $L_1 \cup L_2 = \{x0\mid x \in L_1\} \cup \{y1\mid y \in L_2\}$. I want to prove that $L_1 \le_m L_1 \cup L_2$. I was reading about the mapping reduction. According to mapping reductions, for any $w \in \Si...
Consider the following pseudocode: int divide(int l , int r){ if r - l > 3 then mid = (l + r) / 2 divide(l , mid) divide(mid + 1, r) return merge(l, mid, r) else return bruteforce_solution(l, r) } If merge function takes $O(n^2)$ time, then total complexity can be found ...
How we compute the computation complexity of an exponential function like $a^x$ where $a,x \in \mathbb{Z}$ with $|a|=l$ bits and $|x|=m$ bits? Can anyone please explain using big notation?
From R.Sutton's book, the eligibility trace update rule is: $$ E_t(s)\leftarrow\gamma~\lambda~ E_{t-1}(s)+\mathbb{1}(S_t=s) $$ I wonder why do we need both $\gamma$ and $\lambda$ to assign credit to most recent states.
I've been reading about count-min sketch and I'm interested in the performance of this data structure when doing conservative updates. To my understanding from the Wikipedia article, conservative updating means that when you see an item, instead of incrementing all the counters you only increment the counter(s) that ha...
I need to proof if that it's true or not. $ (G^R)^* = (G^*)^R $ If $G$ is a CFG and $ G = \langle V, \Sigma, \delta, S \rangle $ where $ V $ = Set of Variables or Non-Terminal Symbols $ \Sigma $ = Set of Terminal Symbols $ \delta $ = Set of Production Rules $ S $ = Start Symbol By def. $$ G^R = \langle V \ ,\ \S...
It is well known that the problem of counting the satisfying assignments of SAT, namely the problem #SAT, is #P-complete. It is also suspected (somewhat less widely) that even deciding SAT should take time $2^{n-o(n)}$ according to the strong exponential time hypothesis. I was wondering if there are any hardness resu...
Consider a standard enumeration of Turing machines ($T_0, T_1, T_2$, ...). Then, let language A be defined as $A = \{n \in\mathbb N | T_n(\lambda) \downarrow\}$. I need to reduce it to the halting problem (let's call it $K$). So, I want $K \leq_m A$ (mapping reduction). I know that mapping reduction is based on the ide...
Let $T=(\mathcal{V},\mathcal{E})$ be an udirected acyclic graph and $|\mathcal{V}|=n$. Let $\mathcal{V'}$ be $\mathcal{V'}\subset \mathcal{V}$ where $|\mathcal{V'}|=2m\leq n$. There are $2m \choose 2$ pairs of nodes in the set $\mathcal{V'}$. For each pair of nodes $(w,w')$ in the set $\mathcal{V'}$, there is a unique ...
Converting the following NFA to Regular Expression. Quick question: Do I have to add a new initial state as Q1 is accepting an incoming edge with 0+1 from itself? Method used: State elimination method
I've search on Google but still don't understand. I've read about it into arm book, but they don't define it. Could you explain me what is it, where is it used, what's the point to have it and, if you can, its used into arm chips. Thanks.
I am preparing class materials for the applied statistics class for Ph.D. students and want to present them with examples of bad statistics in different fields of computer science. I am especially interested in the examples form the sub-fields represented in our department: CHI MIS (with focus on qualitative methods a...
I want to calculate the Entropy of the phrase "Eile mit Weile". I found the probability of each letter as the following $$P(e)=\frac{4}{12}$$ $$P(i)=\frac{3}{12}$$ $$P(l)=\frac{2}{12}$$ $$P(m)=\frac{1}{12}$$ $$P(t)=\frac{1}{12}$$ $$P(w)=\frac{1}{12}$$ Then I used the formula for entropy $$H(p_1,...,p_k)=-\sum_{i=1}^{k...
Firstly, I am trying to understand the meaning of LCA in DAG. I read a definition somewhere-"Define the height of a vertex v in a DAG to be the length of the longest path from root to v. Among the vertices that are ancestors of both v and w, the one with the greatest height is an LCA of v and w." In a graph like this 1...
How can I prove that if $T(n) = \sqrt{n}T(\sqrt{n}) + n$ then $T(n) = \Theta(n\log\log n)$? I tried to define $T(n)$ by $G(n)$, prove about $G(n)$, and then to return to $T(n)$, but it's not working..
The number of computations of an algorithm is $n'm\sum_{x=0}^{n'-m} 1/(m+x)$. What is the complexity of the algorithm ? Thanx for help.
I'm wondering if its possible to express the time complexity of an algorithm that relies on convergence using Big $O$ notation. Is it fair to say that we can't reason about an algorithm's scalability based on input size if we also have to rely on convergence - unless there's some facet of the algorithm's manner of conv...
Why does the circuit value problem run in log space on an alternating Turing machine? It is claimed to be so in my university's lecture notes. Also, it is claimed that monotone circuit value problem has the same space complexity on an alternating Turing machine. I think it requires at least linear space because it need...
You are given an unsorted array of all the integers in the range $0$ to $n = 2^k -1$ except for one integer, called the missing number. Find a divide and conquer algorithm to find the missing number in time $O(n)$. If you wish, you may use the fact that an algorithm $median(A)$ exists that can find the median ...
Historically, what has happened is the following: There is a "mechanical" structure, most importantly, arithmetic, which operates according to a set of well-defined rules that a stupid computer can easily follow. e.g. a computer can easily calculate $5349\cdot 5345=...$ There is a "mechanical" proof-system, most impor...
Does there exist a computable function $f:\mathbb{N}\rightarrow \mathbb{Q}$ such that: For all $t\in\mathbb{N}: 0\le f(t) < X$ $\lim\limits_{t\rightarrow\infty} f(t) = X$ Where $X$ is an uncomputable real number. The only reference to this question I have found was the answer to this question: https://math.stackexch...
So in the book that I'm reading it says at a time only the data of one register can be on the data bus and only one register can load the data. the first part i get but what about the second part? why can't we just turn on the load parameter for both of the registers at the same time? I'm studying for computer architec...
Could a standardized ternary (base-3) system be more efficient than the binary (base-2) system? Binary is efficient for processing using logic gates, but can be bulky when using for file storage or file transfer. I am interested in the feasibility of a ternary system both for file storage, file transfer, and computatio...
I took an extremely interesting intro to CE course, learning about transistors/memory/logic gates up to LC-3 assembly. Something that was really interesting to me was learning about how a processor's frequency is its speed, determined by the clock signal (if anyone can point to a link of how a clock cycle is made/works...
I've stumbled on this definition on Wikipedia, and I can't figure out why. I could probably start the demonstration by saying that, with $n$ bits, you can create $2^n$ possible different numbers, so $2^n=x$. If I rewrite the expression with logarithms, I find $\log_2x = n$, so the base-2-log of the total number of poss...
In this book there is a lot of mention of "pushing x down". For example: Pushing NOT operations down and eliminating them NOT operations need to be pushed downwards for correctness reasons. Attention has to be paid to the IS NOT NULL and IS NULL predicates. XXX complete set of rules go into some table ... Typical step...
I have a set of N integers that I want to partition into m subsets. I want these subsets to be well-balanced wrt some criterion say that minimize the max difference between the size of all subsets. But I am not really interested in THE optimal solution. I am interested in a FAST algorithm that generates some good parti...
This is a problem that involves matching students with various skills into groups so that there are as many groups as possible while ensuring that each group has certain skills present. I've reduced it to this: Given a set of $N$ people with $S$ skills where $A_{n,s}$ is the quantity of skill $s$ that person $n$ has. ...
Recursive definition for travelling salesman problem can be written like this :- T(i,S)=min((i,j)+T(j,S-{j})) for all j belonging to S, when S is not equal to NULL T(i,S)=(i,S) when S is equal to NULL Here, T(i,S) denotes the tour starting from i covering all vertices in Subset S and then travel back to i. I built the...
When we consider multi-tape Turing machines, we can assume that each tape is accessed with a separate head and each head can move independently of the other heads. But can we assume that each tape can be in its own state independently of the other tapes (for example, tape 1 in state A, tape 2 in state F, tape 3 in stat...
We have given weighted undirected connected graph with $n$ nodes and $n$ edges, we want to find the longest path in it. Note that the path should be in each node at most once. Since the graph has $n$ edges clearly it has exactly 1 cycle, and removing 1 edge from this cycle will lead us to a tree. Clearly we can iterate...
So generally speaking, when we implement the graph using linked list, do we store the degree of each edge too? I'm asking this because if a question in my exam stated that we implemented this graph using linked list, do i assume we can access the degree of each edge in o(1) or not? this matters because it effects the t...
I found a question while studying compilers :- Given a grammar E->E+E/E×E/number The above grammar is fed to a YACC with semantic rules for parsing. What will be the action of the YACC. 1) it detects recursion and eliminates recursion. 2) it detects RR conflict and resolves 3) it detects SR conflict and resolves in f...
I have found dynamic solution for Bitonic tour but I could not find any greedy approach for this problem. Is it possible to solve it in a greedy manner?
Two given languages $L_1$ and $L_2$ are called recursively separable iff there exists a recursive languge $R$ such that $L_1 \subseteq R$ and $L_2 \cap R = \emptyset$. Now consider first order logic, and some finite axiomatisation of $\mathbb N$ in it (surely this is way to weak, as we have no induction). Then we have ...
So, there can be different types of edges in a directed graph while solving the max flow problem. There can be reverse edges, multiple edges and self loops. What is the significance of self loops in it? How is it related to flow in the graph? Let there be a graph like this 1->2->3 and 2 has a self loop. So, can I int...
We are given a set of points $S$. Given $K$ is any subset of size $k$, how do I efficiently find the following: $\mathop{\arg\max}\limits_K$ $\sum_{x_i\in K} \mathop{\min}\limits_{x_j \in K, x_j \ne x_i}d(x_i,x_j)$
I have a binary variable $y\ \epsilon\ \{0,1\} $ and a real $x$ which has the following boundaries $-100\leq\ x \leq\ 100$. How can I reformulate the following statement: $$ y = \begin{cases} 0 & \text{if $ x< 0 $ }\\ 1 & \text{if $x \geq0$}\\ \end{cases} $$ Your help would be much appreciated.
Integer Linear Programming (ILP) is NP-complete. However, there are special instances that can be solved in polynomial time. I am curious about the following integer program (IP) with equations and inequalities in $y_i, c_i, x \in \mathbb Z$ of the following form: $$\begin{align*} A_i + B_i y_i+ c_i &= x \\ c_i^2 &> 0\...
I am currently taking a graduate course about Image Processing in electrical engineering and while this question doesn't particularly relate to the class itself but rather some concepts in the algorithms we utilize. One of the algorithms that we utilized was called, "Image Correlation" in order to find a "match" from u...
If I'm given a graph $G$ with the set of vertices $V$ and a set $B \subseteq V$, can I remove all the vertices $\in B$ from $G$, as well as all edges that connect any other vertex to a vertex $\in B$ in linear time ($O(V + E)$)? It can be assumed that checking if a vertex $\in B$ is $O(1)$. My thoughts on this are- If ...
According to A modern eye on ML type inference Furthermore, for some unknown reason, W appears to have become more popular than J, even though the latter is viewed—with reason!—by Milner as a simplification of the former. Jones’ presentation of type inference for Haskell [21] does rest upon an implementatio...
Recall A'= $\{x \mid \phi^A_x(x)$ halts and accepts $\}$ In this article, a proof that A' not computable in A is given: http://www.math.uchicago.edu/~may/VIGRE/VIGRE2006/PAPERS/Flood.pdf He constructs the function f(x)= $\phi_x^A(x)$ +1 if x in A and 0 if x not in A Shouldn't it be f(x)= $\phi_x^A(x)$ +1 if x in A' and...
I understand that NC0 circuits have a constant depth and bounded gate fan-in of two, but I'm struggling how to understand why the language is in NC0 iff there is a constant c such that for every n, there is a set c variables that determine it's membership.
To prove that K= $\{x \mid \phi_x(x)$ halts and accepts$\}$ is r.e.: we can recognize K by: for any x, we simply run x on machine $\phi_x$ and accept if the machine accpets else reject and that's it... In general, for proving a set is r.e. , we must recognize every element IN the set? How do we deal with functions lik...
I know that Huffman coding produces an optimal solution, but are there any more solutions using the same number of bits (not including just flipping the ones and zeros or switching the encoding for letters which appear with the same frequency).
According to this answer, $\sum_{k=1}^\infty \frac{1}{k^2 H_k}$ is approximately 1.33275. How?
How to sort a stack using bubble sort? Can use another stack if necessary.
We know that the halting problem $A_{TM}$= $\{(e,x) \mid M_e(x)$ accepts$\}$ and the diagonal language K= $\{e \mid M_e(e)$ accepts$\}$ are mapping reducible to each other. Recall that A mapping reducible to B means there exists a computable function from A to B s.t. for all x in A, x in A iff f(x) in B. Furthermore bo...
I need to find a way to iterate over all sequences of words in two letters $A,B$ avoiding the sequence $A^2 = AA$ and $B^3 = BBB$. First of all, what is the regular expression for such a thing? I need a way of iterating over all such possible words. I tried this one: $$ w \mapsto \{ wA, wB, wBB\} $$ however, if I run...
Similar to the theory of hardness of approximation for (offline) approximation algorithms, has there been any work done on proving hardness guarantees for online algorithms? Theoretical lower bounds on competitive ratio conditioned on hardness of some other problem?
I am just trying to visualize how computers work with Virtual Memory/Address. Assume there is a program on the disk that looks like this: a b c d e f g h i j k l m n o p where the a .. p are instructions and their address is from 0 to 15. What happens inside the CPU while executing this program? Assume that the operati...
Take any operation that is done by any type of computer (e.g. a cpu on a modern laptop), which doesn't use any type of temporary memory storage. I.e. this computer operation computes a function $f(x)=y$, without using any form of memory storage. Q1: Is it possible for any arbitrary such $f$ to be represented by a form...
Suppose I have a sequence: $$n = \prod_{i=1}^{r(n)} p_i^{d_i}$$ for some primes $p_1 < p_2 < \dots < p_{r(n)}$, and each $d_i \geq 1$ an integer. The function $r(n)$ denotes the number of distinct primes divisor of $n$. I'm trying to show $r(n) = O(\log n)$. What I have tried: I think I can establish an upper bound on ...
I am new to Machine Learning. Suppose a training set of positive (square) and negative (circle) points is given like: Obviously there would be no nice linear separator of positive and negative points. So assume there exist a transformation for (x1,x2) points as: y1 = (x1-5)^2, y2 = (x2-5)^2 in (y1,y2) space. We will t...
Primitive recursion is recursion where totality can be proved because there is a single natural number parameter that strictly decreases in every recursive call. Put another way, the recursion terminates because there is a parameter with order type $\omega$ that strictly decreases under the ordering in each call. The A...
I am developing a neural network that is trained using a genetic algorithm. The neural network is a multilayer perceptron using $\tanh$ as its activation function. Currently, the genotype of the neural network is by its weights. I used the method of making a connectivity matrix and linearizing it according to this pap...
First of all, note that I'll have to explain my thoughts in a layman's terms. There are so many high-level programming languages out there that compete with each other. This means we have to build the same functionality over and over again in each language. Therefore, I wonder the following: Why isn't there one languag...
For an Instruction fetch cycle we have the flowing registers in a CPU. Memory Address Register (MAR) Memory Buffer Register (MBR) Program Counter (PC) Instruction Register (IR): Accumulator Register: Stack Control Register: Flag Register: Out of these I have come to know that PC and IR registers belong to control uni...
How do we test the following function? bits(bitstring, i, j) which returns a copy of the substring from i to j of some bitstring. Consider the fixed 32-bit value: bitstring=0x12345678 We could manually pre-determine the correct return values for ~500 different combinations of i and j. But this only covers 0x12345678. T...
I am trying to implement a hash table for string keys as part of a university project. I was able to make a basic, working implementation without major issues. I am now trying to optimize the thing to go closer to a O(1) expected lookup / insert time. I was reading up on hash functions and in particular, the MAD method...
I'm trying to understand the time complexity of an example algorithm. My conclusion was O(n^2) but this was considered wrong. The algorithm is as follows: input: data: array of sorted n integers input: n: size of data input: c:a positive integer between 1 and n-1 delta = Array(n-1) map=HashMap() for I =1 to n-1 do: d...
I am going through the book "Knowledge Representation and Reasoning" by Brachman and Levesque. So an interpretation $ F $ is defined as a pair $ \langle D,I \rangle $ mapping from a set of objects $ D$ called domain of the interpretation and $ I $ is a mapping called interpretation mapping from the non-logical symbols ...
I am confused as to how a 16-bit (or 32, 64) processor can store multiple adjacent bytes at once without supplying multiple addresses For example say we have (16-bit processor) 0xABCD starting at address 0x0000. For loading, the processor would just supply 0x0000 on the address bus and the way the bytes are laid out ph...