homework

How to display unique numbers with their frequencies as occurring in a matrix?

Hi . I have a matrice with some number: 1 2 3 6 6 7 2 1 1 4 5 6 And the program should display all different number with own frequency for example: 1 -> 3 2 -> 2 3 -> 1 4 -> 1 5 -> 1 6 -> 3 7 -> 1 Please help me ...

Java inheritance question

you have public class Question and public class MultipleChoice extends Question and public class SurveyQuestions where SurveyQuestions has private static List<Question> q = new ArrayList<Question>(); In main you keep adding questions and all the things questions are composed of to the list. Once done, you want to iterate ov...

font in to image

I have written this code which inserts the fonts according to user inputed phrase in to the main image (srcImage), i am not getting any errors, but i am not seeing the result not sure where the logic error is? The arguments was the image and phrase Hi. I have tested that letter fonts do open and correct rgb values are extracted, the font...

XML and its uses in Databases

what is XML and how is it used in databases? if this looks like a homework assignment,it is. ...

Question about Binary Search Tree?

Today, in class my professors said there's a balance binary search tree which I never heard of it before. I would like to know is there a Balance Binary Search tree without rotation? From my understanding, Balance Binary Search Tree is AVL tree. Besides that I don't think it's possible to build a 'Balance Binary Search Tree'. But if in ...

Checkers/draughts using minimax in C#

Hello, I have homework in **c#**. I have to make a game (such as checkers, chess or something else, but not tic tac toe - and I choose checkers/draughts) with using **minimax** and **alphabeta**, but I don't even know how to start :( **And I have a tight deadline**. I worked with c# a little bit at school, but I'm not a programmer. Now ...

Python; Linked list and traversing!

Hi! Starting some programming with python at school now, and I don't know how to proceed with this problem. Any thoughts? Input consists of integer separated by line breaks. Your program should submit them in a linked list, traverse the linked list and print the highest number. Something to take the first number, and do an action whic...

I am creating a program to implement Sieve of Eratosthenes in C++ for Codechef. But i need a way to optimize the program for large inputs (10^9)

#include <iostream> #include<map> using namespace std; map <long long , long long> h; void sieve(long long start,long long size) { long long i,j; for (i=2; i*i <= size; i++) { if (!h[i]) { for(j = i+i; j < size ;j+=i) { h[j] = 1; } } } for (i=2; i<size; i++) { if (!h[...

Help with Pointer Arithmetic

Hi all, I've been studying C++ for a test and I am currently stuck with pointer arithmetic. The basic problem is the following: int numColumns = 3; int numRows = 4; int a[numRows][numColumns]; a[0][0] = 1; a[0][1] = 2; a[0][2] = 3; a[1][0] = 4; a[1][1] = 5; a[1][2] = 6; a[2][0] = 7; a[2][1] = 8; a[2][2] = 9; a[3][0] = 10; a[3][1]...

Data conversion between int and char

Hello all I am studying for a C++ test, I have not been able to solve this: I have data in a int* and I want to print it out to a char* I thought I could do it the following way: // pOutputString is of type char* // pIntegers is of type int* int pos = 0; for (int i = 0; i< SIZE; i++) { pOutputString[pos] = char(pIntegers[i]); p...

Could you grade my relational algebra answers?

I have a Databases exam tomorrow and I have been running over some past papers to check whether my relational algebra knowledge is up to a decent standard or not. If it isn't I'm going to stop working on it now and focus on other possible question types (DDL, Normalization) that may also arise. If it needs just a little bit of work the...

Factorizing a number

I've got a number which is less than 500,000,000 and I want to factorize it in an efficient way. What algorithm do you suggest? Note: I have a time limit of 0.01 sec! I've just written this C++ code but it's absolutely awful! void factorize(int x,vector<doubly> &factors) { for(int i=2;i<=x;i++) { if(x%i==0) { dou...

What will be the time complexity of the following algorithm ?

for(i=0;i< m; i++) { for(j=i+1; j < m; j++) { for(k=0; k < n;k++) { for(l=0;l< n;l++) {if(condition) do something} } } } ...

Parallelized sorting algorithm, a good choice

Hello buddies! I wanna implement a fast algorithm for a homework, but using parallel processing for this task. I heard that the parallel version of Quicksort is the best choice, but I'm not sure of this... maybe Heapsort is a good idea. Which algorithm do you think is the best one for a parallelized environment, and why? Regards. ...

Database Theory: Transaction serializability

Hy, I'm learning for my exams and came over the following question: Take the History (or Schedule) H = w1[x] w2[x] w2[y] c2 w1[y] w3[x] w3[y] c3 w1[z] c1 where w1[x] means: Transaction 1 writes to Data-Object X (r1[x] means read) and c1 means: Transaction 1 commits. Why is this transaction view serializable? For view Serializabilit...

Coin flipping game: Optimization problem

There is a rectangular grid of coins, with heads being represented by the value 1 and tails being represented by the value 0. You represent this using a 2D integer array table (between 1 to 10 rows/columns, inclusive). In each move, you choose any single cell (R, C) in the grid (R-th row, C-th column) and flip the coins in all cells (r,...

What is the problem with this piece of C++ queue implementation?

Hi everyone! I'm trying to write a linked queue in C++, but I'm failing so far. I've created 2 files by now: my main.cpp and box.h. When trying to use my box, I receive the following message: Description Resource Path Location Type conversion from ‘Box*’ to non-scalar type ‘Box’ requested main.cpp /QueueApplicati...

Trying to use a while statement to validate user input C++

I am new to C++ and am in a class. I am trying to finish the first project and so far I have everything working correctly, however, I need the user to input a number to select their level, and would like to validate that it is a number, and that the number isn't too large. while(levelChoose > 10 || isalpha(levelChoose)) { cout << "...

How to union, intersect, difference and reverse data in java.

Hello! I have some problem, i want to union, intersect, difference and reverse operator in java. first i have 2 arraylist a = [0,2,4,5,6,8,10] b = [5,6,7,8,9,10] a union b is return c = [0,2,3,4,5,6,7,8,9,10] a intersect b is return c = [5,8,10] a defference b is return c = [0,2,3,4] reverse a = [10,8,6,5,4,2,0] something like t...

[C#] Get only the first 10 number of a X lenght digit.

Hello all. I have a method , that calculates distance between two xyz cords, and return me a nice long double number like 10,12345678963235. But I only need 10,12345 , that would be enought for me. How can I do this? This is the method that returns me the value: public static double Distance(Vector3 v1, Vector3 v2) { return ...