Questions tagged [homework]

Questions requesting help with school homework. This tag lets potential answerers know that they should GUIDE the student in solving the problem, rather than showing a complete solution. CAUTION: Before posting, consider that classmates may be tempted to reuse code from your post. (Read the tag wiki.)

Filter by
Sorted by
Tagged with
10
votes
1answer
48k views

Java multi-thread file server and client

My task was to build a multi-thread file server and a client that can upload or download a named file over sockets. It is assumed that the client will finish after its operation and there is no need ...
2
votes
2answers
233 views

Where to start refactoring? [closed]

I am currently programming, but I messed up my code. What is the best way to clean this? buttonUitvoeren_Click_1: ...
0
votes
1answer
974 views

C for Nios-2 IRQ handling

Related: Nios 2 interrupt handler ...
17
votes
7answers
131k views

Finding repeating numbers in an array

I want to search through an array of n numbers and find the numbers that are repeated. So far I have this code, which does the job, but I find it to be a rather cumbersome method, but I can't seem to ...
2
votes
2answers
930 views

RPN Evaluator that writes the results to a text file

For homework, I had to write an RPN Evaluator and write the results to a text file. I've done all that, but it feels weird, like the writing to my results text file. It also doesn't feel efficient. ...
3
votes
2answers
435 views

Optimization of exponentiation

I'm writing some crypto code, and as part of it, we have to implement modular exponentiation. I have it working, both with the right-to-left binary method and with the Montgomery formula. While ...
3
votes
2answers
454 views

addMatrix() method

Can anyone review my addMatrix() method to see if I am following the instructions correctly? These are the instructions: This is a ...
11
votes
4answers
3k views

Turning an array of words into a random license plate

This is an assignment question from school: Write a method called licencePlate that takes an array of objectionable words and returns a random licence plate that ...
5
votes
3answers
1k views

Printing a 2D array

The problem presented to me: Declare a two-dimensional array of ints in main. Write a method to read in the size of each dimension, allocate memory for the array and return it (DON'T DO THIS IN ...
6
votes
3answers
9k views

Simple array-based Stack class in Java

I have created a simple array-based Stack class with some methods like the actual Stack in Java. I am testing this for mistakes, but since I am learning Java, my tests may not be as comprehensive as ...
4
votes
2answers
174 views

Ordinary Data Processing Task in Haskell: Vague Misgivings

This is an ordinary data processing task: read a list of dates and amounts (for example, deposits and withdrawals from a bank account) and report the date on which the lowest balance was recorded and ...
11
votes
4answers
28k views

Simple C++ function to determine the circumference and area of a circle

First off I would like to state that this is a homework assignment. However, I am not looking for you to complete anything for me. I code I am posting is the completed homework assignment. However, ...
3
votes
2answers
1k views

Format names to title case

So I'm writing a program to format names to title case and display them in alphabetic order. Any advice please? And how can i add more methods? ...
10
votes
4answers
8k views

Payroll calculator

First I tried to fetch this program as close to pseudo code where I must follow all imported items, all method definitions, and all defined variables; anything else was my choice. After I created ...
4
votes
3answers
794 views

Nearest Neighbour classification algorithm

The following code is from a university assignment of mine to write a classification algorithm (using nearest neighbour) to classify whether or not a given feature set (each feature is the frequency ...
23
votes
6answers
3k views

HashSet and TreeSet

I got some homework in which I had to take the novel War and Peace and put it into a HashSet and TreeSet respectively. I had to time it, to check differences and my question is whether my ...
2
votes
2answers
8k views

Producer-consumer in C using pthread_barrier

We're preparing for an exam at the moment, and our lecturer has given us a sample problem to work on. I have it completed, but would like to know a) If it is actually doing what it's supposed to, and ...
2
votes
3answers
1k views

C inner product function without using array subscripting

As part of a question designed to help us understand the relationship between pointers and arrays in C, I've been asked to write an inner product function that doesn't use any array subscripting. Here'...
3
votes
1answer
469 views

Scheme, first timer first program, simple list removal technique

I have started my hand at writing some scheme code. I am trying to get the first n primes. I plan to do so but first getting a list from 2 to ...
2
votes
2answers
457 views

Displaying a certain element among inputted numbers

I prompt the user for 9 numbers, store those numbers in 9 pointers and display the element 2. It seem to work just fine, but am I forgetting something? Can I improve it but keep it simple? I'm just a ...
3
votes
2answers
255 views

Finding the cheapest one-way air flight fare

I'm doing a sort of exercise where I'm given a question, and I have to answer it by writing an SQL query using a database that I was given. This is the question: What is the cheapest fare for a ...
3
votes
2answers
278 views

PHP function to compare two Roman numerals

This was for an assignment. I had to write a function to compare two roman numerals. This had to return true only if the second number was larger than the first and ...
8
votes
1answer
17k views

Inversion count using merge sort

...
4
votes
2answers
2k views

Inventories of iPods for different countries

We were given two countries, namely Brazil and Argentina. Both had one inventory each with 100 iPods in them. The cost of an iPod in Brazil was 100/unit and in Argentina it was 50/unit. But to get ...
4
votes
2answers
308 views

Storing three integer values

Consider an 8-bit complier, in which we have an integer of size, say 2-words i.e. 16-bits or 2 bytes. You need to store three integer values which are supposed to be as: ...
1
vote
4answers
274 views

Insertion vs Selection

I currently have a selection sorting algorithm, but need some help turning it into a insertion sort, I understand a insertion sort if faster? The hand array is full, and it needs to sort from lowest ...
12
votes
6answers
16k views

Does my Rock Paper Scissors game look good?

I'm doing some homework and am just curious if everything I've done looks good and/or if you'd suggest I modify something to keep with "javaese." ...
3
votes
3answers
1k views

JavaScript Objects- Can you confirm?

Ok, I am in a JavaScript class, and I have no desire for anyone to do my schoolwork, I have already done what I think is correct, I am just hoping someone can take a look and tell me if I am close, or ...
23
votes
9answers
32k views

Most efficient way in C++ to strip strings

If I want to strip a string completely of its whitespaces, punctuation and numbers (i.e. anything that is not A-Z, a-z), what is the most efficient way of doing it in C++? I tried this: ...
5
votes
1answer
4k views

Implementation of Dijkstra's shortest path algorithm

This is my code that implements Dijkstra's single source shortest path algorithm, which is called multiple times to recalculate after graph changes. the graph is a road system of a city and shortest ...
3
votes
1answer
3k views

Abstractness of Shape class

Shape represents an abstract class and the other two classes inherits from it. This looks insufficiently abstract to me. How could I improve it? ...
5
votes
2answers
2k views

Pouring water problem

I just began to study Scala (coming from Python I had quite a few problems with types) and I want to know if my first code to solve a real problem is nicely done or if there is some points that need ...
9
votes
3answers
22k views

Finding points with the shortest distance

This takes in a user specified number of points then finds the two points with the shortest distance. ...
2
votes
4answers
760 views

String-crunching routine

How can this be optimized? ...
4
votes
1answer
2k views

Money class for handling calculations with coins

The code follows the requested format of the output exactly for my assignment. But, for my own personal reference, is there a better way that I could have done anything? Are there any additional tips? ...
3
votes
2answers
442 views

Programming of 3 x 7 trick

The puzzle is: The deck contains 21 unique numbers The numbers should be laid up in rows of 7 (3 rows in total) ask the player to memorize a number to start the game once the game starts, ...
2
votes
1answer
167 views

Destructively appending one list to another

I am implementing a list structure in C. My current function I am working on is a destructive append function that takes two lists and appends the second one onto the end of the first. Right now, it ...
3
votes
3answers
4k views

Iterating through a dictionary in C#

I am trying to get my dictionary to iterate seven times after the dateTime is found. I want to iterate through the next week of objects in my dictionary ...
4
votes
4answers
300 views

is there a better way than replace to write this function?

I am doing my homework and i have done this? Is there any other better way to do this? ...
5
votes
5answers
2k views

String traversal program in C

My task was to write a function in C where a string such as {2210090,34566,87234,564676} would be given as input and the function had to find out the count of ...
2
votes
2answers
2k views

Alphabetically-sorted word lookup

The goal of this code is to save a list of 250000 words with a number that indicates its frequency. The 250000 are sorted alphabetically but the frequency is unsorted. The idea is that a user must ...
3
votes
2answers
247 views

Reflecting and counting points on a 2D grid

First number indicates the number of points, followed by N points (x,y). Then the next number indicates Q num_queries, followed by Q queries: Reflect all points between point i and j both ...
2
votes
3answers
903 views

Is this correct java? Attributes and constructors especially

I'm learning java, although because of work I didn't had much time to go to classes. We had a final work to do but since I'm more familiarised with python I'm not sure if I'm doing java correctly... ...
8
votes
6answers
4k views

Sum of all primes under 2 million

I have this assignment to write the optimized space and time code for finding the sum of all primes under 2 million. I'm using the following function to check if each number is prime: ...
3
votes
2answers
1k views

Menu system and Turtle

I had to do a small application using a menu system and Turtle. I have finished it and worked perfect. Just to make sure, can you please check it if it has done properly? ...
2
votes
3answers
913 views

Permutations Finder Help Number 2

Previous question: Java application for finding permutations efficiently> I have changed quite a bit of code, and need some more reviews. ...
8
votes
1answer
746 views

Java application for finding permutations efficiently

I am an eighth grader with a school project of creating and application in Java that returns the total permutations of two given numbers. It needs to be light and efficient, for later deployment on a ...
6
votes
4answers
1k views

Converting an integer into the written form

For my homework assignment I have to create a class which converts an integer between 0 and 9999 into the written form. For example, 713 would be written as "seven ...
4
votes
1answer
2k views

Sudoku Solver Optimization

I am currently working on a Sudoku solver that should be able to solve a 25 x 25 grid. However, I am experiencing problems optimizing it to run quick enough to actually get a result with any grid ...
15
votes
2answers
1k views

Is this C++ quicksort program okay?

I wrote a quicksort program in C++. Is it okay to implement it this way? Am I using pointers correctly? Is my style okay? Any ideas to speed it up or save memory? ...