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
4
votes
3answers
95 views

Hotel booking with multiple options. Improvement through subclasses?

The code below runs perfectly fine as I want it to. I'd like to create more subclasses to get a better overview over the whole code. Can I place the setter and getter as well as the methods into the ...
6
votes
2answers
100 views

Follow up to “C simple hashcons data structure”

This is a follow-up question to my previous question I have modified the code according to the feedback I got from here and my Professor. However, my Professor is still not happy with the final code. ...
6
votes
2answers
167 views

C simple hashcons data structure

I wrote this hashcons data structure in C and it works correctly. It uses larger twin primes as the capacity and double hashing (open addressing). Page 614 of "Data Structures and Other Objects ...
4
votes
3answers
211 views

Student Grade Calculation

Develop a smart application as Student Grade Calculator(SGC). Create a class Student with following private attribute : int id, ...
7
votes
1answer
220 views

Parsing a sequence of bits out of a bit field

For homework, I had to parse CPUID instruction output in C, which required a lot of specific bit-manipulation like: (eax & CACHE_LEVEL) >> 5 I ...
2
votes
2answers
106 views

Verify credit card number with Luhn's algorithm

...
20
votes
6answers
4k views

Can I slim this UTF8-encoding program?

Below is my entire program. You can read what it does thanks to the comments and specifications in particular. My question is: can it be improved? Would it be possible, for example, to avoid writing ...
1
vote
0answers
24 views

Parametrized cache simulation in C

This is an assignment known as a Cachelab from CMU 15-213. The full writeup for the lab can be found here, the handout I'm working against - here. All in all, the task is to emulate a cache, given the ...
2
votes
1answer
57 views

Code duplication

I wrote a function that merges two linked lists but I seem to have some code duplication I'm not sure what to do with: ...
2
votes
2answers
80 views

Prefix expression evaluator [C++] [closed]

Here's my code for this' weeks homework I had. The code should take an expression , preferably in prefix notation ( otherwise throws exception ), that evaluate prefix expression. I've given three ...
3
votes
1answer
64 views

C# Quicksort Assignment

For my CS minor I was assigned to implement the Quicksort algorithm in C#. I gave it a go and found that I like the implementation of the algorithm more than Mergesort. Now that I've got my Quicksort ...
1
vote
2answers
69 views

integer log base 10 function without using java.lang.Math?

I am assigned to a task of creating a function int logBase10Estimate(int n) that returns the log of a number base 10. The answer is integer part only.(w/o using the Math class) Is this okay? ...
12
votes
3answers
1k views

Implementing a rectangle class

First I've to indicate that this is my homework. An example of a given input is: s1 = {'p1': (x1, y1), 'p2': (x2, y2)} where all names and coordinations are ...
2
votes
1answer
81 views

Optimizing minHeap implementation

I have implemented a java class for minHeap but it is not working as fast as I want . I want some help to change it to work faster in insertion or deleting the minimum node. Here is my implementation:...
1
vote
1answer
849 views

Go homework interview challenge for Storj

Last December I interviewed with Storj and was unsuccessful after my code challenge. Storj were good enough to pay me for the time it took to complete the challenge, but have refused to give any kind ...
5
votes
1answer
118 views

Parsing weather station XML on raspberry pi

This if for a school project that is all about getting the most performance possible out of a relatively weak computer. For this project we have received a weather station report generator that ...
0
votes
1answer
39 views

Spaceship Operation in for Lexicographic Comparison

I have written a program in Java 8 using BlueJ. There is just one function of type byte that accepts two String values and return 1 if the first word comes before the second in alphabetical order, and ...
7
votes
1answer
78 views

Cis 194: Homework 3 (Histogram)

I am following CIS 194: Introduction to Haskell (Spring 2013) online to teach myself Haskell. Following is my response to third exercise of Homework 3, namely Histogram. In which ways I could improve ...
1
vote
1answer
92 views

Optimizing Hash Table

I am trying to write my own implementation of a hash table (hash map) in C++. It turns out that my code is unoptimized as I can't pass performance tests. Can you please give some advice for ...
5
votes
2answers
183 views

Binary search guess game in C++

I'm trying to write a program where computer attempts to guess a number entered by user. Computer should keep asking until guessed number will be equal to user number. If you know what can be ...
2
votes
1answer
712 views

Salaries exercise

Hey there guys, I have just completed an exercise for uni and I would really like some feedback as I'm pretty new to using java. Areas that I could especially use some input in this instance: ...
3
votes
1answer
58 views

Converting an input of space delimited integers to a list

tablou = input("Enter values delimited by space: ") b = tablou.split() t = [] # initial list with int() contents for l in b: r = int(l) t.append(r) I ...
4
votes
3answers
102 views

A custom String class implementation

This is my first implementation of a "container" using the Rule of Five, any feedback I'll gladly accept. I've tried to make it as Exception-Safe as possible. I've made it for an assignment. Header <...
7
votes
3answers
337 views

Optimizing Conway's Game of Life in C++

How could I further optimize my implementation of Conway's Game of Life? And how would you critique my current strategies? I'm taking a C++ optimization class, the deadline has passed and my ...
11
votes
4answers
4k views

Python Bingo game that stores card in a dictionary

I am super proud of this python bingo game I wrote. I am posting it here to make get some help reviewing it to make sure I'm using the best practices. This is for a class, and my professor is a ...
0
votes
1answer
513 views

The Game of Pig in JavaScript

I've implemented the game of Pig in JavaScript. My implementation has the following rules: Two players take turns playing in rounds. In a round, the player rolls a single die as many times as they ...
6
votes
3answers
163 views

Taking out number of subarrays from an array which contains all the distinct elements of that array

I am a beginner in C. My teacher gave me a homework problem in which a user would provide an array with its size. What we have to do is:- 1) Take out all the distinct elements from that array. ...
7
votes
2answers
1k views

Count the frequency of items in an array

The question is: Write a program that prompts the user to input ten values between 80 and 85 and stores them in an array. Your program must be able to count the frequency of each value appears in ...
4
votes
0answers
77 views

Python program for address normalization and geocoding

This is a school project I have been working on. I have created a program utilizing Tkinter, and I was hoping to get some feedback on the way I have gone about things. I feel like it is pretty messy ...
7
votes
3answers
395 views

Sierpinski turtle triangle

I am working through Programming Fundamentals with Python on Udacity. The assignment was to create a recursive triangle. I am happy with the output, but I am hoping for feedback on the actual ...
4
votes
2answers
87 views

Draw an outline of an upward-pointing triangle

I am beginner in C++ and I was given this assignment by my teacher. The assignment is to print the following shape: ...
2
votes
1answer
153 views

Game of life using NumPy

I'm trying to improve my Game of life program for school in Python, to be able to run it quicker. So if you have some ideas, I will be glad to hear them. My current code: ...
2
votes
1answer
49 views

Naive implementation of sort inplace

I had the following assignment for the Python 101 course I'm taking in my university. ...
-2
votes
1answer
42 views

A game that deals a high card to one of two players [closed]

So for my class, I have to design a game that will deal out one card to for each player. I also need to use functions to accomplish this one for the high card game, and another for the face value of ...
4
votes
1answer
457 views

Getting saddle points of a matrix

My homework assignment: Write a function called saddle that finds saddle points in the input matrix M. For the purposes of this problem, a saddle point is defined as an element whose value is ...
1
vote
2answers
221 views

Turing machine schoolwork

Our teacher doesn't give much feedback on our code itself. Was just looking for some feedback on how I could improve on this. This is the method that tests the string against the Turing machine that ...
-1
votes
4answers
284 views

Python program to print all permutations of a string in lexicographic order using recursion

An assignment at school required me to print all permutations of a string in lexicographic or dictionary order. Here is my solution to the task - ...
3
votes
0answers
476 views

Python program to solve matrix-chain multiplication

An assignment at school required me to write a Python program for this task: In the matrix-chain multiplication problem, we are given a sequence of matrices ...
5
votes
2answers
479 views

Array Stutter Implementation

I was assigned this homework assignment to complete. The question originates from CodeStepByStep. Below is the prompt for the question: Write a function stutter that takes an array of Strings as a ...
3
votes
1answer
93 views

Get all possible subsets from a set of distinct integers using OOP

An assignment at school required me to write a program for this task: Create a class and define two methods in the class. Method ...
2
votes
1answer
555 views

Python program to find the subarray with maximum sum

An assignment at school required me to write a program for this task using Kadane's algorithm (explained here): Define the function find_max_subarray that ...
21
votes
4answers
5k views

Count all vowels in string

For a homework assignemnt, I was asked to complete this CodeStepByStep problem. It's coded correctly and gave me a right answer. I'm just wondering if there's an easier way to solve this problem ...
1
vote
1answer
29 views

Calculate function with optional operator argument

I am currently learning javascript at university. We have an assignment where we shall write various functions for calculating values. In one case, we shall write a function which returns the sum of ...
2
votes
1answer
49 views

Sum of Two Matrices

For a homework assignment, I was asked to do this problem. It worked, but it looks messy in my opinion. I want to know if this is the best way to accomplish this task, and if there can be any ...
1
vote
2answers
61 views

Optimize printing massive strings to System.out with respect to time

I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
2
votes
2answers
70 views

Split calculation string into parts

Our professor has given us the following task (its part of a bigger document full of tasks): Write a function in C that handles strings like "233+343" and parse them into the variables "iNum1", "cOp" ...
6
votes
3answers
4k views

Huffman Code in C++

This is my version of the Huffman Codes. ...
3
votes
2answers
77 views

Add three integers and report the sign of the sum

I am in my first high school programming course; the assignment is: Write a program that asks the user to input three integers and outputs a message indicating their sum and whether it is ...
4
votes
1answer
184 views

CS50 - Bleep suggestions

I finished CS50's bleep.py from pset6. I was hoping to get some feedback on my code (e.g., redundant code, bad practice, etc...). Program function load in a dictionary of banned words accept a ...
2
votes
1answer
113 views

Graph implementation using FIFO lists

I've made a little implementation of an undirected graph, using FIFO lists, for one of my homeworks. Never really knew how to write a proper FIFO data structure, so I would be glad to see some opinion ...

1
2 3 4 5
10