homework

Is DataSet slower than DataReader due to...?

Hello, 1) A) DataSets can be 10+ times slower than DataReader at retrieving data from DB. I assume this is due to overhead of DataSets having to deal with relations etc. B) But is the speed difference between DataSets and DataReader due to DataSets having to retrieve more data ( information about relations ... ) from DB, or due ...

Card Shuffling in C#

I am trying to write a code for a project that lists the contents of a deck of cards, asks how much times the person wants to shuffle the deck, and then shuffles them. It has to use a method to create two random integers using the System.Random class. These are my classes: Program.cs: using System; using System.Collections.Generic; u...

Array Homework Question

You are given an array with integers between 1 and 1,000,000. One integer is in the array twice. How can you determine which one? Can you think of a way to do it using little extra memory. Algo: Solution 1: Have a hash table Iterate through array and store its elements in hash table As soon as you find an element which...

Function to return 3^k in n+1 calls

Can someone hep me find an algorithm for a recursive function func(int k) to return 3^k in only n+1 calls where k is in the range [ 3^n, 3^(n+1) ) For example, the function should return 3^1 or 3^2 in 1 call, 3^3, 3^4, .. 3^8 in 2 calls, 3^9, 3^10 .. in 3 calls and so on. ...

Please explain two lines to me

typedef vector<double>::size_type vec_sz; vec_sz size = homework.size(); ...

Are the solutions to Stanford's online iPhone development course anywhere on the web?

I am working through Stanford's online CS course for iPhone development and from time to time I get stuck on something. Does anyone know if they supplied solutions to the weekly homework anywhere? It would also be nice to have something to check my work on after I finish each lesson. The course has been over for some time so I don't thin...

Add and subtract two integers without using the + or - operators in java

how can add two number without using + or - operators in java.. I have found one link for the same in c. http://prokutfaq.byethost15.com/AddTwoNumbersWithoutArithmetic But, i am not able to implement in java. Please help me. ...

How to add 50-digit numbers in C++?

In C++ I want to add two 50-digit numbers. I use an array to keep each. It means that I want to add two arrays. My problem is that I want to do this in a function named AddNum() and pass the result to another function named WriteNum for printing and I don't know how to pass an array returned by one function to another function. hope that...

C++ w/ static template methods

Template methods as in NOT C++ templates. So, say that you would like to do some searching with different algorithms - Linear and Binary for instance. And you would also like to run those searches through some common routines so that you could, for instance, automatically record the time that a given search took and so on. The templ...

How to save contacts in an address book and list them?

I am working on making an address book in C# 2008. I need to be able to save the contacts and then later display them when the user asked for it. I also need to handle an exception when someone enters an unknown color when writing the person's favorite color. This is my code so far: using System; using System.Collections.Generic; using ...

why are standards for teminology and diagramming notation as defined by UML so important for the success of the object oriented approach?

I try to research every pages about UML. There none of impact about UML.. anyone have this experienced before? what i mean is the standard of terminology and diagramming itself.. and the reason why uml so important for the success of the object oriented... ...

Queue in An Array

Problem: to understand the solution, when the length of the queue is 5. Exercise: Its solution: Question: Why is the solution not C A B B B, otherwise everything the same in the "Solution"-picture above? Source, (the solution and exercise at "10:02.03-08.03") ...

To make a plan for my first MySQL project

I need to complete the plan of a ask-a-question site for my uni. in a few days. I need to have the first version of the code ready for the next Tuesday, while the end of the project is in about three weeks. Questions about the project which do not fit here to make efficient tables to improve a relation figure to improve a ERD diagram ...

Find the most frequent numbers in an array using LINQ

List<int> a = new List<int>{ 1,1,2,2,3,4,5 }; What's the quickest way to do this with LINQ? I'm new to LINQ ...

passing variables into another form

i am developing a windows app in c#..i have used three decimal variables:counter,narrow and broad which stores different values based on some calculations. On clicking a button, a message box is displayed displaying these three decimal values and the application exits.. now i want to add another form having three labels in which these v...

Recursive non-binary, non-sorted tree search using c# lambas

class TreeNode { public string Value { get; set;} public Collection<TreeNode> Nodes { get; set;} public TreeNode() { Nodes = new Collection<TreeNode>(); } } 1) How would you write the recursive lambda expression to return the TreeNode with a particular value (or null if not found) assuming the values are u...

Try Catch Block in Java

So I'm given this code and I have to create an Exception and then use a Try Catch Block to catch it. I've already made the Exception, at the bottom of the code. But I've never used a Try Catch Block before and am not sure how to implement it. The Exception is if a rank that isn't listed under the enum is entered. I need to use a toStri...

stretch image to fit in td

I want to stretch an image in my td cell. How to do that. Its is a tab image which looks like inverted of this |____|. I need to place the image in the first td cell which contains the text 'aaa' will come in center of this image. Thanks ...

Sort array in ascending order while minimizing "cost"

I'm taking comp 2210 (Data Structures) next semester and I've been doing the homework for the summer semester that is posted online. Until now, I've had no problems doing the assignments. Take a look at assignment 4 below, and see if you can give me a hint as to how to approach it. Please don't provide a complete algorithm, just an app...

Relational UML Diagram inspired by SO

My homework was to create a relational UML diagram about a discussion site. I used the SO schema, and I did some modifications: removed Age in the User Information added representatives, which allows users to categorise posts by their usernames (voluntary) Otherwise, the schema is rather similar, but rudimentary. How would you improv...