Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to choose a encoding scheme for data storage. I have very low available memory. which coding should be best to optimally utilize available space.
ANSI, UTF or any other..
Data is the Capital Alphabetics
If you know the frequency distribution of letters, Huffman Coding is a good balance between complexity, speed and efficiency.
If you don't know the distribution of letters or they are random, just store them 5 bits at a time. For example, consider the string "ABCDE". The letter numbers are 0, 1, 2, 3, 4. Converted to binary, this is:
00000 00001 00010 00011 00100
Now you just group every 8 bits into bytes:
00000000 01000100 00110010 0xxxxxxx
You need to store the length too, so that you know that there is no useful data in the last byte's 7 bits.
If code space is of no concern and you just want to pack the strings as well as you can, you could use Huffman coding or Arithmetic coding even with a uniform frequency distribution to pack each character into log2(26) bits on average, which is slightly less than 5 (namely, 4.7 bits).
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
We have 2 CPU which has this properties-
Clock Rate
CPI
Execution time
No of instructions
MIPS, will always be identical?
If 2 machines have the same Instruction Set Architecture, which of the upper mentioned property will be same?
4 will be true (same dynamic instruction count) unless the program has speed-dependent behaviour (e.g. keep looping checking the time until 0.1 seconds have elapsed, or other more interesting examples you could come up with).
No reason for 1 to be true, and it's very easy to find counter-examples if you go to any online computer store and look at different models of the same generation of x86-64 CPUs with different max clock speeds. And across different generations, there can be even larger differences in clock speed, e.g. a 25MHz 80386 vs. a 5GHz Zen 2 or Coffee Lake.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am wondering if there is a software library that enables opening a jpeg and converting a subset of it to an uncompressed array (such as Pillow). This would be in contrast to the more usual method which is to open the file, convert it fully to a bit array, then take a subset of the bit array.
In my case the subset that I have in mind is the upper left corner. The files decompress to 2544 × 4200 pixels, but I am only interested in the top left 150 x 900 pixels.
The background is below:
I am hopeful that the JPEG format is a string of compressed subpanels and an algorithm could stop when it had processed enough subpanels to fulfill the required subset of the image.
I have been searching for a while but have not found any mention of such an algorithm which, admittedly, is a special case.
Background
I use pyzbar to capture a barcode from the top left corner of a JPEG image as produced a high-speed scanner. Generally this required about 250 msecs per image. The actual Pyzbar time is about 2.5 msecs while the other 99% of the time is spent reading the image from a file, having it decompressed using Pillow, extracting the upper left corner.
The non-profit where I do this work as a volunteer cannot really afford to replace the $25K scanner and the channel that this clunker has is the overall bottleneck. Telling the scanner to send uncompressed images would slow the whole process down by at least 90%
I don't know of an existing library that can do this, but it is possible to modify jpegtran.c and jdtrans.c from the IJG C library to only read as many MCU rows as necessary when cropping, and in your specific case the decode time should be reduced by ~75% (900 / 4200 lines).
Since you are using Python, you could obtain a suitably cropped jpeg with:
os.popen("jpegtran -crop 152x904 %s" % inputfile).read()
This assumes the input jpeg is not progressive.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
If a RAM has 32 bits in its MAR(memory address register) and its MDR (Memory data register) is 16 bits wide, then what is the capacity of RAM.
My probable solution is that it can address upto 2^32 locations.
Your solution is incorrect. The question is what the capacity is, not the number of addressable locations. Your answer should be measured in units of storage (e.g, bits, bytes, or their multiples).
Since this is clearly a homework problem, I'm not going to give an exact answer. But I will point you in the right direction by asking some additional questions:
What is the memory data register used for? (Refer to your textbook if you're not sure.)
What is the capacity of the memory data register? (The answer is in the question. Don't think about it too hard.)
With that in mind, what is the capacity of the memory?
Yes, that sounds right. If a microprocessor or CPU has a memory address register with a size of 32 bits, it can access 232 locations, as 32 binary bits used in combination allow you to handle 232 different values starting from 0 to 4294967295 (232 - 1).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
How micro processor is controlled? For example, after receiving instructions from memory, the instruction decoder decodes the instruction(???), and the decoded instruction is executed in ALU. How all this happen in a sequence?
At a high level, when the microprocessor is given electricity, it sets the program counter to a predefined address in memory where it expects the sequence of program instructions to start. Each instruction tells the microprocessor to do one or more things, such as read/write memory, do math, or change the value of the program counter.
The ALU is the Arithmetic Logic Unit, which just does the math bits.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
I didnt understand this because 2^32 is 4 giga bits not bytes right ? since 2^2 * 1024* 1024* 1024 bits right ? Am I wrong ?
The smallest individually addressable unit of memory is a byte. Bits don't have addresses. You have to read a byte or more and then do bit masking and such to get at the individual bits.
As far as i can recall from my college days, this is how it goes
If 32 = size of the address bus, then the total number of memory addresses that can be addressed = 2^32 = 4294967296
However, these are 4294967296 Addresses of memory locations. Since each memory location itself = 1 Byte, hence this gives us 4294967296 bytes that can be addressed.
Hence 4GB Memory can be addressed.
No, it is Gigabytes. A byte has 8 bits so you have to multiply the resulting number by 8 to get the bits. As john said in his answer you cant address individual bits, you will have to do bit shifting and masking to get to individual bits.
In the old console days SNES and Megadrive games were measured in MegaBits because by definition an 8MegaBit game sounds bigger than a 1 MegaByte game. In the end most people said 8Megs so again the confusion gave the impression of 8Megabytes for most people. Im not sure if brett is talking about SNES or Megadrive programming but remember 8 Megabits = 1 Megabyte.
the above answer solves it, and if you wish to address more then 4 gb then you can use an offset memory register, that can help you address a wider range.