I am trying to compute the depth of any(not necessarily complete) BST in O(log n) time recursively.
This is the algorithm I came up with:
//max() - returns the max of two numbers
int depth(root)
{
if(root->left==NULL && root->right==NULL) //leaf
return 0;
else if(root->left!=NULL && root->right==NULL) //with right leaf
...
I want to have a stack that takes strings. I want to be able to push and pop strings off, as well as clear the whole stack. I think C++ has some methods for this. What about C?
...
Hello,
I have a binary search tree created in c. The problem is I can't find a efficient way to delete all the nodes with e.g. id>5.
When I traverse the tree, if I delete a node, the recursion is getting error, because the structure is not the same.
Is there any way, instead of using a helping stack to keep the data before delete them...
Please help me in writing SWIG interace.
I want to open a database connection handle in C program. This handle must be passed to Perl, where I will use the Perl DB interface for interacting with the database. For security purpose we wanted to use this mechanism. I want to pass the database handle using SWIG interface.
Added:
We are ...
I have an array of structs. It's declared like this:
tableEntry [MAXSCOPE][MAXSIZE];
When the structs are created, C automatically initializes all the members to either 0 or null.
Let's say that I have given some values to the struct members of tableEntry[1][0], tableEntry[1][1], and tableEntry[1][2].
Now I want to reinitialize a...
Hi I am working in C on Unix platform. Please tell me how to append one line before the last line in C. I have used fopen in appending mode but I cant add one line before the last line.
I just want to write to the second last line in the file.
...
This question is based on a previous question: http://stackoverflow.com/questions/1917935/how-does-c-compilation-get-around-needing-header-files.
Confirmation that C# compilation makes use of multiple passes essentially answers my original question. Also, the answers indicated that C# uses type and method signature metadata stored in as...
i want my yylex to parse a string rather than a file or stdout.how can v do it in solaris
...
The print comes when the 'current lock owner' of a kernel resource is current CPU. I don't know what could lead to this condition. Couldn't find much on the net. Anyone debugged this?
...
I am writing a C project. Now I just doubt one function in the whole project may be take the most of computational complexity. If I can make sure about this, I can further improve this function with a more clear target.
Or, is there any tools for this usage?? I mean to find the most "expensive" function in the whole program or project??...
I think I know what #ifdefs I need to use to be x86-32 and x86-64 compatible on both msvc and gcc, see below. Is this complete for those platforms?
#if defined(_MSC_VER)
# if defined(_M_IA64) || defined(_M_X64)
# define SIZEOF_SIZE_T 8
# define SIZEOF_VOIDP 8
# elif defined(_M_IX86)
# define SIZEOF_SIZE_T 4
# define SIZEO...
C doesn't have any built in boolean types. What's the best way to use them in C?
...
Can you please recommend any E-Book Reader which can execute a third-party software, so that anybody can create software for such device?
...
Let's say the factors for valuing a choice are the library of widgets available, the slope of the learning curve, and the degree of portability (platforms it works on). As far a language binding goes, I'm using C++.
Thanks!
...
I want a C library for generating image snapshots of PDF files. Then I would use this to generate the thumbnail of the first page. Is there a library for this?
...
Thanks for all helped me before.
But I still have some questions about the program.
How to generate a new random number while the new random number is equal to the previous random number? Also how to transpose the matrix?
#include "stdafx.h"
#include "stdlib.h"
#include "time.h"
int _tmain(int argc, _TCHAR* argv[])
{
int nu...
On Linux systems (either 32- or 64-bit), what is the size of pid_t, uid_t, and gid_t?
...
Recently, I read a white paper by an individual who refers to a pointer to a struct as a handle. The author was clearly someone who had written C code on the windows platform previously. Googling indicates that windows programmers interact with system components via handles. I am wondering if it is common practice for windows programm...
I'm looking for a C/C++ functional equivalent to HTML::Defang, and my Google-fu has not been able to uncover anything. I want to keep any benign tags and strip out/defang everything else. Lacking an actual library, any pointers to complete lists of tags/attributes/etc to defang would be appreciated. I know of http://en.wikipedia.org/wiki...
I have a numerical method that could return nan or inf if there was an error, and for testing purposed I'd like to temporarily force it to return nan or inf to ensure the situation is being handled correctly. Is there a reliable, compiler-independent way to create values of nan and inf in C?
After googling for about 10 minutes I've only...