Hi Daniweb, I'm new to Assembly level programming and have been given an assignment in MIPS. Having started to plan the assignment, I have come to a rather open ended question that I want your opinion on: given that one has only so many registers to work with on Assembly level, how does one use these efficiently? For example, my assignment requires 4 registers to hold numbers, 4 more registers to hold addresses to arrays, and will probably need more later. And this is just my assignment, I'm sure many assembly programmers have faced a situation in which they have …

Member Avatar
Member Avatar
+0 forum 1

I am trying to modify my shell sort algorithm to use Hibbard's increments rather than n/2. I know that Hibbard's increments are 2k - 1, but I can't figure out how to incorporate that into my algorithm. Any suggestions to help me move forward with this? I feel like I just can't figure this one out. Here's the working version of what I have now, which is NOT using Hibbard's increments: [CODE] public void shellSort(int[] array, int lowindex, int highindex, boolean reversed) { int n = highindex - lowindex; int increment; int offset; for (increment = n / 2; increment …

Member Avatar
Member Avatar
+0 forum 4

There must be a better way of writing the following code, I would really appreciate your suggestions and coding. I am new with python. Thanks. A1 = os.path.join(pathname, "x") A2 = os.path.join(pathname, "x", "y") A3 = os.path.join(pathname, "x", "y", "z1") A4 = os.path.join(pathname, "x", "y", "z2") createPath(A1) createPath(A2) createPath(A3) createPath(A4)

Member Avatar
Member Avatar
+0 forum 2

Hi, I have quite a large CSV file (Around 20,000 rows with about 20 columns) that I am trying to manipulate. Initially I am looking for a way to get out the first 10 or so records after they have been sorted in ascending order on one of the numeric fields. I've thought of loading the file into memory and then sorting it from there using one of PHPs sort functions but as expected, the memory is simply exhausted. My current thoughts on this would be to read line by line attempting to place each record into an array (Which …

Member Avatar
Member Avatar
+0 forum 12

Hello, Is there any way to access a large number of keys in a dictionary efficiently. Perhaps via indexing with an array of lookup values. Some pseudo code may help; dictionary={a:1, b:2, c:3 ...etc} lookup=[a, a, b, c, c ... etc] print dictionary[lookup] thanks, Joe

Member Avatar
Member Avatar
+0 forum 2

Can this code of mine be more efficient? [CODE]import java.util.Scanner; public class Game { public static void main(String args[]){ boolean gamestatus = true; //Boolean to control the whole game double total = 0; //Temporary variable for storing the average Banker banker = new Banker(); //creation of the object banker; int cases = 26; int turn = 0; //counter variable to count the number of turns Scanner input = new Scanner( System.in ); //creation of the scanner object Briefcase briefcase[] = new Briefcase[27]; //an array of briefcases double amounts[] = {0,0.01,0.5,1,5,10,11,14,20,300,600,150, 13,14,15,16,17,18,19,20,21,22,23,24,25,26,28}; //The Amounts to be inserted in to the cases …

Member Avatar
Member Avatar
+0 forum 4

Hi all. I have a database table containing the details of, lets say, Ninjas. It has a primary key called NinjaID. I have a second table containing a match-up of which Ninjas will be fighting eachother. This table has 4 Columns: 1.) MatchID 2.) BlueCornerNinjaID 3.) RedCornerNinjaID 4.) DateTime What I need is to extract a list of Ninja's from the Ninja Table, only of Ninjas that are scheduled to fight in a match (any match) regardless of whether it will be fighting from the blue corner or from the red corner. For argument sake, lets say this is a …

Member Avatar
Member Avatar
+0 forum 4

For each of the step (even that specific as what editors and other software to use) included into building an application (for me mostly - web (php-mysql-html-javascript)) I really need tips on how to improve them so I could start working really really fast and be able to generate all the required functions in an application like in one day instead of a week. The problem is when I come up with a nice idea, I start to develop it, but it takes way too long and I get bored of it and throw away. How to prevent (well my …

Member Avatar
Member Avatar
+0 forum 18

Hey everyone I was wondering if anyone had any tips or methods for me to better my programming in C. I know I have to practice problems from my book but are there any other ways to better my code writing skrills :D thank you.

Member Avatar
Member Avatar
+0 forum 3

Hey guys I had some homework in a Java class on Friday. I completed it so I am not looking for answers (I also don't think it will be graded). I was just curious, as a learning exercise, how would you guys improve this and why? Now remember I'm a java newb so go easy; I still haven't learned what an object is. I'm sure their has to be a better, prettier way of doing this though so I figured I would ask the pros. Here's the code: [CODE]/* * This program generates and prints a * random card from …

Member Avatar
Member Avatar
+1 forum 2

I am working on a project and coding in Python 3.1 where I need to find a string in a file. I have already considered reading the file to a string and then using rfind() on it, but that does not seem to be efficient, seeing as how I expect my file to be large. I am considering using a for loop to read each line, but I'm not sure how efficient that is either. Any better alternatives out there? P.S. I need to find the last instance of the sub-string. So a bigger file will almost kill my previous …

Member Avatar
Member Avatar
+0 forum 3

hi guys, i'm running a recordset read as below and within that running commands against a 2010 exchange server. i wanted to know what you thnk the fastest method there is of doing this?Is the best mehod to put the connection to the exchange server outside the rdr.read, and then only have the runspace/command in the rdr.read? let me know what you think i'd really appreciate any input, as you can see i'm not expert! [CODE] while (rdr.Read()) { if (exchversion == "2010") { SecureString password = new SecureString(); string str_password = exchpwd; string username = exchuser; string liveIdconnectionUri = …

Member Avatar
Member Avatar
+0 forum 1

I have a table with ~10,000 records. There is a "viewed" column which contains either 0 or 1. At some point in my code I want all rows = 1 for the "viewed" column. Does it matter if I set all rows to 1 or set all rows to 1 that = 0? For example, is there a performance issue or something else to consider between the 2: UPDATE table SET viewed = 1; and UPDATE table SET viewed = 1 WHERE viewed = 0;

Member Avatar
Member Avatar
+0 forum 4

I have a prime number method here which checks if the user input is a prime number, I've done some stuff to try to make it more efficient, but I am wondering if there is anything else that can be done, maybe even make the complexity class constant? Thanks. Below is my code. [CODE] public static boolean checkPrime (int n) { if (n!=2) { if (n%2==0) { return false; } } for (int i=3; i<=Math.sqrt(n);i+=2) { if (n%i==0)//if n divided by i has a remainder of 0, then not prime { return false; //number is not prime, return false for …

Member Avatar
+0 forum 0

When I use my computer, I often feel that my CPU is under performing. The only time I don't feel like this is when I am using programs or playing games that are made for multi-core processors. This has stopped me from upgrading to i7 simply because I don't know if windows will use it that way I want it too. Maybe I could start a [B]HUGE[/B] debate out of this question. :)

Member Avatar
Member Avatar
+0 forum 1

I am working on an application and would like to be able to calculate the efficiency of various algorithms and choose the best one. The application operates on a list of records that are stored in a file. Operations include adding records, deleting records, and searching for records based on any field in the record. I know that the File I/O and searching has cost and I am having trouble find a balance between them. Is it more desirable to minimize search time or File I/O? For example, I could use the search from the STL, but that would require …

Member Avatar
Member Avatar
+0 forum 3

Starting with version 2.6 Python has introduced a new container called the named tuple. You can use it similar to a class based record structure, but it has the memory efficiency of a tuple.

Member Avatar
+1 forum 0

First off thanks to all the members of daniweb for all there help and support, they've been fantastic. I'm on the last stage of my program and i need a little more help. I am using binary serialization to save information, i don't want to use xml because frankly it looks a lot harder. My problem is i want to incorporated a search bar to search m serialized files however i see no other way to do this then by deserializing all the files and look for keywords. Does anyone have a more efficient way of doing this?

Member Avatar
Member Avatar
+0 forum 2

The End.