## Least computationally expensive bitwise addition

I am familiar with the oft-cited method of bitwise addition using XOR and left shift for the carry, applied recursively. I was wondering if this is the least computationally expensive way to achieve simple addition modulo 2^n using bitwise operators. Answer AttributionSource : Link , Question Author : Brad Thomas , Answer Author : Community

## Regex vs line by line read efficiency – general concept question

Say, I have a file that is somewhere between 10-20 pages long. I need to extract 10-20 pieces of information from it that I can fairly easily extract using a series of regex-es or by running code that reads things line by line and extract information that way. Is there a way that is necessarily … Read more

## What’s the most time efficient way to find the number of nodes reachable from each root and no other root?

Suppose there are n nodes. These nodes are connected by m unique directed edges. Sets of these edges may form cycles. Each node has an associated quantity. r of these nodes are selected as root nodes. A node a can be said to reach node b if a is b or there exists a directed … Read more

## Understanding recursion tree for withdrawal formula

T(n)=T(n−a)+T(a)+cn Now the solution says that the height of the tree (h) is: h=⌊n/a⌋ And I don’t understand why. Maybe I didn’t understand the withdrawal formula as needed. Answer Your recurrence expands into a recurrence tree in the following way. Each node has a label. If the label n is a or smaller, then the … Read more

## Convex hull on set of squares

Imagine a set of two to six squares within 3D-space. The goal is to generate a convex hull around these squares as efficiently as possible. The following constraints are known: Each of the two to six squares consists out of 4 vertices (a vertex being a 3D-vector). The vertex-data are stored in such a way, … Read more

## Can we make at most 3 comparisons in the closest points algorithm instead of 7?

Let’s say I am using the divide and conquer algorithm outlined here, but I only want to return the minimum distance. I understand why that algorithm puts an upper-bound at 7 but I think that can be trimmed down further. I can’t come up with a geometry of points where if you are comparing them … Read more

## Which of the query approaches are more efficient?

There are two relations, registered(participant,topic) and fee(participant,amount). The primary key for registered is (participant, topic) and the primary key for fee is participant. The premise is that of an academic conference. The relation registered stores the names of the participants and the names of the topics registered by them. On the other hand, the fee … Read more

## Modeling timing characterists of an architecture

I am building a system and I have a couple of architectures in mind. I want to have an idea of which architecture is likely to be most performant (quickest). I can make different decisions like 1) Do everything in one thread 2) Separate this part into one thread, that part into another thread since … Read more

## Random file access in a block based file format

I am writing a program to store, retrieve and delete “blocks” of data of varying sizes. The way it currently works is by keeping a database storing the locations of the blocks and the locations of free space in the file. The file is split into pages such that in each page there are no … Read more

## How do we determine how much time a multi-tape DTM saves over a one-tape DTM?

Note: This is a part of a homework question Were asked to construct a multi-tape Turing Machine for language {anbncn∣n≥0} Then it says “Discuss how much time your machines saves over a one-tape DTM using the same algorithm” Any hint? Here’s my algorithm: (1) Cut-and-paste c’s to tape 3 (2) Cut-and-paste b’s to tape 2 … Read more