homework

Java: Expanding array size, can't seem to keep all values in original locations.

For my current homework, I'm trying to sort my array through a generic class as the user inserts values into its locations. When the size reads as fully loaded, the array class calls in an expansion method that increases the size of the array while retaining its values in proper locations, which I followed from my Professor's note. For s...

Still problems with LLIST *mylist[x]

So I have... int x; LLIST *mylist[x]; x =10; bzero(mylist, sizeof(LLIST *)*x); this does not seem to be a valid solution.. I did add the -std=c99 to my make file, just this alone did not work which is why emil suggested the above approach, because I had originally: int x=10; LLIST *mylist[x] = {NULL}; My make file lo...

Referring to "C - Help understanding how to write a function within a function (list_map)"

I have the same professor: I have read the forum: http://stackoverflow.com/questions/2119558/c-help-understanding-how-to-write-a-function-within-a-function-listmap/2119913#2119913 It is very helpful understanding the concept of the function but I'm not sure if I am using it right... Here is my code.. Let me know if I am on the right ...

C Linked list only contains first element...not sure what happens to rest.

I posted a question a few days ago about a linked list in C. I thought everything was ok then the prof emails us saying that instead of this signature: int insert_intlist( INTLIST* lst, int n); /* Inserts an int (n) into an intlist from the beginning*/ He accidentally meant: int insert_intlist( INTLIST** lst, int n); /* Inserts an i...

How do you determine the best, worse and average case complexity of a problem generated with random dice rolls?

There is a picture book with 100 pages. If dice are rolled randomly to select one of the pages and subsequently rerolled in order to search for a certain picture in the book -- how do I determine the best, worst and average case complexity of this problem? Proposed answer: best case: picture is found on the first dice roll worst case...

Global variables in C++

I am supposed to write a program that should read from input numbers in the main() part, and then make some calculations in other bool functions. I don't want to insert the whole arrays of the numbers and all the other parameters in the functions everytime i call them. My question is this: Can i make somehow in c++ to read input in som...

understanding functions and pointers in C

Hi, This is a very simple question but what does the following function prototype mean? int square( int y, size_t* x ) what dose the size_t* mean? I know size_t is a data type (int >=0). But how do I read the * attached to it? Is it a pointer to the memory location for x? In general I'm having trouble with this stuff, and if anyb...

wireshark pluginds

Do you know a website that has latest security issue for wireshark that need a solution. I know wireshark mailing list but is there another website than this? my teacher is asking us to report 5 problem that need to develop a plugin for wireshark. Thank you, ...

Error from gcc compiler

Hi, What does the following error mean: In function `get_ints`: `l` undeclared (first use in this function) Thanks, Josh ...

Understanding pointers with file i/o in c++

I'm trying to get a better grasp on pointers. My class assignment was to create the function for the prototype void OpenFile(const char *fileName, ifstream &inFile). void OpenFile(const char *fileName, ifstream &inFile) { inFile.open(FILENAME, ios_base::in); if (!inFile.is_open()) { cerr << "Could not open file " << fileNam...

HTTP PUT method implementation in C

I need to implement the HTTP PUT method in C using TCP socket. Can anyone help me out? ...

How to erase existing text in a file

I'm working on an assignment for school, and am trying something beyond for extra credit. The program is to demonstrate the efficiency differences between a linear & binary search for a given array size of integers. I have a loop set up that creates an int[size] array, searches for a random number, then creates a new array of int[size*...

C homework help: Searching through arrays

I'm working on a problem where I'm given a sorted array of integers, and I am supposed to take an input from the user, search for the input, and return the first instance of that input (if it exists) and the number of times it appears. I wrote a program with the following approach: I take an input from the user. I then use binary search...

ArrayList Confusion and assistance!

hi, basically id like a few hints or tips on how to solve this question.. maybe a few things which i could read up on about arraylists and loop which would make it simple for me to understand!.. the question is : Processing an ArrayList of Characters: cList is an ArrayList of objects of type Character that has been declared and in...

Why am I getting array elements with "0"? (See pastie inside)

Hey there. Java beginner here :) Well, I'm having a few troubles with this program: http://pastie.org/private/sfqqnqwxtpgtuhswpqepw 1) I want my program to split up the "input" array into an oddList, evenList and negativeList set of arrays. However, when splitting it up, it is adding a bunch of elements as "0". 2) 0 needs to be added o...

Implementing 5-variable function using multiplexers

If I have a 5-variable function (below) and I want to implement it using a multiplexer, how would I do that (using the minimum possible multiplexer): f(A,B,C,D,E) = A + C'D + BD' + B'D + B'CE This is homework, so don't provide a solution, just a guidance of how that works. Thanks! ...

Simple MATLAB/Octave simulation

This should be a very simple question for anyone who has some experience in this area, but I'm still new to this. I have the following system (or here is an image with better resolution): Given the following input: u = min(2 - t/7.5, 2*(mod(t, 2) < 1)); I need to plot the output of system y. I am describing the system with the fo...

EBNF to BNF Conversion

I have a homework problem which I could use some help on. I need to convert the following EBNF statement to BNF <S> -> <A>{b<A>} <A> -> a[b]<A> This is what I have come up with so far; <S> -> <A> | <A><S> | b<A> <A> -> a<A> | ab<A> It doesn't feel right, mainly because it's a WAG. The example in my book (Concepts of Programming Lan...

C compiler complaining about void (*)

My professor defined this in the .h file void list_map(INTLIST* list, void (*f)(void *)); /*Applies a function to each element of the list */ I wrote the function like this: void list_map(INTLIST* list, void (*f)(void *)) { INTLIST* pTemp=NULL; if (list == NULL) { //list is empty } else { for(p...

String hashing with linear probing

Hello, I am stuck trying to figure out how to do string hashing with linear probing. Basically, the idea is to hash every string from a dictionary (90000 words), and retrieve anagrams of selected words. Here's what I did: created a hash table 2*90000 in size using a simple hash function, I hash each word from the dictionary, get a v...