Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many integers can I create in 1GB memory?

In book Algorithms fourth edition by Robert Sedgewick on page 200, it says "for example, if you have 1GB of memory on your computer (1 billion bytes), you cannot fit more than about 32 million int values."

I got confused after my calculation: 1,000,000,000 bytes/4 bytes = 250 million

How the author got 32 million?

The book describes like below:

enter image description here

like image 262
Max Avatar asked Feb 22 '16 10:02

Max


People also ask

How much memory does integer take?

Integers are commonly stored using a word of memory, which is 4 bytes or 32 bits, so integers from 0 up to 4,294,967,295 (232 - 1) can be stored.

How much is 1GB of memory?

This is a lot of memory, 1 GB has 1 billion bytes, and each byte has 8 bits, so 1 GB has 8 billion bits of memory (WHOA!).

What can you do with 1GB of storage?

A 1GB data plan will allow you to browse the internet for around 12 hours, to stream 200 songs or to watch 2 hours of standard-definition video.

Which device can store from 1GB to 16gb of data?

Hard disk is an hardware component which is used to store large amounts of data. The primary characteristics of hard drive are its capacity and performance. it is an electro mechanical data storage device.


2 Answers

The author has acknowledged that this is an error in this book website, please refer to the link as follows: http://algs4.cs.princeton.edu/errata/errata-printing3.php

like image 79
Max Avatar answered Sep 20 '22 19:09

Max


1 gigabit = 1073741824 bit
1 int = 32 bit
calculation = (1073741824/32) = (32 * 10242) = (32 * 220) = 32 million

If author meant gigabytes then answer would be (32 * 8) million = 256 million

like image 23
shaggy007 Avatar answered Sep 18 '22 19:09

shaggy007