computer-science

Difference between Memory Mapped I/O and Programmed I/O

烂漫一生 提交于 2020-01-01 12:03:25
问题 While going through computer Architecture, I learnt different method of controlling I/O device which are, Programmed I/O Interrupt I/O DMA I learnt all three methods. But I come across another term Memory Mapped I/O . Is there any relation between Programmed I/O and Memory Mapped I/O ? I am confused with these two. Are they similar? 回答1: Those terms are mostly independent and not mutually exclusive. Below I'll use a pseudo-assembly code to make the examples clearer, it is a demonstrative code

NP-Complete VS NP-Hard

回眸只為那壹抹淺笑 提交于 2020-01-01 11:50:16
问题 I am trying to understand the difference between NP-Complete and NP-Hard. Below is my understanding An NP-Hard problem is one that is not solvable in polynomial time but can be verified in polynomial time. An NP-Complete problem is one that is in NP and is also NP-Hard. Is the above definition correct? If so, What about problems not In NP but NP-Hard. Wouldn't they be harder than NP-Complete problem, say they can only be solved and verified in exponential time? 回答1: A NP problem (not NP-Hard

ID3 and C4.5: How Does “Gain Ratio” Normalize “Gain”?

独自空忆成欢 提交于 2020-01-01 03:39:30
问题 The ID3 algorithm uses "Information Gain" measure. The C4.5 uses "Gain Ratio" measure which is Information Gain divided by SplitInfo , whereas SplitInfo is high for a split where records split evenly between different outcomes and low otherwise. My question is: How does this help to solve the problem that Information Gain is biased towards splits with many outcomes? I can't see the reason. SplitInfo doesn't even take into account the number of outcomes, just the distribution of records in the

How to compute the absolute minimum amount of changes to convert one sortorder into another?

折月煮酒 提交于 2019-12-31 12:55:53
问题 Goal How to encode the data that describes how to re-order a static list from a one order to another order using the minimum amount of data possible? I have a feeling there is an algorithm or computer science term that will help me but right now I'm too stuck on the problem to figure out other ways of looking at it. Background Motivation I'm have a program that is deployed to a remote location where all communication is via an intermittent incredibly expensive satellite connection. It's a

How to compute the absolute minimum amount of changes to convert one sortorder into another?

ε祈祈猫儿з 提交于 2019-12-31 12:55:44
问题 Goal How to encode the data that describes how to re-order a static list from a one order to another order using the minimum amount of data possible? I have a feeling there is an algorithm or computer science term that will help me but right now I'm too stuck on the problem to figure out other ways of looking at it. Background Motivation I'm have a program that is deployed to a remote location where all communication is via an intermittent incredibly expensive satellite connection. It's a

Optimum search for k minimum values in unsorted list of integers

时间秒杀一切 提交于 2019-12-31 10:52:06
问题 I was just interviewed with a question, and I'm curious what the answer ought to be. The problem was, essentially: Say you have an unsorted list of n integers. How do you find the k minimum values in this list? That is, if you have a list of [10, 11, 24, 12, 13] and are looking for the 2 minimum values, you'd get [10, 11]. I've got an O(n*log(k)) solution, and that's my best, but I'm curious what other people come up with. I'll refrain from polluting folks brains by posting my solution and

Optimum search for k minimum values in unsorted list of integers

◇◆丶佛笑我妖孽 提交于 2019-12-31 10:51:54
问题 I was just interviewed with a question, and I'm curious what the answer ought to be. The problem was, essentially: Say you have an unsorted list of n integers. How do you find the k minimum values in this list? That is, if you have a list of [10, 11, 24, 12, 13] and are looking for the 2 minimum values, you'd get [10, 11]. I've got an O(n*log(k)) solution, and that's my best, but I'm curious what other people come up with. I'll refrain from polluting folks brains by posting my solution and

Dividing and multiplying Decimal objects in Python

非 Y 不嫁゛ 提交于 2019-12-31 05:38:14
问题 In the following code, both coeff1 and coeff2 are Decimal objects. When i check their type using type(coeff1), i get (class 'decimal.Decimal') but when i made a test code and checked decimal objects i get decimal. Decimal, without the word class coeff1 = system[i].normal_vector.coordinates[i] coeff2 = system[m].normal_vector.coordinates[i] x = coeff2/coeff1 print(type(x)) system.xrow_add_to_row(x,i,m) another issue is when i change the first input to the function xrow_add_to_row to negative x

max float represented in IEEE 754

旧巷老猫 提交于 2019-12-30 08:59:32
问题 I am wondering if the max float represented in IEEE 754 is: (1.11111111111111111111111)_b*2^[(11111111)_b-127] Here _b means binary representation. But that value is 3.403201383*10^38 , which is different from 3.402823669*10^38 , which is (1.0)_b*2^[(11111111)_b-127] and given by for example c++ <limits> . Isn't (1.11111111111111111111111)_b*2^[(11111111)_b-127] representable and larger in the framework? Does anybody know why? Thank you. 回答1: The exponent 11111111 b is reserved for infinities

Why do Computers use Hex Number System at assembly language?

∥☆過路亽.° 提交于 2019-12-30 07:51:27
问题 Why do computer use Hex Number System at assembly language? Why don't they use any other number system like binary, octal, decimal? What thing forced computer designer to use hex system at assembly? Why it looked so beneficial to them? 回答1: 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