rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The rules here are that for school work we will help you AFTER you have made an honest effort at solving your problem. So far, you are just asking us to cheat for you... :-(

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If this is a balanced tree, then you need to rebalance when deleting the node. This is usually done recursively, which I don't think you are doing. Recursive algorithms are often MUCH simpler than trying to do the same thing in-line, though they may be a bit more resource intensive (stack memory and function call overhead mostly). Class exercise? Another approach is to walk the tree from left to right, creating a new tree, skipping the deleted node. If the tree isn't too big, this can be very effective, and possibly better (other than memory usage) than rebalancing the tree in-situ.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A video file is already in binary. What operating system are you using? There are a lot of tools to do what you want. Both ffmpeg and vlc (and other tools) have video streaming capabilities. You can also use something like netcat (nc) to send the data to another system, using netcat to receive it and output to a local file. Do you have to use python? In any case, try some Google searches - there are a ton of tools out there to do this.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What operating system are you using? If Linux (or Cygwin on Windows) you can use netcat (the nc command) to send/receive data. If just reading, then you can use wget.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

SQL Server, or something else? Look up the C# documentation for ODBC.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, since you want to do it yourself, the old cfront C++ precompilers would do that for you just fine (up to the point you need to convert template classes and functions), and I believe that the current GNU C++ compiler will do that with the -E option. However, the differences between C and C++ from both the syntactic as well as the semantic perspectives are VERY different languages. At the most simple, you can consider C++ to be C with structures that have embedded functions, and replace the functions with external functions that pass a pointer to the structure as the first argument (the "this" pointer). In fact, the cfront precompilers do just that. However, getting to modern C++ with templates and such, that is a VERY different kettle of fish!

So, I have to ask why you want to do this? I don't suppose it is an assignment for a computer languages class?

In any case, there is NOTHING simple about this. I am considered to be an expert in C and C++ - I've been programming in C since 1982 and C++ since 1991, and have used both languages to design and develop complex software that runs many major enterprise systems, and I would not bother to translate C++ to C these days. Maybe 20+ years ago before templates and such - and consider that I have also designed and implemented non-trivial computer languages (compilers and interpretors) for specialized purposes (including the US Navy).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Let's see if I understand what you want to do.

  1. Search a file.
  2. Find string1 that is followed in the same line by string2
  3. Follow string2 with string3, in the file, written back to disc?
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some call C a "high-level assembly code" language, though it really isn't (in my opinion). Assembly language is as close as you will want to get to machine code. Do remember that each processor family has a different instruction set, and trying to do machine code on modern computer gear would likely be a great exercise in futility! :-)

The last time I wrote binary code was for a boot loader for an IMSAI 8080 S100 bus computer in the 1970's. Until we burned it to a ROM, we would input it via front-panel switches on the box. When executed, it would load CP/M from a floppy disc so we could do some real work, such as writing a clone of Space Invaders...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The Fibonacci sequence. It is as np_complete said, with the addition that by definition Fib(0) == 0, Fib(1) == 1.

int fib(int n)
{
    if (n == 0) return 0;
    else if (n == 1) return 1;
    else return fib(n-1) + fib(n-2);
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also Qt is cross-platform. I've used it for Windows and Linux cross-platform development quite nicely.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The overhead of function calling is directly proportionate to the number of arguments and automatic variables declared in the function. They all have to be pushed onto the stack. Also, deep recursion will cause similar overhead. That said, you are generally better off to have a bunch of small, easily understood functions rather than just a few big/complex ones. Remember the KISS principal. It is pre-eminent in software engineering.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

When I was studying mechanical engineering back in the 1960's, Fortran was a required course. I am now a software engineer... :-) FWIW, my wife, the physicist, is one of the few people I know who still use Fortran, and mostly she uses C++.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Besides circular queues, looping pointer constructs are necessary to deal with when you have references to other types of items, and they may have a reference back to one of the parents in the hierarchy. There are a number of methods to detect these situations, some of which I have dealt with in the past when writing reference-counting garbage collectors for C++. One method is to use a stack and starting at the top of the list/tree and as you traverse each item, you search the stack for the next item. If found, then you have a circular (recursive) link. If not, then push the address onto the stack and continue. The cost is proportianate to the depth (complexity) of the list. I utilized some other techniques for my C++ garbage collector because I needed it to perform in a deterministic mannger for near real-time systems.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are some excellent Qt tutorials out on the web. Fire up your Google search tool and find them...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here you are...

#include <stdio.h>
int main(void)
{
    printf("Hello World!\n");
    return 0;
}
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can remove the drive from the laptop and try to boot into the BIOS. If it still "lets the smoke out", then the system is fried, though the HD may be recoverable as far as your data is concerned. If it can get to the BIOS, then it may be the HD, but in my experience smoke is usually associated with stuff other than the HD. Save the HD, get a new laptop and a docking bay for the HD (costs about $25) and you may be able to recover your data files.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I've done that in the past using raw sector editors. You usually have to boot into a live CD/DVD/USB system to do that, and it is very dangerous - you really need to know precisely how the file system is organized, and that is not always easy. All file system types are very different, such as FAT, NTFS, Linux ext2/3/4, xfs, ufs, zfs, etc al. Assuming you are referring to Windows systems, then you have FAT-16, FAT-32, and NTFS. With NTFS you may also have compressed or encrypted folders, which becomes another major issue. I have 30+ years of software engineering experience, including implementing file systems of various types, and even I don't bother with raw sector editing - the last time I did that was probably 20-25 years ago when I had no choice.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Some aspects of building a TCP/IP stack from scratch are very subtle. I have a "fond" memory of sitting in a small lab/office in an engine manufacturing plant in Indianapolis to debug and fix our OOB (Out-of-Band) message handling which wasn't working properly. Three solid 12 hour days of debugging, coding, testing... :-)

One thing that is absolutely necessary to understand the protocols and to code them is a complete understanding of finite-state machines (FSMs). It is impossible to implement them without using FSMs extensively. In such cases, either you have to write your own FSM handling code (which I did), or you resort to a lot of lex/yacc rules. My method was more efficient because I could tune the FSMs by editing a text file of rules and restart the applications/servers instead of regenerating C code with lex/yacc, recompiling, relinking, etc. The time I saved doing that was significant - we figure it cut a year off the development time. In 6 months we had a functioning system, and there were only two of us working on it. Most of our time was spent validating the state-machines by careful analysis of the RFCs in the White Books.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The TCP/IP protocol suite was formulated by the US Department of Defense's Defense Communications Agency and originally implemented by DARPA (Defense Advanced Research Projects Agency) in conjunction with the company Bolt Beranek Newman, Inc. in Cambridge Massachusetts. The specs are in the form of RFCs (Requests for Comments) in a set of very big books called the DDN Protocol Handbook. The most popular implementation is the Berkeley Sockets Library, written by the Berkeley Software Distribution (BSD) team at the Universiy of California, Berkeley. This is the source used by most Unix and Linux distributions. FWIW, I did a complete TCP/IP implementation for a real-time operating system, working solely from the DOD White Books, as the DDN Protocol Handbooks are called, back around 1990. The handbooks came out in the 1980's - my copy is from 1985, and it takes up a good foot of shelf space. Our implementation was able to communicate over ethernet to any system that had a TCP/IP protocol stack over ethernet, ranging from mainframe computers to mini-computers to PC's.

silvercats commented: woha +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please be more specific as to what your particular problem is, and what you want to do to resolve it. Just saying "remove limited connectivity from LAN connection" is not particularly helpful in understading your real problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Myself, I use usually use quicksort for existing arrays that can be sorted in-situ, and a head-tail-optimized insertion sort (using a bsearch algorithm to find the insertion location) when I am adding elements to an empty or already sorted array or if I need to sort the elements of an array that must be left untouched. The head-tail optimization sped up inserting into sorted arrays tremendously for large arrays (thousands of elements).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Here is an excellent wikipedia article on quicksort, including sample pseudocode illustrating how to implement the algorithm: http://en.wikipedia.org/wiki/Quicksort

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You are a graduating BIS student and you are not much of a programmer? Business information systems are all about programming - implementing complex business logic with computer systems. What kind of systems have you studied? What interested you the most? What could you do that would help push that area ahead from the perspective of the people impacted by those systems? These are the questions you need to be asking yourself - then you might find a project that will suit you.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The variable i needs to be instantiated outside of main, either in the same file, or in another one that is subsequently linked to create the executable. Try this:

#include <stdio.h>

int i = 0;

int main(void)
{
    extern int i;
    i=20;
    printf("%d\n",i);
    return 0;
}

In any case, your code should compile, but it will not link as it stands. Actually, the compiler should complain and may error out since you forgot the return value.

WaltP commented: I don't understand the purpose of this post. The code is essentially identical to the OP's code, and the information is just restating what decepikon said. Did you read his post at all? +0
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The port number of the sending and receiving tasks are usually different. A server will listen on a known port, and when the client connects to it, it will provide an anonymous port to use for that connection.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I see I didn't look at the date - I must have hit the "end" option instead of "next" on the main page... Oh well, stuff sometimes happens!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Well, you can use something like gnuplot to generate charts and graphs, and there are development toolkits such as Qt that are great frameworks to build tools that generate graphical tables, text forms, etc, and can easily pipe the data into gnuplot or gimp for more technical graphs. Qt is available for both Windows, Linux, and some smartphone operating systems, as is Gnuplot (I think) - not so sure about Gimp - it is mostly a Linux tool. Anyway, here is a link to Linux business intelligence and reporting tools: http://www.linuxlinks.com/article/20100101053947560/BusinessIntelligence.html - most or all of them are open source.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You scan variables n and qi, malloc ni and arr, and nowhere do you do any bounds checking or verifying that you got a valid memory address. In addition, malloc() returns a void pointer, so assigning it's output to a long pointer is invalid code unless you make an explicit cast.

All that aside, running this code in a debugger will help you find out what is going on and where it is crashing. You say you have a thorough knowledge of C and C++, but that is not the impression I get from your code. :-(

A couple of final comments/questions: why are you starting your array indexes at 1? C/C++ are indexed from 0, and main() without argc/argv should have the signature int main(void)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There are all kinds of html to pdf converters on the market, and a PDF is eminently printable.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
itemWord* findDup(itemWord* head, itemWord* item)
{
    for (itemWord* curr = head; curr != 0; curr = curr->next)
    {
        if (curr != item && strcmp(item->word, curr->word) == 0)
        {
            return curr;
        }
    }
    return 0;
}
void removeDup(itemWord** head, itemWord* item)
{
    itemWord* prev = 0;
    for (itemWord* curr = *head; curr != 0; curr = curr->next)
    {
        if (item == curr)
        {
            if (prev == 0)
            {
                head = &(curr->next);
            }
            else
            {
                prev->next = curr->next;
            }
            free(curr);
            return;
        }
        prev = curr;
    }
}
int main(void)
{
    itemWord *curr = 0, *head = 0;
    int done = 0;
    .
    .
    .
    /* This will get rid of ALL duplicates, even if there are muliples.
     * An optimization may be to avoid rescanning the list. That said,
     * I haven't run this code, so it may need some tweaking! :-)
     */
    while (!done)
    {
        int gotone = 0;
        for (curr = head; curr != 0; curr = curr->next)
        {
            itemWord* found = findDup(head, curr);
            if (found)
            {
                removeDup(&head, curr);
                gotone = 1;
                break;
            }
        }
        done = !gotone
    }
    return 0;
}
WaltP commented: Doesn't anyone look at posting dates anymore???? It's a freaking 4-year old thread! -3
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can also use a state machine to model this simple of an entity, which a DFD is at a fundamental level (sort of).

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Take the input into a string, the use the strtof(const char* ptr, char** endptr) function to convert the string to a number. You pass the address of a char* variable as endptr and if the conversion stops because it encounters a non-float character in the string, endptr will be set to the location in the string where that occurred. At that point, you can determine whether to compute the results, or output an error message. Bear in mind that strtof() and strtod() will both handle scientific notation such as "1.25E22", as well as hexadecimal and octal numbers, so if you want to be more rigorous in your treatment of the input you will need to walk the string and decide whether or not you want to accept it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Create a class with all of the values, call it AgeGroup. Create a map<int,AgeGroup> object where the int part is the age, and the object is the other member. Then read each csv record into an instance of the object, and insert that into the map. Example (not complete, won't compile):

map<int,AgeGroup> ageList;

while (not-done-reading-csv)
{
    AgeGroup member = read-csv-record;
    ageList[member.getAge()] = member;
}

This will give a list of records, nicely sorted by age. Then, counting the number of members of each age, etc is a matter of iterating through the list.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try this:

        double results = kilo * sqrt(metre);
        String response= results + " " + FirstName + " " + Lastname;
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Most of these cards have built-in antennas, but provide external antenna leads so you can install better or high-gain ones for better distance and performance.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There was a bug in Win7 early on (fixed with a patch earlier this year) where the CPU would get "stuck" at a slow speed, even when plugged into wall power. A number of my co-workers had this problem. I don't remember just off-hand what the patch was, but you should be able to find it on the MS web site. Also, get the CPUz tool (freeware). It will interrogate your system and tell you all about it, including what speed the CPU and bus are running. You can get it here: http://www.cpuid.com/softwares/cpu-z.html

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Connect an external display and go into the BIOS setup. You might find the information you need there.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What are you using for an editor? Have you modified the file and directory permissions so you can save a new version of the file?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can enable the source code repository and download/install the kernel source code with the yum command. Alternatively, you can download the kernel source code RPM file from a CentOS mirror site and install it directly, again with either yum or rpm commands. And yes, you will need the kernel source if you are going to add your own system call. I would strongly suggest that you do some studying of how to configure, build, and install custom kernels. There are a lot of documentation, manuals, etc on both the kernel.org and tldp.org (The Linux Documentation Project) web sites that will help a lot.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have a live or recovery cd/dvd/usb drive, you can boot into that and fix the file systems with fsck. However, as AHarrisGsy mentioned, it would be good for you to provide a bit more information.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I just downloaded and burnt the CD and booted it to explore it a bit. It is an awesome set of tools. One that is on the mini-xp image is called s&mstress which will stress test the system CPU, power supply, hard drives and controllers, etc. That would probably help determine if your problem is the power supply, or something else.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I suspect that the power supply is faulty, though it could be a problem with the motherboard as well. You need some diagnostic tools to check the system board and power supply. This is a free one that has good reviews (self-booting CD image): http://www.hiren.info/pages/bootcd, and here is a link to the download image: http://www.hirensbootcd.org/files/Hirens.BootCD.15.1.zip

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Does the drive have an external power supply, or are you just powering from the USB port?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

MS-DOS was written in assembler, as was CP/M, TRS-DOS (for the TRS-80), et al. There is an open source version of DOS (FreeDOS) which certainly has a fair amount of assembler in it (it's mostly in assembly language). Here is a link to the download page: http://www.freedos.org/download/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The IEEE has a CSDP (Certified Software Devlopmen Professional) training/certification program, and I think you can choose your language of preference. This is the pre-cursor for the upcoming IEEE professional engineering (PE) certificate in software engineering. Up to now, software engineering has not been considered rigorous enough for a PE standing, unlinke mechanical, electrical, civil engineering (and other) disciplines. This is changing, and a PE in software engineering is either now available (or will soon be) in Texas and Illinois. For more information, go to http://www.ieeeusa.org/

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Another approach is to use the strtod(const char* nptr, char** endptr) function. You pass the string containing the number, and the address to a char* which will be set by the function to the first non-numeric character. FWIW, strtod() [double] and strtof() [float] will also accept scientific notation, such as 1.254e25. This is the technique I usually use, although I also will utilize an algorithm that walks through the string to check each character in some specific (rare) circumstances where I need to validate a particular numeric format.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If this is homework, please try to solve the problem on your own first, before you ask us to help you. Then, post your code or other work product here for comments, corrections, etc.

In any case, fibonacci numbers are where fib(n) = fib(n-1) + fib(n-2), so exponentiation should not a factor here. Show us the math!

FWIW, I have been using fibonacci sequences for almost 30 years for many situations ranging from balancing stock portfolios to determining the most optimal server to process a network request. Needless to say, it is a subject of which I have some small knowledge... I first implemented the algorithm in C in 1983. :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What distribution+version of Linux, and which kernel, are you running? This problem is usually due to a missing new-line at the end of the command stream. Edit the file, and add a new line at the bottom, then save the file and try again.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If it won't get to the POST display, then it is a hardware problem. If you can't remove the DVD drive directly, then the next time you get to a POST, go into the BIOS setup and see if you can disable it. Then see if the problem continues. That will at least eliminate the DVD/CD ROM drive as a cause. If that doesn't work, then there is some other hardware issue and you need to send it in for repair, or if it is more than 3 years old, replace it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Sleep a bit before exit(0). I think you are running into a race condition and your parent is getting a SIGCHLD signal (you dieing) about the same time it gets the SIGUSR1 signal.

FWIW, using signals to communicate between processes is very dangerous and error-prone. It's use is common enough, but it is very easy to get into bad situations.