I was trying to find a solution for checking the symmetry of a tree. I would like to get some comments on the approach.. I am trying to do it by modifying the inorder traversal thing.. The pseudo code is: [CODE] // since the structure should be similar string in1,in2; func inorder (root): //normal inorder traversal static int i; if root==NULL: return; if (root->left!=NULL): in1[i++] = 'L'; inorder(root->left); if (root->right!=NULL): in1[i++] = 'R'; inorder(root->right); func modified_inorder (root): // modified inorder traversal. This one flips the traversal order from (root,left,right) to (root,right,left). static int i; if root==NULL: return; if (root->right!=NULL): in1[i++] …

Member Avatar
Member Avatar
+0 forum 5

I was looking around the time module. The time.sleep(no_of_seconds) sleeps the program for no_of_seconds seconds. I don't think this is busy wait. It must be scheduling the process at a later time. Just curious of how this is working.! :)

Member Avatar
Member Avatar
+0 forum 4

Even after looking at a lot of books, I am not able to understand the problem in the following code: [CODE] //1.c static int y=23; void abc(int a){ printf("%d\n",a); } [/CODE] [CODE] //2.c #include<stdio.h> #include "1.c" int main(){ abc(12); printf("\n"); printf("%d\n",y); return 0; } [/CODE] I can understand that the functions abc is accessible to this file, but how is this variable y accessible here? [QUOTE]The static declaration, applied to an external variable or function, limits the scope of that object to the rest of the source file being compiled. from: dennis ritchie[/QUOTE] So, how is this static variable in …

Member Avatar
Member Avatar
+0 forum 9

I was looking at a question: Q. Given n numbers of which all numbers are repeated (at least once) other than one. We have to find that number. Numbers range is to 10^9, thus using count sort would do no good.! Adding the numbers one by one to a dictionary was another option (and a good one as the complexity is O(n)). But this has high implementation requirements.! Can someone suggest some better answer to this problem.? :-/

Member Avatar
Member Avatar
+0 forum 4

I just wanted to learn to create facebook applications using python.I am new to web development of any sorts, so everything seems to be weird right now. Here is what i acquired by google searching pages: This is the facebook developers page: [url]http://developers.facebook.com/opensource/[/url] Only one link to python.. [url]https://github.com/facebook/python-sdk[/url] The downloaded file contains a small amount of python files, but they are asking for another module: google.appengine amongst others. I tried to search for some previous applied code using google code, but alas, it all made no sense to me..! If someone has ever worked on it before, then please …

Member Avatar
+0 forum 0

I was trying to code the assembly line sheduling problem using the dynamic programming approach. I have coded the program but i am facing problem with the 2-dimensional arrays I am using. For testing purpose, I wanted to initialize the array, but I was not able to get it. Moreover, as most of the arrays I am using are dynamically allocated, They were not getting passed to functions. Though I have made the program working with some tricks but I would really appreciate if someone helps me improve it. [CODE]#include<iostream> using namespace std; //Had to make much of the variables …

Member Avatar
Member Avatar
+0 forum 3

The last time I was making a program, I wanted to input from user a boolean answer (to save space ;)) An input of 0/1 works good (0-false) and (1-true), but if the user inputs the boolean values as "true" and "false", it comes out to be an error. So, are there any ways of doing so.? I believe, that the strings "true" and "false" are defines using #define in the header files because of which the input is creating an error. Am i correct.?

Member Avatar
Member Avatar
+0 forum 5

Can someone please direct me to the code for the class <int> in python. I know that it must have written in C, but I could not understand, where to ask this query. Though I tried to figure it out myself, but could not even understand, which folder to attack in the source code. (the source has really got some good great number of files..)

Member Avatar
Member Avatar
+0 forum 2

This may be quite a late introduction, but better late then never. I am having great fun at this forum. See me at C, C++ and python forums... got to learn a lot..

Member Avatar
Member Avatar
+0 forum 5

I have just started writing C code in dev-c++. The programs are running fine, but each C program shows me the following warning: [QUOTE] [Warning] command line option "-fno-access-control" is valid for C++/ObjC++ but not for C[/QUOTE] The test program I used was: [CODE] #include<stdio.h> int main(){ system("pause"); return 0; }[/CODE] After searching a lot all I could find was: [QUOTE]-fno-access-control Do not obey access control semantics[/QUOTE] Can anyone please explain, what is this all about? Thanks..

Member Avatar
Member Avatar
+0 forum 3

I was having some confusions about string and NULLs. So, I read this [URL="http://www.daniweb.com/forums/thread77987.html"]thread[/URL] on this very forum. But, I could not understand somethings... Firstly, Is NULL an integer value 0, or something else? Secondly, [CODE]if(strlen(str)==0)[/CODE] this shows that the string is null or it shows that the first character is '\0' ? if I assign [CODE]str[]=""[/CODE] str now is a null string or has no value or contains the null character '\0' or something else ? How much space is it going to acquire? And finally, please suggest me some good and valid methods to check for NULLs in …

Member Avatar
Member Avatar
+0 forum 10

I want to sort a list of dictionaries using the inbuilt sort() function for lists. The problem is I am not able to understand, how to give the function a key.. Example: [CODE] a={'name':1,'data':200} b={'name':2,'data':400} c=[a,b] [/CODE] Now, I want to sort the list c with the key being a['name']. If i use c.sort(), it gives me an error as dictionaries can not be compared. Either I can use a sorting algorithm but that would make my program too complex. So, can anyone suggest me a beeter approach.

Member Avatar
Member Avatar
+0 forum 6

I want to print a float number with it's digits extending to 20000 digits after the decimal i.e. if the number is 10/3, it should print 3.333333333333333333333333333...20000 or more times. So, how do I print something like that? Also, do tell the solution for C and C++ as well... The code I used was: [CODE] #include<iostream> #include<math.h> #include<conio.h> using namespace std; int main(){ printf("%f",(sqrt(2))); getch(); return 0; } [/CODE] It gave me output: 1.414214

Member Avatar
Member Avatar
+0 forum 5

Hello, I was trying to implement data structures using file operations. I am using a data structure of two integers, one being the index number and other being the value. My actual aim is to recreate the file containing the data using a log. But, the program isn't running as required. Please help. I am giving the code: [CODE] ifstream rlist; rlist.open("redo.txt",ios::in); ofstream datt; datt.open("datatemp.txt",ios::out); dat c; char s; while(!rlist.eof()){ rlist>>s; if(s=='I'){ rlist.read((char*) &c,sizeof c); datt.write((char*) &c,sizeof c); } if(s=='D'){ ifstream rlistd; rlistd.open("datatemp.txt",ios::in); rlist.read((char*) &c,sizeof c); ofstream rlistdw; dat s; rlistdw.open("datatem.txt",ios::out); while(!rlistd.eof()){ rlistd.read((char *) &s, sizeof s); if((s.a)!=(c.a)) rlistdw.write((char*) &s, …

Member Avatar
Member Avatar
+0 forum 5

The End.