I'm asked to find a 2 approximate solution to this problem:
You’re consulting for an e-commerce site that receives a large number
of visitors each day. For each visitor i, where i € {1, 2 ..... n}, the site
has assigned a value v[i], representing the expected revenue that can be
obtained from this customer.
Each visitor i is shown one ...
the program must read numeric data from a file.
only one line per number
half way between those numbers is a negative number.
the program must sum those who are above the negative number in a acumulator an those below the negative number in another acumulator.
the black screen shall print both results and determined who is grater or equ...
6.1.4 Describe an algorithm based on breadth-first search for finding a shortest
odd cycle in a graph.
6.3.5 Describe an algorithm based on directed breadth-first search for finding a
shortest directed odd cycle in a digraph.
what is most importent is that it must be a directed graph not necessary bfs but must be the shortest directed ...
For a project, I have to convert a binary string into (an array of) bytes and write it out to a file in binary.
Say that I have a sentence converted into a code string using a huffman encoding. For example, if the sentence was: "hello" h = 00 e = 01, l = 10, o = 11
Then the string representation would be 0001101011.
How would I conver...
i have to create a program which can have n number of nodes and each subnode can have n number of subnodes and so on, its not a binary tree.
i need to know how can one create it?
...
Given an area of specific size I need to find out how many pavement stones to use to completely pave the area. Suppose that I have an empty floor of 100 metre squares and stones with 20x10 cm and 30x10 cm sizes. I must pave the area with minimum usage of stones of both sizes. Anyone knows of an algorithm that calculates this?
(Sorry if ...
I am working with a basic C++ program to determine the area and perimeter of a rectangle. My program works fine for whole numbers but falls apart when I use any number with a decimal. I get the impression that I am leaving something out, but since I'm a complete beginner, I have no idea what.
Below is the source:
#include <iostream>
...
Hoookay, so. I'm trying to get the longestS method to take the user-inputted array of strings, then return the element number of the longest string in that array. I got it to the point where I was able to return the number of chars in the longest string, but I don't believe that will work for what I need. My problem is that I keep get...
I need to write a program where the program would generate random letter and i would need to store this random character into an array
char[] arrayRandom = new char[10];
for (int i = 0; i < 8; i++) {
randomNumLet = (generator.nextInt(20) + 1);
System.out.print(arrayRandomLetter[randomNumLet] + ...
Pls can someone tell me two physical methods by which a bit of information can be stored in a device attached to a computer...Thanks.
...
I've got a homework assignment that requires that I use Oracle 10g Express to implement an Object Relational database to track phone billing data. I have a superclass of Communications with subclasses of Call, Text, and Data. I'm hitting a snag with properly populating these tables so that I can find the appropriate data in the various...
I'm implementing an FTP-like protocol in Linux kernel 2.4 (homework), and I was under the impression that if a file is open for writing any subsequent attempt to open it by another thread should fail, until I actually tried it and discovered it goes through.
How do I prevent this from happening?
PS: I'm using open() to open the file....
I received homework to make program without casting using constructors so this is my code, I have two classes:
class Base {
protected:
int var;
public:
Base(int var = 0);
Base(const Base&);
Base& operator=(const Base&);
virtual ~Base(){};
virtual void foo();
void foo() const;
operator int();
};
class Der...
Hey all,
I need to write a simple Symbian application (console) to monitor battery voltage. I read about the CHWRMPower class (http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-4A98138C-4C68-3399-80E8-25CB41E43D5C.html) and other power related APIs, but I didn't manage to write something working, mainly due to lack o...
What is the size of this array?
float a[10];
...
Hello, I am making "game of life" implementation that, when cell has:
two live neighbours I make object of class CCellB
two live neighbours I make object of class CCellA
when has >3 or <2 I make object of class CCellX (dead)
Class CCell is base of CCellA, CCellB, CCellX
arr is previous state of game, temp will be new arr at the end.
...
Hello,
Can someone could be kind and help me out here. Thanks in advance...
My code below outputs the string as duplicates. I don't want to use Sets or ArrayList. I am using java.util.Random. I am trying to write a code that checks if string has already been randomly outputted and if it does, then it won't display. Where I am going wro...
proces P0: proces P1:
while (true) while (true)
{ {
flag[0] = true; flag[1] = true;
while (flag[1]) while (flag[0])
{ {
flag[0] = false; ...
In Chomsky's hierarchy, the set of recursive languages is not defined. I know that recursive languages are a subset of recursively enumerable languages and that all recursive languages are decidable.
What I'm curious about is how recursive languages compare to context-sensitive languages. Can I assume that context-sensitive languages ar...
I have a client server situation in which I receive data using
read(socket, char_buf, BUF_SIZE)
and then try to write it into a log file using
write(filefd, char_buf, strlen(char_buf))
Strangely enough this fails (write returns -1), and yet the errno is set to 0, and I can print the message, AND the log file descriptor works (I w...