Questions tagged [space-efficiency]

67 questions
0
votes
1 answer

Is it considered efficient to pass functions as arguments over passing variables?

Given the task of printing to the terminal, which code block is "best practice"? string name = get_string("Whats your name? "); printf("Hello, %s\n", name); or printf("Hello, %s\n", get_string("Whats your name? ")); This question has…
0
votes
1 answer

Database Application - Store or compute on-the-fly?

I have a table of purchase list with fields: ItemName, Quantity, UnitPrice, Amount. Note that Amount is equal to Quantity * UnitPrice. My simple problem is, should I STORE the amount or COMPUTE it when retrieving the data? To what should I concern…
kazinix
  • 28,987
  • 33
  • 107
  • 157
0
votes
1 answer

Efficiency of Arrays vs Ranges in Ruby

While working on something recently, I started to think about the efficiency of Arrays and Ranges in Ruby. I started to try and research this but could find very little information on it or even how I could test this myself. So I came across some…
Aaron Nolan
  • 15
  • 1
  • 4
0
votes
3 answers

Recommended SQL Types and Lengths

I'm new to SQL and I'm working on a table that stores account information for a multiplayer game. I'm wondering what is the most efficient way to store a lot of data. For these three columns, I think, I've already figured it out: username:…
0
votes
0 answers

why does python's array uses 2 bytes for unsigned ints, whereas C expects 4 bytes in general?

I need to store a large number of unsigned integers. Looking at https://docs.python.org/3/library/array.html, I wonder why python's array uses 2 bytes for unsigned ints whereas the C language expects 4 bytes in general?
zell
  • 9,830
  • 10
  • 62
  • 115
0
votes
0 answers

Bubble sort algorithm efficiency

I would like to know how to determine the efficiency of my array sorting algorithm. After researching big O notation I learned that the time complexity is polynomial of O(n^2) since the algorithm consists of 2 loops. Also, the space complexity is of…
310094933
  • 59
  • 1
  • 5
0
votes
1 answer

How to reduce Android app size by compressing images?

I am developing an Android app which has hundreds of .jpg files (over 300) each one of around 40kB. I would like to know if there is a way of reducing the size of my app. I looked at a similar question here Reducing Android App Size, but the problem…
James Ele
  • 111
  • 3
  • 13
0
votes
1 answer

When reassigning a Python reference to itself, does it un-assign and re-assign, or do nothing?

def new_val(x): x['a'] = 5 return x b = {'a': 2} b = new_val(b) # b re-assigned to ret val Since dictionaries are mutable, b is a reference pointer to a dictionary, and we pass this pointer into the function new_val. The reference to the…
Dave Liu
  • 906
  • 1
  • 11
  • 31
0
votes
1 answer

How do I go through an array of numbers efficiently in Python?

I am trying to make a more efficient method of going though an array of numbers, and finding what number is missing. I have an array of numbers from 1 to 20, but one is missing, and the numbers aren't ordered in a chronological order (they're…
E. Epstein
  • 739
  • 2
  • 11
  • 26
0
votes
1 answer

If select exists, use it. If not, try it on different table

I have a piece of code like this: IF EXISTS(SELECT VALUE FROM tableA WHERE nameid = 'thisName') BEGIN SELECT distinct VALUE FROM tableA WHERE nameid = 'thisName' ORDER BY value END ELSE…
Zikato
  • 536
  • 9
  • 18
0
votes
0 answers

Most efficient data structure for sorting an ArrayList by categorical factors

I have created an object, let's call it EventObject, that will hold the results of an SQL query. Initially the objects will be aggregated into a single ArrayList. I am trying to develop a method that will look at each EventObject in the ArrayList,…
0
votes
1 answer

Is there a way to make this more efficient?

So I am working on a text adventure to improve my programming skills (Just a beginner) and I was working on a new combat system for it because the old one was really boring. So I came across a rock paper scissors system but I wanted something that…
0
votes
0 answers

Decreasing EXE Size

I wrote a TicTacToe program in C that reads 68.3 KB on my hard disk, and I was wondering if there are any sort of optimization techniques I could use to decrease the amount of bytes in my .exe file. For instance, is there anything in my code that I…
Delfino
  • 967
  • 4
  • 21
  • 46
0
votes
1 answer

Get a set of subnets/adresses from IP range

I'm looking for a good algorithm (or code if you speak it better than English) to do the following: For a given IP range (e.g. 1.1.1.1 - 1.1.2.247), find the smallest combination of subnets/addresses that includes all the IPs in the specified range.…
0
votes
1 answer

Why is my date dimension table useless? (Confusion over PostgreSQL storage...)

I have looked over this about 4 times and am still perplexed with these results. Take a look at the following (which I originally posted here) Date dimension table -- -- Some output omitted DROP TABLE IF EXISTS dim_calendar CASCADE; CREATE TABLE…
Ryan
  • 729
  • 1
  • 10
  • 25