Questions tagged [space-efficiency]

67 questions
3
votes
3 answers

Most efficient database date storing method?

So I am looking to store a date in my SQL database and am not sure what the most efficient way would be. I have thought of two different methods. Firstly, people are going to be able to set a certain price for each day. For example: March 8, 2011:…
Flipper
  • 2,589
  • 3
  • 24
  • 32
3
votes
3 answers

How would you most efficiently store latitude and longitude data?

This question comes from a homework assignment I was given. You can base your storage system off of one of the three following formats: DD MM SS.S DD MM.MMM DD.DDDDD You want to maximize the amount of data you can store by using as few bytes as…
3
votes
2 answers

How to find if there's arithmatic mean of contiguous elements in a sorted array that equals to a given value in the most efficient running time?

INPUT: Sorted array of positive, natural numbers, EXPECTED COMPLEXITY: Time: O(n) Additional space: O(1) Example: Input: arr = {2,3,17,30} x=10 Expected behavior: The function prints the indexes : 1,2 and returns true since (3+17)/2 = x =…
Dam
  • 125
  • 7
3
votes
4 answers

Is there a better way to repeat code other than using def

I have print(randint(0,12)) Is there a quicker easier way of being able to execute this three times in a line other than copying it all out or using def RandNum(number): print(randint(0,12)) so is there just a way I can run the…
Merlindima
  • 48
  • 6
3
votes
1 answer

C++ class design: dynamic typing alternative to template argument?

I would like to build a space-efficient modular arithmetic class. The idea is that the modulus M is an immutable attribute that gets fixed during instantiation, so if we have a large array (std::vector or another container) of values with the same…
3
votes
1 answer

Find prime numbers between 1 and ~2^128

I want to implement an algorithm to get a list of prime numbers between 1 and a very large number. I was going to use erasthosthenes sieve. But to implement the sieve, shouldn't we first create a boolean array containing that many numbers. Isn't…
harryjohn
  • 656
  • 1
  • 8
  • 25
2
votes
6 answers

Ideal options for archiving flat files

We receive multiple thousands of flat files per week currently, and I have a system that runs reports on these and exports them to PDF for our people to process and reference. I currently bulk load these into a database, make sure all…
thismat
  • 2,096
  • 17
  • 24
2
votes
3 answers

Best way to store and retrieve a DAWG data structure for fast loading

I have a 500k+ wordlist that I loaded it into a DAWG data structure. My app is for mobile phones. I of course don't want to repeat all the conversion steps to load this wordlist into a DAWG every time, since it would take to much storage space to…
Alex
  • 319
  • 6
  • 14
2
votes
1 answer

Speeding up a code that calls same function again and again

I have got a matrix say A of size M X N. I have to call same function for each column throughout the matrix. Till now, I have been extracting each column and calling the function over the column iterating till N. i.e. (No. of Columns) Is there any…
2
votes
3 answers

Encoding multiple instructions in the same machine code

I am curious if this has been done before and not necessarily whether it has practical value (although the spatial efficiency gains would be obvious). Has encoding multiple instructions within the same machine code ever been done? For example: (This…
ballaw
  • 1,489
  • 6
  • 20
  • 28
2
votes
1 answer

Perl: Efficiently store/get 2D array of constrained integers in file

This is an attempt to improve my Perl: seek to and read bits, not bytes by explaining more thoroughly what I was trying to do. I have x, a 9136 x 42 array of integers that I want to store super-efficiently in a file. The integers have the…
user354134
2
votes
2 answers

SQLite - is foreign key more efficient than an int column?

I have a table: CREATE TABLE pupils ( id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, name TEXT, surname TEXT, address TEXT, score INTEGER ); where score is a percentage. Is it more efficient to have the integer value in there or a…
Ne0
  • 2,688
  • 3
  • 35
  • 49
1
vote
2 answers

Why does MySQL prefer ENUM('N','Y') over BOOL?

Today I noticed that the tables of the mysql database in a default MySQL 8 installation use the type ENUM('N','Y') where I would expect them to use BOOL. For example, see the output of DESCRIBE user. The same pattern is followed elsewhere, such as…
William Rosenbloom
  • 2,506
  • 1
  • 14
  • 37
1
vote
1 answer

Do the tail-recursive version of the length function saves stack space at run-time?

I am asked to change this F# length function to a tail-recursive one. let rec len xs = match xs with | [] -> 0 | x::xr -> 1 + len xr;; While this is not a difficult exercise, I wonder whether changing to the tail-recursive version,…
zell
  • 9,830
  • 10
  • 62
  • 115
1
vote
1 answer

How to reduce a pandas Series by performing an operation on every set of N sequential elements

Say I have a pandas series, and I want to take the mean of every set of 8 rows. I don't have prior knowledge of the size of the series, and the index may not be 0-based. I currently have the following N = 8 s = pd.Series(np.random.random(50 *…
Dagorodir
  • 104
  • 1
  • 10