c,programming-languages,computer-science,systems-programming,inventions

It will give you a good idea of where computers started and how they've progressed and how they progressed. If you want to get into the history of computers I'd look at things such as the Jacquard loom and Babbage's difference engine. These two inventions probably had the greatest early...

java,while-loop,external,computer-science

You have made a good start by using the Scanner. I would suggest that just using that may be insufficient, as you may end up with some malformed lines. To handle them you may wish to split the processing into two parts: get a line, and then get the individual...

create a counter and add to it for correct answers. You can also create a counter for wrong answer Of course you want to declare these variables first. so the code to increment your counter would be like : rightAnswer += 1 if answer == riddle["correct"]: print("Congratz! You can think!!!")...

java,computer-science,keylistener,keyevent

You simply have to add the listener to something (e.g. the window where the game is being played). I will give you an example, where we will simply display the code of the key being stroked. This is the class where you produce the interface: import java.awt.Dimension; import javax.swing.JFrame; public...

html,twitter-bootstrap,computer-science

class of form-inline will do, adding div form-group will even be better. <form class="form-inline"> <div class="form-group"> <input type="text" class="form-control" id="control1"> </div> <div class="form-group"> <input type="text" class="form-control" id="control2"> </div> </form> Goodluck in computer science....

java,c++,sorting,computer-science,quicksort

The quicksort algorithm looks like this: quicksort(A, lo, hi): if lo < hi: p := partition(A, lo, hi) quicksort(A, lo, p - 1) quicksort(A, p + 1, hi) We have a special partition that is 3-way, so let's say it returns the equal range for whatever pivot it picks and...

computer-science,computer-architecture,digit,bcd,vlsi

A Mod 4 in the original equation gives the two least significant bits of the BCD digit A. So, let's consider the two most and least significant bits of A separately, like so: X = A AND 3 = A Mod 4 (two least significant bits) Y = A AND...

algorithm,math,computer-science,ed25519

I would argue this is impossible. At least the part where you say "the second party must be able to recreate the signature from the data" The simple reason behind this is entropy, or the amount of information that is contained in each signature. First, let us take a look...

assembly,computer-science,computer-architecture

Maybe a picture helps: +----------------+----------+----------+----------+----------+ 1 core: | non-par. | parallelizable | | (1 - Q) | Q | +----------------+----------+----------+----------+----------+ | || | | +----------------+----------+ --+ n cores: | | | | +----------------+----------+ | | | | +----------+ +-- n times | | | +----------+ | | | | +----------+...

python,computer-science,permutation,combinatorics

Using itertools.combinations: >>> import itertools >>> list(itertools.combinations(['foo', 'bar', 'la'], 2)) [('foo', 'bar'), ('foo', 'la'), ('bar', 'la')] ...

java,computer-science,compareto

if(!(obj instanceof Pizza)) throw new IllegalArgumentException ("Parameter must be a Pizza"); Pizza temp = (Pizza) obj; return Double.valueOf(this.cost).compareTo(Double.valueOf(temp.cost)); cost is primitive double. CompareTo is a method in object. So you can use Double object instead of double or You simple use arithmetic operation....

image-processing,computer-vision,computer-science,imaging

A symmetric checkerboard pattern is ambiguous: you cannot tell if it is rotated 90 degrees or 180 degrees. Asymmetric pattern does not have this ambiguity. If your checkerboard is non-square, then you can tell if it is rotated 90 degrees. If one of its sides has an even number of...

I don't know anything about R, so I'll just address the theoretical aspect of this question. First, the constraints are really boolean predicates of the form "a1 ^ b2 -> ¬c3" and so on. That means that all valid combinations can be represented by one binary decision diagram, which can...

assembly,computer-science,computer-architecture,bits

Bits are not numbered from right to left. They are numbered from lowest weight (the lowest weight bit getting the number 0 or 1 depending on the convention chosen) to highest weight (which can be 15 or 16, 31 or 32, 63 or 64, ...). One reason to number them...

algorithm,computer-science,combinatorics,set-theory

We already know the answer for these cases (as you wrote in your examples): n=2 n=3 n=4 For n=5: You can partition from 2: 1 2 - 3 4 5. This is like dividing the 5 member set into two sets, first one n=2, and second one n=3. We can...

c#,vb.net,vb6,computer-science

You are correct in saying that *.designer.cs files are usually created by the IDE. However, generating them yourself makes sense here. To understand why, you have to realize what that file actually is. The IDE takes all the stuff you do on the actual forms designer (hence, designer.cs) and stuffs...

To prove it, you need to know the algorithm being used and show in graph terms that the set of all states constitutes a cycle, that there are no subcycles, and that the cardinality of the state space modulo N is zero so that there is no set of states...

youtube,computer-science,news,journal,innovation

You can watch channel 9 http://channel9.microsoft.com/ They talk about different topics related with technology: smart phones, software, languages and so on. It's a must see. Also microsoft virtual academy videos.

security,operating-system,system,computer-science

Anyone saying that microkernels are "the right way" is wrong. There is no "right way". There is no objectively best approach to security. The problem is that security is not fundamental to computing. It's a sociological issue in a lot of ways, it only exists because humans exist - unlike...

regex,perl,computer-science,theory,automata

It doesn't look that different from standard regex... the only change you would have to make is to swap + with | (change (0+1) to (0|1)). Apart from that, you would just have to make the resulting regex match the entire line, either by prepending ^ and suffixing $ or...

algorithm,computer-science,insertion-sort

Consider an n element list where the first n^(k/2) elements are decreasing [n^(k/2), n^(k/2)-1,...,1], and the remaining n-n^(k/2) elements are increasing [n^(k/2)+1, n^(k/2)+2,...,n]. Insertion sort is quadratic on the first part and linear on the second part. This is runtime Theta(n^k + n - n^(k/2)), which is Theta(n^k) as long...

python-2.7,matplotlib,computer-science,floating-point-conversion

You can't append to a tuple at all (tuples are immutable), and extending to a list with + requires another list. Make curveList a list by declaring it with: curveList = [] and use: curveList.append(curve) to add an element to the end of it. Or (less good because of the...

c++,computer-science,c-strings,c-string

after the line with the j++; insert the following if (j < 201) { documentArray[i][j+1] = '\0'; # terminate the c string } else { documentArray[i][j] = '\0'; # cannot terminate the c string, overwrite the last char to terminate the string } But please make sure that every read...

algorithm,networking,data,computer-science

Part a T = 0 RTT Sender sends frames 0, 1 and 2 (theoretically) simultaneously. T = 0.5RTT Receiver receives frames 0,1 and 2. Receiver updates LFR = 2, LAF = 5. Receiver sends ACK for each of the three frames. T = 1 RTT Sender receives ACK for frames...

vb.net,visual-studio-2013,computer-science

Here's an example of what I mentioned in the comments. It builds a list of the desired number of operations in equal quantities, then shows how to pull a random one from that list: Public Class Form1 Private Operations As New List(Of String) Private Sub Button1_Click(sender As Object, e As...

windows,winforms,osx,operating-system,computer-science

Go for Linux based OS and play with the source code during your CS. PC and Mac are for users, but you do not want to become a user but a programmer, so Linux based OS are best as they are open source and you can learn a lot. Analogy:...

For the case you mentioned(case (i)) you can use Arithmetic Progressions In this case as first term=2*n-1 and the last term is n, so sum of all the terms is S=n/2*(n+2*n-1)=O(n^2) For the Case II, first term=(n+1-1)=n and last term=(n+n-1)=(2*n-1), so Sum, S is equal to, S=n/2(first term+last term)=n/2*(n+2*n-1)=O(n^2) You...

assembly,architecture,computer-science,computer-architecture,hex

Well it doesn't make a difference how you represent them but as we know that humans don't understand binary numbers, they are only to make the computer's life easier as it works on only two states true and false. So in order to make binary numbers(instructions) human readable we adapted...

arrays,algorithm,data-structures,time-complexity,computer-science

The answer is O(nlogn), since it is the lowest yet not sublinear option. It can be done in O(nlogn) by maintaining a sorted DS (self balancing BST for example) of size sqrt(n), and iteratively remove and add elements to it (while running a sliding window on the array). Each iteration...

Omega(f(n)) + o(g(n)) is not really defined well, so I'll try to formally define what you are asking: if f(n) is in Omega(n^3), and g(n) is in o(n^2), is f(n)+g(n) in Omega(n^3)? The answer to this is yes. Let's say you have constants C1, C2 such that: f(n) >= C1*n^3...

r1 is loaded with the address of xtop. It's just an accident that it starts with 11100. There is no "double to integer cast" in that code. It's 224 because you have 28 doubles defined before xtop, each taking 8 bytes (the pi followed by the numbers 1-27).

Math and physics are used a lot in graphics programming, so you will probably like to join a project about a game. In 3d graphics programming math is really important, and if you love math this is the computer science field for you.

algorithm,optimization,computer-science,dijkstra,shortest-path

If I understand you correctly, you want to find the tree of minimal weight in the graph that contains all the vertices of E and at least one vertex from S. The problem is called general Steiner tree, and it is NP-hard. So the best you can probably hope for...

algorithm,computer-science,finite-state-machine

No. Intuitively, an algorithm can only be represented as an FSM if it uses only a finite amount of state. For instance, you couldn't sort an arbitrary-length list with an FSM. Now, add an unbounded amount of state to an FSM -- like an infinite one-dimensional array of values... and...

algorithm,linked-list,computer-science

You don't know the length of the list, so you have to iterate it all the way to the end. You need to keep copy of the currently chosen items value (or item, but there seems to be no way to do that in your question). Then for every new...

sorting,computer-science,mergesort

If you keep dividing n by 2, you'll eventually get to 1. Namely, it takes log2(n) divisions by 2 to make this happen, by definition of the logarithm. Every time we divide by 2, we add a new level to the recursion tree. Add that to the root level (which...

javascript,math,logic,computer-science,permutation

How about: if ((!SL || SM) && (!TL || TM)) ... ie: the source must be empty or take multiple lines and the target must be empty or take multiple lines...

php,computer-science,computer-science-theory

You are installing a PHP interpreter (it is an interpreted language on its base), along with its built-in functions (APIs provided as a library along with the language for mostly common used functionality). Also a SAPI (Server API) is installed, which allows the PHP runtime environment to be accessed through...

c++,visual-c++,dll,operating-system,computer-science

It all depends ! Your projects can be independent applications or libraries: Independent application each have their own stack Libraries will be linked to application and don't have their own stack DLLs are libaries that are dynamically linked, so they follow the principle of libraries and don't have their own...

c,arrays,computer-science,bubble-sort,c-strings

Arrays are not assignable as you're attempting in C. You need to setup some buffer swapping logic. For example. if(strcmp(str[j+1],str[j]) < 0) // note: fixed. { strcpy(temp, str[j]); strcpy(str[j], str[j+1]); strcpy(str[j+1], temp); } Other issues with your code: Incorrect size of your input array. All those strings require at least...

logic,computer-science,transitions,boolean-logic

Your finite state machine has one state bit and one output bit. Therefore you can distinguish four different r/y states: r y ---- 0 0 0 1 1 0 1 1 From each of these states the machine will transition to a subsequent state depending on the input bit x....

computer-science,computer-architecture

In your configuration a memory block is made of 16 words. Let me also assume that a word is 4 bytes and the memory is byte addressable. 1 Block = 16 words = 64 bytes Block numbers usually grow with memory addresses, that is: Block Address Range Block #0 [0,...

computer-science,type-theory,computer-science-theory

Technically, it would be associative, but it depends a bit on how you are using it and how much you want (or need) to adhere to its definition. In many type systems, you only have two-type tuples, and every product type that contains more than two types is just two-type...

algorithm,heap,computer-science,fibonacci-heap

Nodes with equal keys are OK. Recall the heap property: for min-heap, the key of each node is greater than or equal to the key of its parent. (The max-heap property can similarly defined.) A Fibonacci heap is just a collection of such trees. If more than one root has...

You would use the modulo operator. A common formula to use (for arbitrarily large positive / negative integers) is: (n % SIZE + SIZE) % SIZE Instead of cluttering the code with these formulas however, I would encapsulate it in a function: int getCell(int i, int j) { return board[(i...

javascript,jquery,html,css3,computer-science

yea, to have such stunning effect we have to invest some efforts or money to get it. But since you tried to search but no hint, i will show you some starters :) http://janpaepke.github.io/ScrollMagic/ http://johnpolacek.github.io/superscrollorama/ http://prinzhorn.github.io/skrollr/ there are a lot more libraries available out there, but it is alwasy fun...

programming-languages,computer-science

Python looks procedural, supports functional programming and has continuation implemented here: http://pypy.readthedocs.org/en/latest/stackless.html#continulets Also check out asyncio tulip: https://docs.python.org/dev/library/asyncio.html...

I've heard this called a "turn of the event loop" (by engineers at Mozilla and by members of TC39, the ECMAScript standard committee). In the ECMAScript standard, a Job is defined as "an abstract operation that initiates an ECMAScript computation when no other ECMAScript computation is currently in progress". That's...

algorithm,math,time-complexity,computer-science,recurrence-relation

Here are a few hints : define R(n) = T(n)/(n-1)! solve the recurrence for R(n) express T(n) as a function of R(n) ...

architecture,binary,decimal,computer-science

You are correct that the computer stores numbers as binary representations - 1s and 0s. There are many different types of binary representations of numbers depending on how big the number is that needs to be stored and whether it has a decimal part or is an integer. The computer...

java,arrays,sorting,computer-science,insertion-sort

"but I really am crap at sorts of all kinds" What you are not doing here is helping yourself. Getting other people to do your work for you is not going to make you any better. A good place to start learning about insertion sort would be the Wikipedia...

c++,compiler-construction,computer-science

No, I don't think that's how it works. If you attach to a running program, that simply tells the debugger which process to be interested in, and from this it can find the EXE file and the PDB symbols file. From the PDB symbols the debugger can find the required...

O(65536 n2 + 128 n log2n) is the same as O(n2 + n log2n) since you can ignore multiplicative constants. O(n2 + n log2n) is equal to O(n2) since n2 grows faster than n log2n. Also, by the way, the base of logarithms doesn't matter in Big-O analysis. All logarithms...

c++,algorithm,big-o,computer-science

A sweep line algorithm is an efficient way to solve your problem. As explained previously by Brian, we can sort all the endpoints by the x-coordinate and process them in order. An important distinction to make here is that we are sorting the endpoints of the segment and not the...

algorithm,network-programming,computer-science,dijkstra

If there are two entries with the same lowest cost, you can choose either - it doesn't matter. For example, if your tentative list looks like this: 10 4 9 7 7 3 2 11 5 2 and you were finding the minimum cost by using a sorted list, it...

You have three problems here (two related), all of which are probably contributing. The first is that floating point comparisons are generally unwise since, while you may think you have 360, it may in fact be 359.999999942. The second is that inaccuracies build up over time. Every time you add...

numbers,computer-science,representation

Your reasoning is perfectly sound. The easiest to show it is be example, as you did. An non-representable example Consider the "usual single floating point" format, as defined by IEEE-754, it has 7 exponent bits, thus a range beyond [-2^127,2^127]. It also has 24 mantissa bits, so let's consider 67108864,...

c,function,for-loop,computer-science

You don't reset you x_coord variable in your outer for loop so at the end of the first row, your x_coord is 202 and that's where it starts writing the next row which may be out of your window. simply adding x_coord = 2; after y_coord += 40; should fix...

You should check out a Chumby Hacker board instead of a raspberry pi as they have audio inputs and inputs included. This site will tell you all you need to know about the required code for the button. https://learn.adafruit.com/playing-sounds-and-using-buttons-with-raspberry-pi/overview While I hour this helps, please keep in mind that this...

javascript,ruby,oop,inheritance,computer-science

It depends what you mean by "multiple inheritance" and "composition." If composition and inheritance both just mean adding to a list of messages that an object responds to, then they are equal by definition. Let's say that classes are simply virtual tables of methods, and that each object in a...

algorithm,big-o,computer-science,big-theta

Wouldn't it suffice to give a special input and show that the running time is at least f(n)? Yes, assuming you are talking about the worst case complexity. If you are talking about worst case complexity - and you have proved it is running in O(f(n)), if you find...

algorithm,graph,computer-science,graph-algorithm,shortest-path

Edited my answer based on counter example by David Eisenstat. The example you give in your question is not a good example of when Dijkstra will not work. I believe you can do this by modifying Dijkstra. The key is to keep track of multiple alternatives for each Vertex. Not...

image-processing,computer-vision,computer-science

"Scale" here alludes to both the size of the image as well as the size of the objects themselves... at least for current feature detection algorithms. The reason why you construct a scale space is because we can focus on features of a particular size depending on what scale we...

memory-management,operating-system,computer-science,fragmentation,fat

Most "non-traditional Unix" and FAT file systems I am aware of use an allocation bitmap to identify free space on the disk and some form of file extent descriptors. A separate descriptor is required for each contiguous region for the file. If a file is entire contiguous, it needs only...

algorithm,lambda,functional-programming,computer-science,lambda-calculus

There are various approaches to evaluating lambda terms. Depending on whether type information is available or not, you can get more efficient and more secure evaluators (runtime checks are not needed as the programs are known to be well-behaved). I'm going to give a crude presentation of some techniques. Big...

You have to go through all the elements of the array, one by one. Without more information there is no way to locate the repeated element without touching at least once each element. This is at least O(N) and you can't go faster. If the repeated elements are consecutive, for...

Every expression in Ruby is being evaluated to an object and every object has a boolean value. Many expressions can have a false value, but the only two objects in Ruby to have a boolean value of false are nil and false. That's why....

multithreading,data-structures,concurrency,computer-science

I will try to answer with examples from JDK, if you do not mind: Lists: CopyOnWriteArrayList is a list that achieves thread-safe usage by recreating backing array each time the list is modified; Lists returned by Collections.synchronizedList() are thread-safe as they include exclusive locking for most operations (iteration over is...

algorithm,sorting,big-o,computer-science,asymptotic-complexity

The reason that comparisons are such an important factor, is because you could always store things by pointer, worst comes to worst, and make swaps the same for any types of keys. These simple system tricks will not work for comparisons. Comparing strings by lexicographic order is inherently more expensive...

You can probably go out and start learning more about algorithms. There is a course starting up on algorithms on coursera https://www.coursera.org/course/algo. You can also try competing on http://www.topcoder.com/ ...

algorithm,math,statistics,computer-science

How about using harmonic mean? 4 / (1/1 + 1/1 + 1/1 + 1/7) = 1.272727 4 / (1/2 + 1/2 + 1/2 + 1/4) = 2.285714 ...

algorithm,sorting,math,computer-science

Since Big O is just an approximation you can not compute the real time but yes you can have some estimation. In your case it would be 1 M ~ 5 min 4 M ~ 5 *(4*4) min ~ 80 min. Note : I used symbol ~ to show approximation....

algorithm,math,big-o,computer-science,integer-arithmetic

Edit: Your previous question shows that you are interested in the number of terms in the inner summation. The loop for j<- first to last has last-first+1 terms (this is easiest to see if you write down some examples with small last-first). So for (1), there are (2n-i)-(1)+1=2n-i terms for...

algorithm,data-structures,computer-science,binary-search,linear-search

regarding 1&2, an absolute number as an answer would've been possible if an absolute number was provided as the size of the input. since the question asks about an arbitrarily sized array (of length n) then answer is also given in these terms. you can read more about big O...

javascript,data-structures,computer-science

As SLaks wrote above any recursion can be represented as loop with stack. So after thinking a while I came up with next solution: var myobj = { one: "hello", two: "world", three: { one: 1, two: 2, three: 4, four: { one: true, two: false } }, four: "!"...

algorithm,graph,computer-science,graph-algorithm,dfs

Step 0: If there is no path from v to t, then answer is NO. Step 1: Make the graph G' after collapsing all the strongly connected components of G. Step 2: If the vertex 'v' is a part of some SCC consisting of more than 1 vertex, then there...

python,debugging,recursion,computer-science

The problem is in the recursive call: scrabbleScore(s[0]) when s returns as an empty string (base-case of the recursion) this call will fail and throw an exception. A side note: there's no point in the line: let.lower() - it doesn't do anything....

c++,c,computer-science,logical-operators

You can add brackets around the separate operations and apply them in order. e.g. !(!(~x)) i.e. !! is 2 NOT's What happens to some value if you perform one NOT is: If x == 0 then !x == 1, otherwise !x == 0 So, if you would perform another NOT,...

operating-system,computer-science,disk,disk-io

Let's know what the SCAN(Elevator) disk-scheduling algorithm says:- It scans down towards the nearest end and then when it hits the bottom it scans up servicing the requests that it didn't get going down. If a request comes in after it has been scanned it will not be serviced until...

floating-point,computer-science,computer-architecture,floating-point-precision

According to the paper referenced in the question, it is possible to calculate the dot product of a pair of length N vectors with a single rounding operation at the end, getting the closest representable result to the dot product. In practice, current computers round intermediate results, which often results...

python,recursion,input,average,computer-science

You can try something like this : def read_and_avg(sum_,n,left,i): ## left is the number of times the input is to be taken if left == 0: print (sum_/float(n)) return (sum_/float(n)) else: i = i + 1 print "Enter the values for pair number "+str(i) a = int(input()) b = int(input())...

c,pointers,computer-science,user-defined-functions

As other answers have observed, in C, all arguments are passed by value. That means the function gets a copy of the caller's value, therefore changes to that value are not visible to the caller. In other words, given void f(any_type arg) { arg = any_value; } The caller will...