homework

Interesting compiler projects

I'm currently in the process of choosing a project for a grad-level compiler course to be done over the next 8 weeks. I'd like to do something related to optimization since I haven't worked much in that area before, but anything in the field is fair game. What was the most interesting compiler-related project you've done? What did you ...

What will pNext be in the following case using C/C++?

func() { Object* pNext; func1(pNext); } func1(Object* pNext) { pNext = Segement->GetFirstPara(0); } I was expecting it to be pointer to firstpara returned from func1() but I'm seeing NULL can some explain and how to fix it to actually return the firstpara() pointer? ...

How to paralleize search for a string in a file with a help of fork? (GNU Linux/g++)

This is how the situation looks: I got a text file with a couple of lines and I am looking for a string in this file. I need to pass following command line parameters to the program: - file path - the string I am looking for - maximum number of processes the program is allowed to "fork" in order to complete this task. How to such pr...

Swap every pair of characters in string

I'd like to get all the permutations of swapped characters pairs of a string. For example: Base string: abcd Combinations: bacd acbd abdc etc. What's the best way to do this? ...

Printing out items in any Collection in reverse order?

Okay, so I have the following problem in my Data Structures and Problem Solving using Java book: Write a routine that uses the Collections API to print out the items in any Collection in reverse order. Do not use a ListIterator. I'm not putting it up here because I want somebody to do my homework, I just can't seem to understand exact...

How do you reverse a string in place in C or C++?

How do you reverse a string in C or C++ without requiring a separate buffer to hold the reversed string? ...

Programming timing shellscript measuring program execution time at 0 seconds.

My professor wrote this shell script to time my program, and display the results. For some reason it just outputs 0s with my program. He provided the following files: timeit.csh sequence ecoli2500.txt ecoli3000.txt ecoli5000.txt ecoli7000.txt ecoli8000.txt ecoli9000.txt ecoli10000.txt Here are the contents of ...

fast filter method in python

I want to filter two list with any fastest method in python script. I have used built in filter() method for this purpose. but it is quite slow and taking too much time because I have very big list, I think more than 5 million item in each list or may be more. I do not know how I will make it. Please if anybody have idea or write small ...

finding largest increasing subset of an array (non-contiguous)

How can I find the largest increasing (non-contiguous) subset of an array? For example, if A= array(50,1,4,9,2,18,6,3,7,10) the largest increasing non-contiguous subset is either (1,4,6,7,10) or (1,2,6,7,10). I can intuitively see how to find the subset, but I don't know how to design the algorithm. thanks. ...

What is the best Agile methodology for a class project?

The project is poorly defined: we are to write educational software for CS 111 Computer Programming I students focusing on functions. We have 6 student developers with various backgrounds working in Flex. The project has a duration of about 7 weeks. We have very limited face time (30 min per week) and very limited work time (<8 hours per...

How to read until EOF from cin in C++

Hi, I am coding a program that reads data directly from user input and was wondering how could I (without loops) read all data until EOF from standard input. I was considering using cin.get( input, '\0' ) but '\0' is not really the EOF character, that just reads until EOF or '\0', whichever comes first. Or is using loops the only way to...

learning a new language

I am planning to do a project in my spare time. I have some experience in Java. Please suggest a programming language I can pick up easily. ...

Recursion and Big O

I've been working through a recent Computer Science homework involving recursion and big-O notation. I believe I understand this pretty well (certainly not perfectly, though!) But there is one question in particular that is giving me the most problems. The odd thing is that by looking it, it looks to be the most simple one on the homewor...

C++ Recursive Traversals with Function Pointers

template <class T> void BT<T>::inOrder(void (*inOrderPtr)(T&)) { inOrderPtr(inOrder(this->root)); } template <class T> void BT<T>::inOrder(Node<T>* root) const { if (root->left != NULL) inOrder(root->left); //something here if (root->right != NULL) inOrder(root->right); } Ok I am trying to create t...

C++ Binary Search Tree Insert via Recursion

So my code is below. I'm not getting any errors and it places everything in the node just fine. But based on my debug statements Everytime anything is inserted it's finding the root. I'm not sure if that is right. But according to output file for the assignment, my answers are different when it comes to the height of the tree, the tr...

how to read and write multiple files

I want to write a program for this: in a folder I have n number of files; first read one file and perform some operation then store result in a separate file and the read 2nd file again perform operation and save result in new 2nd file, even same procedure n number of files. The program read all files one by one and stores results of eac...

How do I search text then print the result?

I am searching for "o" then prints all lines with "o". Any suggestion/code I must apply? data.txt: j,o,b: a,b,d: o,l,e: f,a,r: e,x,o: desired output: j,o,b: o,l,e: e,x,o: ...

How do I interpolate variables to call a Perl function from a module?

Requirement is to pass module name and function name from the command-line argument. I need to get the command-line argument in the program and I need to call that function from that module For example, calling a try.pl program with 2 arguments: MODULE1(Module name) Display(Function name) perl try.pl MODULE1 Display I want to some t...

How to reference man pages in CS papers?

Hi, I am busy writing my thesis (so, I guess this could count as a homework question). Now, one of the things that came up was the Unix select system call. I would like to add a reference to the appropriate man page, but all I can find that seems the slight bit official is the Single Unix Specification site that wants my money first. Sur...

Visual C++: Avoiding overlapping of paint events, arching lines through click and drag?

I am currently a student and trying to design a Visual C++ application to allow me to visually insert an oriented graph in order to create a text file with the graph's matrix. At this point I have created an onClick event to create nodes and have used the form's Paint event to draw the nodes. I have also inserted the conditions to avoid...