instruction
stringlengths
35
29.1k
Problem: There are $n$ points on a map, $p_1,..p_n$. There are two officers located initially at $(0,0)$ coordinate. They want to patrol all of these points with a minimum traveling (each officer separately patrol a point). The point $p_i$ must be visited before $p_j$ if $i< j$ I can write a backtracking algorithm to c...
I am currently reading about the Halting Problem in my course on the theory of computation and the following was given in my lecture slides Now my question is that if $d$ is the description of a Turing machine, what exactly is $d$ from a strictly mathematical point of view? The way that $d$ is written above seems to ...
An algorithm is requested to calculate all balanced binary trees which can be built with $N$ nodes, having exactly $L$ leaves. A balanced tree is a binary tree in which the difference between the heights of the left and right subtrees is at most 1, and the subtrees are themselves balanced. I tried to use dynamic progr...
I encountered this problem from game development which I will formulate in a more formal way: Given a sequence $A = a_1, a_2, \dots, a_m$ and a permutation of $\{1, \dots, n\}$, $B = b_1, b_2, \dots b_n$, find all $i$ such that for all $1 \leq j \leq n$, $a_{i + j}$ is the $b_j$th smallest element of $a_{i + 1}, a_{i ...
I would like to know where I can find challenging exercises that ask to prove the correctness of an algorithm. The invariant of most of the exercises I’ve found on the internet are quite easy (factorial, binomial coefficients...). That’s why I was wondering if there exist a book or some online ressources where I can fi...
For language $L = \{ x \in \{a,b\}^* \mid \#_a x = \#_b x \}$, I came up with the following CFG: $$S \rightarrow aSbS \mid bSaS \mid \varepsilon.$$ It can be easily shown that it is correct (quick example, for string $x = aabb$ we have these derivations: $S \rightarrow aSbS \rightarrow^* aaSbSb\varepsilon \rightarrow^*...
I am probably just missing the correct term for my problem to find the solution but here it goes: I have a set of tasks with a given duration and an interval for each task in which it has to be completed. I now need to find start times for the tasks, so that each tasks is completed within its interval no task overlap...
It seems impossible for me to find a pattern for integers $n$ such that $$n \equiv 1 \quad(\bmod 7)$$ in order to construct this DFA. Is there smart way to do it without a machine which has memory or completes operations? A hint would be greatly appreciated.
If we consider any smoothing technique like laplace or delta smoothing. Intuitively we can see that the we are stealing from sequences with non zero probablity and re distribute to sequences with zero probablity and there by it should be a probability distribution function. But how do we prove this mathematically say f...
Given $L=\{a^ib^jc^k | i\neq j \space and \space j=k\}$. Is this CFL? How do I write CFG for it or prove it with pumping lemma? Thanks.
Say we want to place n items on the real line. Let us denote the position of item i by $p_i$. We have interval constraints on the position $p_i$, i.e. we are given $l_i, r_i$ such that $l_i \le p_i \le r_i$. My problem is: given a specific item s, how do I compute the maximum gap possible to the right of s? By maximum ...
So from the above diagram, we can move either right or down. So a binary tree is built that way. It's written "If we had intermingled common nodes across different branches, we would have got a graph instead" I am unable to visualize how a graph can be formed out of this. Will it be a graph with only 2 columns? Please...
Can I reduce the find max (or find min) problem to the sort problem? Because if so, knowing the lower bound for find max is Ω(n) I can also infer that the lower bound for sorting is Ω(n) too? I'm confused with this spread of lower bounds and applicability of reductions.
I am trying to prove that given a DAG. There exists a valid topological ordering that has v in front of u iff there is no path from u to v. The proof is related to the fact that reverse DFS post visit order satisfies the condition of topological order. How do I construct a proof?
Consider the situation, when you're given M byte arrays of size N, and you need to check if all of them have unique content (so there are no two arrays that have the same sequence of bytes). What would be the best option to check this condition? From my point of view, there are several approaches available for this pro...
Let $C$ be an array with length $n$ (assume the elements are cities with some properties). We have some properties sorted by importance. For example, 1.area, 2.population size, .... We use the following algorithm to find the best city according to sorted properties: We choose the first property and examine each city. T...
Consider a system with a two-level paging scheme in which a regular memory access takes 150 nanoseconds, and servicing a page fault takes 8 milliseconds. An average instruction takes 100 nanoseconds of CPU time, and two memory accesses. The TLB hit ratio is 90%, and the page fault rate is one in every 10,000 instructio...
I have a problem. I want to know how to solve this in polynomial time (is it possible?). There are $n$ customers that must be served by single machine. For every customer $C_i$, it has a profit $P_i = a_it + b_i$ where $t$ is the finish time and $a_i<0$. Yes, the profit can be negative. For every customer $C_i$, it has...
Unlike traditional problems dealing with push and pop sequences of distinct numbers, I would like to know the procedure to determine the validity of the stack operations for sequences of non-distinct numbers. For example, Push : 1 2 1 2 2 2 1 Pop : 2 2 1 2 2 1 1 is a valid operation for stack. Any way to figure this ...
Past few days I've been struggling with floating point number exercises, trying to learn how they work and what are their limitations. The exercise I've encountered today is as follows: The Euclidean norm of an n-dimensional vector $x$ with components $x_{1}...x_{n}$ is defined by: $$||x||_{2}=\left(\sum_{i=1}^{n} x...
What are some examples of when to use preorder/postorder practically? When does it make more sense than in-order?
I need help with the following practice problem on network flow: A cohort of $k$ spies resident in a certain country needs escape routes in case of emergency. They will be travelling using the railway system which we can think of as a directed graph $G = (V, E)$ with $V$ being the cities. Each spy $i$ has a startin...
For the following algorithm, $X\leftarrow \{(i, n - i) | i = 1, ..., n- 1\}$ while $\max_{(a, b)\in X}b > 0$ do $\quad X \leftarrow \{(|a - b|, \min\{a, b\})|(a, b) \in X\}$ return $\max_{(a, b)\in X}a$ show that the algorithm does not run in $o(n \log ^k n)$ for any constant $k$. Summary: the algorithm uses the Eule...
I am following a course on complexity theory where languages are a part of the course. There is a proof that no matter how hard I try to understand, it is till so complex that I cannot make it to half of the proof. Namely, the proof of the statement that the intersection of a CFL and a regular language is again CFL. Th...
Please consider the following question given in a booklet: I have read about databases from Database System Concepts - by Henry F. Korth, but never saw an instance where we could do a NULL comparison in relational algebra queries - unlike SQL queries. (C) is given the correct option, but my question is: Is the stateme...
Is it possible to solve the max sub-array product problem using divide and conquer? Given an integer array numbers, find the contiguous sub-array within an array (containing at least one number) which has the largest product. Example 1: Input: [2,3,-2,4] Output: 6 Explanation: [2,3] has the largest product 6.
Let $(Q,\Sigma,\delta, q_0, F)$ be a finite automaton, does $$ (q_1a+q_2b)c=q_1ac+q_2bc $$ hold for any $q_1,q_2\in Q$ and $a,b,c\in \Sigma$? Here $Sa=\{\delta(q, a)\mid q\in S\}$ and $qa=\{q\}a$ for any $S\subseteq Q$, $q\in Q$ and $a\in\Sigma$. The operation "$+$" means set union.
I solved a problem similar to the knapsack problem. There are two packages with a capacity of $P$ on a production line. We want to put $N$ items in them with the weights $w_1,...w_n$ in a pre-defined order (the best order). We can put an item in the package 1 or the package 2 or close one package and replace it with a ...
I am reading William Stallings operating system book which gives this pseudo-Code for disabling interrupt to achieve Mutual Exclusion while (true) { /* disable interrupts */; /* critical section */; /* enable interrupts */; /* remainder */; } But I don't get why there is a While loop in the code which is true thi...
I know that RAID-5 consists of block-level striping across multiple disks, but using an additional parity-check block on each disk .. and that at least two disks are required for striping. And it's obvious that each parity block is specific to each disk it belongs to (and so there is no need for allocating an additiona...
Given rank deficient matrix $A$, I want to randomly construct vectors $\vec{x}$ such that: $0 \le x_{j} \le 1$ $0 \le b_{j} \le 1$ where $\vec{b} = A\vec{x}$ Matrix $A$ is about 10 x 15. I want to generate $10^{5}$ $\vec{x}$ as an initial guess in each iteration of a solver. Below is my attempts. Least square and re...
Hi everyone and first of all thank you for been reading. I'm a little confused about data hazard dependences when a "Store" instruction is followed by a "Load" instruction. (Assume that we're working with a 5 stages pipeline processor withouth data forwading paths) So if I have the following code now: Store R3,R8,of...
I am trying to use a genetic algorithm to solve a problem. However, I find it difficult to represent the chromosomes in my problem. In the problem, I have two categories of parameters, and each gene inside the chromosome has a specific range of values. For example, Category $A$ has chromosome $X$ that has the following...
I am looking for references to efficient algorithms that solve knapsack problem where all profits are equal. More formal definition of the problem from a Wikipedia article on KPs: If all the profits are 1, we will try to maximize the number of items which would not exceed the knapsack capacity: maximize $\sum_{j=0}^n ...
Neural networks in machine learning are inherently a continuous model of computation. Yet we use digital logic circuits with floating point numbers to "emulate" this continuity. I am wondering: is there a possiblity to develop an analog-based ASIC for neural networks, which might fit them well due to their inherent co...
The books I'm reading on complexity theory primarily are about complexity of decision problems by Turing machines. I'm interested in computational complexity of circuits, both boolean and continuous circuits (I'm not sure to what extent there is a complexity theory of continuous circuits). Do you know of a good introdu...
I'm reading a blog post on deep Q-learning, and it contrasts traditional lookup-table-based Q-learning with deep Q-learning: What I wonder about in this picture is: Why does the deep NN not also take a state and action as input? I assume that this has something to do with computational efficiency. Essentially, in th...
I know that similar questions have been answered several times, and based on the answers, I attempted a solution to my problem. But I simply do not get the right results. The problem is as follows. I wish to solve the following optimization: $max(ax_1)$ subject to $x_1 = |x_2-x_3|$ where $a$ can be both positive and ne...
Working with fixed size integer representations, use a number system with b-complement notation, base b = 9 and n = 4 digits. What is the smallest number that can be represented in this number system? State the number in decimal, and also express it in this number system. I assume that it will be 0888 for max, and 800...
Could the run-time of the Strassen's algorithm be improved by adding Memoization to it?
I've been struggling with this problem for quite a while now and every explanation I have managed to find doesn't seem to correctly solve it. Question Proving $L = \{a^nb^m \mid n, m≥0, n \neq m\}$ is not regular by use of Pumping Lemma. I know the correct way of prove with factorial or using closure. However today s...
Given a character array A of size n, compute the length of a longest sub-sequence S of A such that, S read backward is also a sub-sequence of A. Example: A = cabca the sub-sequence S = abc is the longest of such sub-sequences. reading S forward (abc): cabca reading S reverse (cba): cabca How to compute the length of su...
Could anyone briefly show me how the Longest Common Sub-sequence of two sequences is a special case of the Sequence Alignment problem? I cannot wrap my head around this. Thank you.
With locality sensitive hashing (specifically multi-probe hashing http://www.cs.princeton.edu/cass/papers/mplsh_vldb07.pdf) how are the guarantee of similarity returns made? Why are there multiple tables involved in the hash indexing? Wouldn't that make it LESS probable that an item hashed to a bucket is similar to ano...
I just started learning about linear programming in my class, and I'm having some trouble understanding the MST Formulation Integer Linear Programming (Cutset Formulation). This is the definition: An integer linear program that solves the minimum spanning tree problem is as follows: $$ \begin{align*} \text{Minimize} &...
This question is not meant to be too theoretical or nitpicky. I have experience programming, so I'm trying to get a better understanding of what it takes to get Turing-completeness by using my intuition about practical programming languages. Basically: What minimal elements of a language like Javascript do we need to h...
Maybe my question is a bad question, but if it is, I want to know eactly how it is a bad question. Suppose we have some Turing machien $M$ that takes as input a natural number $n$ in the form of a binary string, writes $n^2$ in binary on its output tape, and then halts. What is the type signature of this machine? Here...
If $D(n)$ is the internal path length (sum of the depths of all nodes) for some tree $T$ with $n$ nodes then we have the following recurrence relation: $$D(n)=D(i)+D(n-i-1)+N-1$$ where I simply taken an arbitrary tree with a left subtree containing $i$ nodes and the right subtree containing $n-i-1$ nodes. Correct me i...
I'm doing some practice questions on Big O notation and came across this question. What is the Big O order of function () = ^2 + log2() + log2(). Show your working. My answer is O(n^2) because it's the term with the highest degree. However, I'm not really sure how to show it. Am I right by saying that it has to be pro...
I want to get a better intuition for the curry howard isomorphism, and my intuition is mainly based on object oriented programming languages like JavaScript. So as an example, I am going to formalize the notion of "topological space" in a hypothetical object oriented programming language with dependent type theory and ...
In this wikipedia article, the following comment is made: Consider an arbitrary decision problem in the class NP. By definition each problem instance $x$ which are answered 'yes' have a certificate $y$ which serves as a proof for the 'yes' answer. Thus, the set of these tuples $(x,y)$ forms a relation. The complexity ...
I can easily make counter for consecutive numbers. But for patterns, described in below question, I'm quite unsure about my approach. Question - We want to design a synchronous counter that counts the sequence $0−1−0−2−0−3$ and then repeats. The minimum number of $J-K$ flip-flops required to implement this counter i...
What I have looked up into: here, here and here What I have learnt: What is an interaction net, its deduction & interaction rules, How deduction rules can be changed into interaction rules -- you "link" the two sides of one deduction rule, "magically" turn their arrows up and rearrange the bubbles, and then split them...
A many-one reduction of problem $A$ to problem $B$ is essentially a function that converts a problem instance in problem $A$ to an instance in $B$. This allows you to use a $B-$solver one time to solve this converted instance, in order to solve an $A$-instance. To show that $A$ is in NP-complete, people use reducibilli...
I am reading through the Girvan-Newman description, having come from the topic of "detecting communities in a complex system". What exactly is a community in this context and why is it useful for a network to know about it? In simpler terms, what's a real-life usage of this algorithm?
PS It isn't a homework problem.. (But the results seems to be working for me when I checked manually a couple of values of m and n) Let's say I have two FSM's(calling them A and B) A is the the machine for checking divisibility by any +ve number (calling it m) B is the the machine for checking divisibility by any +ve ...
Some textbook show that the grammar $G=(N,T,P,S)$ below belongs to context-senstive grammars: S->aSBC S->abc cB->Bc bG->bb where N={S,B}, T={a,b,c}. I am confused by the fact that the production rule cB->Bc cannot satisfy the definition of a CSG. So, why is the above grammar belongs to CSG?
I want to formalize Interval Newton Methods in Isabelle. As a research, I have the curiosity of whether there is anything done in the field. For that, I need to know what mathematical contents have been formalized in different proof assistants. For Isabelle, this is easy: just google the Archive of Formal Proofs. What...
I have seen a few proofs that the Blank Tape Halting Problem is undecideable, however I'd like to check if the following is a valid proof (and if it isn't why not) Proof: Suppose that the Blank Tape Halting problem is decideable, then there exists a universal turing machine $M$ that decides it. So given any turing mach...
Say I have an array of integers like so: [2,2,3,5,5,5,5,6,6,7,7,7,7,9,10] I'd like to find all combinations of these values that when summed exceed the maximum (in this case 10) by the smallest amount (in this case a number that is closest to 11). The function for this array would output [[9,2], [6,5], [7,2,2], ... etc...
In the context of CS, how the hash-table and hash-map are different? I was watching a part of "Algorithm with Swift" video in Udacity, and I discovered the terms "hash-table" and "hash-map" are somewhat confusing. As far as I understand, hash table → stores keys only → Swift Set. hash map → stores key/value pairs → ...
A Field-programmable gate array (FPGA) is generally more efficient than using a "hard-coded" processor like a CPU or GPU for highly specific applications like bitcoin mining or doing structurally identical computations many times over. however, FPGA as far as I know are beaten in computational efficiency by Application...
This is a continuation of a question I asked here. The puzzle Icosoku is now described by Wikipedia as: "The puzzle frame is a blue plastic icosahedron, and the pieces are 20 white equilateral-triangular snap-in tiles with black dots and 12 yellow pins for the corners. The pins are printed with the numbers from 1 to 12...
As i've been told , a Branch Target Buffer (BTB) acts a lot like a cache for Branches , keeping a map of where branches are in the address space. If implemented well , it should allow the processor to detect branches before even decoding them , redirecting the PC to the presumed target ( with the help of the branch pre...
We know that P $\subsetneq$ EXPTIME, and that P $\subseteq$ NP $\subseteq$ EXPTIME. I hear alot about the P = NP question and why it would intuitively be weird if it holds true, but I don't hear about the intuition behind why people think that NP $\subsetneq$ EXPTIME. Are there intuitive reasons to assume that NP = EX...
Not sure if this is a proper place, but I really don't know where else to ask. I'm craving for an algorithm generating certain sequences of numbers (the problem comes from physics). I'm looking for all such sequences of $a_n$ an $b_n$ that: $$ \begin{cases} \sum \limits_{n=1}^{K} (n a_n) + \sum \limits_{m=1}^{K} (m b_m...
I also came across something, which is not completely understandable for me, so I ask here. Given is a qubit in an entangled state, this is: $$ \frac{1}{\sqrt{2}}(\left|00\right>-\left|11\right>) $$ Now it is said that one could also apply the Hadamard transformation to the first bit and measure the first bit of the pa...
I am attempting to resolve the following problem using Backtracking: Suppose that you have $n$ men and $n$ women and two matrices P y Q (n x n); such that $P_{ij}$ is the preference of the man $i$ for the woman $j$ and $Q_{ij}$ is the preference of the woman $i$ for the man $j$. Depict an algorithm that follows the B...
My problem is a modification of the known problem. Suppose you have a building with n floors. (Where n can be any size). Furthermore you have an indestructible egg at your disposal. If the egg is thrown from a floor which is not the maximum one gets a message. If the floor was too high you don't get a message. How ca...
I came up with this Hangman variation, where you must figure out the hidden word by asking whether a string is a substring of this word. E.g. if the hidden word is "abracadabra" and I guess "cad" I will get a positive result, and if I guess "arb" I get a negative result. When I guess the word I win. My first question i...
My problem is mainly from this lecture notes on convex optimization here page4 Consider a s-t Minimum problem, on unweighted undirected graph $G=(V,E)$,we can formalize in following linear integer programming problem \begin{equation*} \begin{aligned} & \underset{}{\text{minimine}} & & \sum_{u,v\in E}|x_u-x_v| \\ & \tex...
We have to derive an optimal binary encoding for the infinite set of symbols $\{s_1, s_2, \dots \}$. Their distribution is given by $$p(s_i) = 9 \cdot 10^{-i}$$ My intuition was to use a Huffman encoding. Obviously the Huffman encoding algorithm needs to first find the smallest two elements, which we can't do. But, if ...
As the title reads, I’m just trying to understand if there is any difference between memcomputing and neuromorphic computing. If so, what are they? Memcomputing: https://www.popularmechanics.com/technology/a16308/memcomputer-quantum-computing-alternative/
Suppose you have files with size $1,2,3,4\dots$ (which can be arbitrarily large and which have and can have any value that you want) and a USB-stick whose memory size $s$ you don't know, where $s$ is a positive integer and can be arbitrarily large. If $s$ is not smaller than your current file you get a message that it ...
I'm given a set of $n$ numbers. Is there a data structure that builds in $O(n)$ (linear time) and gets the $k$'th largest element in $O(k)$ time? Also, is there anything better than $O(k)$?
Suppose st: string -> nat and X stands for the string 'X'. Given the hypothesis not(st X <> 0), I can successfully derive assert (st X = 0). { omega. } But in Coq's constructive logic, a proposition of the form (P -> False) -> False does not in general imply P. I imagine the fact that st is a function enables one to p...
How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs ... the result of any execution is the same as if the operations of all the processors were executed in some sequential order, and the operations of each individual processor appear in this sequence in the order specified by its ...
I have an assignment where I have to prove that solving a crossword puzzle is an $NP$-complete problem by reducing from EXACT 3-SET COVER. I have more or less given up at this point. If anyone could give me a hint or know where to find the proof, it would be much appreciated. Problem: [${\bf CrossWordPuzzleConstructi...
This is an interview question. Say you have a function foo() which returns some integer. You need to write an algorithm that does the following: (1). Call foo() in a loop, till the returned value of foo() is -1. (2). Returns true if during the loop there were two calls of foo() which returned the same...
My question is about small set expansion properties of random unbalanced bipartite graphs. Fix a positive $\delta<1/2$, and a positive integers $n,m,d$. Let us call a bipartite graph $\mathcal{G}$ an $(n,m,d,\delta)$-expander if the graph has $n$ left vertices, $m$ right vertices, every left vertex has degree $d$, and...
The scenario is something like this I have tasks that get requested, with a category and a priority For simplicity let's assume that rate of incoming tasks and completion is about the same, with some existing backlog of tasks Each category of tasks can only be completed at some certain rate Completion of tasks is hand...
I am trying to solve an assignment problem-like from a bi-objective persepctive where I have a marketplace of vendors proposing different machines with different types and specs. The goal is to select a small number of vendors (F1) while meeting the specs of some client machines and maximizing a utility function (F2). ...
I am working on a problem in robotics, where we have a problem of having finite time horizon T, and a set of actions. Each take some time to perform and each have a utility. We can transition from any action to another after completing that particular action, and each transition takes a unique, finite time. Our goal is...
Given an array of numbers, I want to select some entries, preserving their order, so that I end up with the longest possible sorted sub-array. It does not matter which entries I discard in the process. In case it matters, each value may only appear once. How might I attack this problem? Examples: [1, 3, 2] - > [1, 2] [...
If $A$ is a regular set, then: $L_1=\{x\mid\exists n \geq0, \exists y \in A: y=x^n\}$, $L_2=\{x\mid \exists n \geq0, \exists y\in A: x=y^n\}$. Which one of them is regular? My reasoning is since in $L_2$ we can have uncountable $x$ from even one value of $y\ (y^0, y^1, y^2,...),\ L_2$ cannot be regular. But that thinki...
$L= \{a^{2i}b^{j}vc^{j}(ac)^{i} | i,j \ge 0, v \in \{a,b\}^*\}$ over the alphabet $\Sigma = \{a,b,c\}$ How can a grammar be created from the language without the use of the empty string. Below is my example that does use the empty string. $S \rightarrow aaSac|B$ $B \rightarrow bBc|C$ $C \rightarrow aC|bC|\epsilon $
In 1995, two DB theory researchers, C.J. Date and H. Darwen, published a text with the rather impressive-sounding name "The Third Manifesto" with their ideas regarding future DBMSes, which would better harmonize a relational model with object-oriented programming, including user-defined types. It is my understanding th...
How do I show that $2^x - x^2 \in \Omega(2^x)$? Basically, I know that this means that $\exists a, x_0 \in \mathbb{R^+}, \forall x \in \mathbb{N}, a.2^x \leq 2^x - x^2$. I worked around a bit with this and I seemed to have gotten something that makes sense for the case of an upper bound; $$2^x -x^2 < 2^x + x^2 < 2^{x+1...
I am trying to understand the larger problem of the decidability of the equality of two DFAs. I understand that this problem can be solved using minimizing DFAs, but my textbook states this can be done using symmetric difference. Theorem: Let $EQ$ be a language, where $EQ$ = $\{<A,B> \mid \text{A and B are both DFAs an...
I am not well versed in this topic so please pardon any ambiguous notation. I am trying to describe the language of this grammar in set-theoretic notation. The Grammar is given by: $ S \rightarrow ASA|B$ $ A \rightarrow a|b$ $ B \rightarrow BC|\epsilon$ $ C \rightarrow a|b|c$ I think I can accurately describe this lang...
With 7 nodes of distinct values (unique), how many Binary search trees (BST) can be formed such that: Exactly $1$ leaf node(s) present? Exactly $2$ leaf nodes present? I was able to solve the first one(and the actual problem was also that, but then I though what if the process can be extended) Here's my take on the ...
I was reading this thread The stable marriage algorithm with asymmetric arrays and started to solve the problem asked in this thread about matching 5 students with 10 dorms. One of the answer suggested to add 5 dummy students to make number of students equal to 10. Lets suppose before adding the dummy students the pref...
Let s say we have an algorithm that takes as input 3 matrix A,B and C $$ \text{Input} :A,B,C \in Mat(n\times n)$$ $$\text{Question} :\text{is } A\cdot B=C$$ the algorith works as follow ; $$ \text{if }(A\cdot B)_{ij}=C_{ij} \Rightarrow A\cdot B=C $$ $$ \text{if }(A\cdot B)_{ij} \neq C_{ij} \Rightarrow A\cdot B \ne...
I want to make the regular expression of this language but I can't: I tried but the regular expression didn't match some strings that it should. Is it even possible?
This is an interview question. Suppose you have an array of n segments, when each segment is a pair of two integers: start point and end point. For example: (1,3). Two segments s1,s2 are intersecting if (s2.start<=s1.start<=s2.end) or (s1.start<=s2.start<=s1.end) For example: (1,3),(2,4) are intersecting. ...
Hiring problem is discussed in section 5.1 and 5.2 of the CLRS* and I'm referring this for exercise solutions. However, for Exercise question 5.2-2 my solution deviates from the one given in the reference and mine seems be correct. I am still not satisfied with the reasoning of my solution though. Here it goes. The Que...
Traditional programs work significantly through control flow. I know that there are simple algorithms that have no control flow at all (i.e. they just perform a fixed sequence of executions), but I cannot imagine anyone building a large complex program without any control flow. However, as far as I understand, there is...
There are many papers and textbooks in computer science that claim that computational problems are not feasibly computable (technically, not theoretically as with the halting problem) using a classical computer if the number of operations needed to be performed for solving them is exceeding the total number of atoms in...
Was hoping if anyone had any way to prove the following claim using proof by contradiction Let $G = (V, E)$ be a simple graph with at least one vertex, and let $G'$ be the graph formed by adding a new vertex $v$ and making it adjacent to every vertex in $V$. Claim: $G$ has a Hamiltonian Path if and only if $G'$ has a ...
In both B-trees and B+trees, a node (a.k.a page) contains K keys and K+1 pointers: node = [ ptr_1, key_1, ... , ptr_K , key_K , ptr_(K+1) ] Now suppose that I want a B/B+ tree (whichever possible), where each node contains exactly K keys and K pointers, in form of {key,ptr} pairs: node = [{key_1,ptr_1} , ... , {key_K...