I use a random function(Let's call it randomNum()) to generate random numbers(unsigned long) continuously(will generate about one million numbers in total).My question is How to determine whether the frequency of current number generated is greater than 20%(among the total numbers generated so far) efficiently?
Please write down your op...
i was wondering if anyone could by any chance help me. i have a school project due in 10 days and to be honest i have no idea what im doing =/ what is expected of me is that i program a memory game. where i am currently stuck is that i have to time how long it takes the person to play the game and then display how long it took them as a ...
I'm a first year compsci student who's extremely lost on this assignment. We are supposed to prompt a user for a number of random numbers to be generated and saved to a file. He gave us that part. The part we have to do is to open that file, convert the numbers into a list, then find the mean, standard deviation, etc without using the...
I have an error and a warning while trying to compile my linked list implementation in c
warning: assignment from incompatible pointer type
error: dereferencing pointer to incomplete type
here is the list.h
#ifndef LIST_H
#define LIST_H
#include <stdio.h>
typedef struct _ListElmt{
void *data;
struct ListElmt...
Hi,
I have an assignment to do and I can't figure out how to do one question.
Here is what I have to do:
" Write a function which collects all elements in the tree T which satisfies the property p and returns it. Traverse the tree in inorder.
Find all elements in BST satisfying f using success continuations.".
I did the following:
da...
generate all possible subsets of a given Set that contain n elements using stack and queue without using recursion.
and then find the complexity of this pseudo code
so if we have a set {1,2,3)
then the subsets are 2^n so its 2^3 and its 8 subsets
result will be
{}
{1}
{2]
{3}
{1,2}
{1,3}
{2,3}
{1,2,3}
...
heli_link_dis(h1,b1,800).
heli_link_dis(h1,b3,1400).
heli_link_dis(h1,b2,600).
heli_link_dis(h1,b8,1200).
heli_link_dis(h2,b4,400).
heli_link_dis(h2,b3,2000).
heli_link_dis(h2,b5,500).
heli_link_dis(h3,b5,1000).
heli_link_dis(h3,b6,400).
heli_link_dis = helicopter linked distance
h1 mean the name of a helicopter
b1 m...
char line[MAXBUF];
char *result;
while((result = fgets(line, MAXBUF, fp)) != NULL) {
printf(result);
}
The following code doesn't work fully. Does anyone know how to print result?? MAXBUF is defined to be 1024 and fp is just a file pointer to some file. What im suppose t...
Pass a integer 2 to this function and then return a integer which is 4
x = 2;
x = rotateInt('L', x, 1);
(left shift the bits by 1)
Example:
00000010 -> rotate left by 1 -> 00000100
but if I pass this:
x = rotateInt('R', x, 3);
it will return 64, 01000000
Here is the code, can someone correct the error... thanks
int rotateInt...
int x = 2;
x = rotateInt('L', x, 1); // should return 4
x = rotateInt('R', x, 3); // should return 64
Here is the code, can someone check it and let me know what the error is?
Compilation is successful, but it says Segmentation Fault when I execute it.
int rotateInt(char direction, unsigned int x, int y)
{
int i;
for(i = 0; i ...
So let's say we have a function such as 6wn^2 - 6wn + 6w, would the big-o notation be O(n^2) or O(wn^2)? The problem set question asks me to write this function in Big-O form in terms of w and n, so I think it's the second one but I've never seen a big O notation like that involving 2 terms so I'm a little confused.
...
I'm trying to determine if a phrase is a palindrome (a word that is the same from left to rigth) or not but i can't make it work. What's wrong?, i can't use pointers or recursion or string type variables
#include <stdio.h>
#include <string.h>
int main()
{
int i,j = 0,length;
char space = ' ';
char phrase [80],phrase2[80],phrase3[...
In data structures, I get converting in order and pre-order formula conversions into trees. However, I'm not so good with post-order.
For the given formula x y z + a b - c * / -
I came up with
-
/ \
* / (divide)
/ \ / \
x + - c
...
input:
Crypted English normal text (A-Z) using a random generated substitution cipher.
output:
key
ideas:
read the whole text storing in some arrays the frequencies for each character/bigram/trigram and comparing them to:
http://en.wikipedia.org/wiki/Letter_frequencies
http://en.wikipedia.org/wiki/Bigram
http://en.wikipedia.org/wiki/T...
Hi,
I'm trying to add to the code for a single layer neural network which takes a bitmap as input and has 26 outputs for the likelihood of each letter in the alphabet.
The first question I have is regarding the single hidden layer that is being added. Am I correct in thinking that the hidden layer will have it's own set of output value...
I have been struggling to write a simple code to sort an array of char in C and been failing miserably. This is what I have so far:
int main()
{
char line[128];
char word[128];
int i=0;
int j;
int length;
while(fgets(line,sizeof line,stdin) != NULL)
{
length=0;
i=0;
while (line[i]!='\0')
i++;
lengt...
Hello guys!
I'm working on a network application for my class. Basically I have to write java and jsp to make a site that gives the .jsp output below (which is preceded by a .jsp page that asks for the balance, rate, and period). I'm writing the java for it now and I'm trying to make a html table with the java class.
The problem I'm ...
Hi,
I have following code
class Test
{
public:
int &ref;
int a;
Test(int &x)
:ref(x)
{
cout<<"Address of reference "<<&ref<<endl;
cout<<"&a : "<<&a<<endl;
cout<<"this = "<<this<<endl;
}
};
int main()
{
Test *pObj = NULL;
{
int i = 10;
cout<<"Address of refer...
I am making a chat application for my homework which runs within a Linux Terminal. So, I need to take from the user some input and display the output from all the users as well in a well organized manner. So, I made two threads. One thread have a cin command and the other thread is having a display function which basically uses printf to...
Hi,
I have below code, running on 32-bit windows, visual-studio.
template <class T>
class Test
{
public:
T &ref;
Test(T &x)
:ref(x)
{}
};
int main()
{
cout<<"sizeof Test<int> : "<<sizeof(Test<int>)<<endl;
cout<<"sizeof Test<double> : "<<sizeof(Test<double>)<<endl;
cout<<"sizeof Test<char> : "<<sizeof(Test<char>)<<endl;
}
Ou...