Posts
 
Reputation
Joined
Last Seen
Ranked #40
Strength to Increase Rep
+12
Strength to Decrease Rep
-3
91% Quality Score
Upvotes Received
181
Posts with Upvotes
129
Upvoting Members
69
Downvotes Received
13
Posts with Downvotes
11
Downvoting Members
9
102 Commented Posts
~269.56K People Reached
Favorite Tags

436 Posted Topics

Member Avatar for killerqb

[QUOTE]what is the time cost of the actual re balancing of the tree[/QUOTE] It depends on how the algorithms are implemented, but ideally for insertion the cost of rebalancing is constant. Only one part of the tree will ever be out of balance and at most two rotations will bring …

Member Avatar for Herbert_3
0
498
Member Avatar for cutedipti

I never liked the term "Self Referential Structure" because it implies that objects of the structure always refer to themselves. A self referential structure is better called a recursive structure. If the pointer is not NULL, it points to another instance of the structure. The null pointer is a base …

Member Avatar for mungara
0
1K
Member Avatar for group256

[QUOTE=firstPerson;947801]There is also cout.width(...).[/QUOTE] [ICODE]cout.width()[/ICODE] is not sticky. You need to call it for every object that gets printed, so code like this will only right justify the first string: [code=cplusplus] cout.width(30); cout << "right justified\n" << "left justified\n"; [/code] To justify both strings, you need to split the output …

Member Avatar for niario
0
15K
Member Avatar for dombit
Member Avatar for ibrahimali88
0
106
Member Avatar for you2

jephthah's way is the safest and most portable once you fix the nonportable assumptions: [code=c] #include <stdio.h> #if __STDC_VERSION == 199901L #include <stdint.h> #else /* change to fit the compiler */ typedef unsigned char uint8_t; typedef unsigned long uint32_t; #endif #define IPV4 #if defined(IPV4) #define NBYTES 4 #elif defined(IPV6) #error …

Member Avatar for pj.david_rajesh
0
14K
Member Avatar for mfcdoubt

[QUOTE][CODE]temp1 *maintemp1;[/CODE][/QUOTE] temp1 is a template class. The error means exactly what it says, and you should add a template argument list. Maybe [ICODE]temp1<test3>[/ICODE]?

Member Avatar for huda_7978
0
3K
Member Avatar for mz_rigel

Base means the longest sequence of fundamental digits before reaching 10. 10 is not limited to the decimal counting system, it is used in other bases to mean one more than the base: Base 10, decimal: 0 1 2 3 4 5 6 7 8 9 10 Base 8, octal: …

Member Avatar for WaltP
0
1K
Member Avatar for kgz

[QUOTE]do you know any method in which to draw hearts all over the screen in C++?[/QUOTE] I sure do: [code] #include <iostream> int main() { for (int x = 0; x < 1000; ++x) std::cout << "<3"; } [/code] :D

Member Avatar for Fuseteam
1
5K
Member Avatar for Tom Gunn

CSV is more than just comma delimited fields. There are quoting and white space rules too. This is a short function as an example of a complete way to read CSV records line by line.

Member Avatar for moonlight01
2
370
Member Avatar for Gaiety

[QUOTE]i can't get how can i use that in a program .[/QUOTE] alloca() is used just like malloc(). The difference is how they work under the hood. [QUOTE]and what is the advantage of such a function.[/QUOTE] [LIST] [*]alloca() is faster because it just needs to adjust the stack pointer. malloc() …

Member Avatar for monishch
0
186
Member Avatar for Gaiety

[QUOTE]then it would be like if-else if internally.[/QUOTE] [QUOTE]but here it is given as it uses jump tables [/QUOTE] I think compilers commonly use jump tables for a tight range of cases and compares for wider ranges. This switch would probably use a jump table: [code] switch (condition) { case …

Member Avatar for lyfzopen
0
189
Member Avatar for chaithanyap

[QUOTE]readb has declared under public section but am unable to access that through the derived class object d. d.readb();//is ambiguous[/QUOTE] read() is ambiguous, readb() should not be. You created the [URL="http://en.wikipedia.org/wiki/Diamond_problem"]Diamond Problem[/URL] where the most derived class has two copies of the same base object. Virtual inheritance fixes this problem …

Member Avatar for Ezzaral
0
875
Member Avatar for cjjack88

[QUOTE]When i remove the root of the binary tree and I view the binary tree in In-Order Traversal, my program will stop running.[/QUOTE] Then you are not resetting the links the way they should be. Removing the root means replacing the root with either the inorder predecessor or successor. Something …

Member Avatar for troyduff281
0
3K
Member Avatar for Gaiety

Technically all you need is a stack to store the nodes needed to get back to the nearest root and traverse the other subtree. So the memory cost is O(logN), not O(N), because the size of the stack has at most as many nodes as [ICODE]height(tree)[/ICODE]. The only way I …

Member Avatar for jl.lakhnai
0
179
Member Avatar for sbhavan
Member Avatar for DoEds

[QUOTE]Can anyone give me some ideas on how to find the middle value between 3 numbers.?[/QUOTE] Assuming it is always 3 numbers, and what you want is the median value, here is a simple way. Find the maximum then the minimum and the one you didn't pick is the median. …

Member Avatar for krutarth
0
3K
Member Avatar for gretty

[QUOTE]Would anyone like to share their tips & tricks for debugging functions & whole programs in C++. [/QUOTE] Learn how your computer works! :) I found that understanding the machine and things at a lower level like assembly and how the OS manages programs/memory really helped my debugging. It also …

Member Avatar for Dingbats
0
157
Member Avatar for eliza2044
Member Avatar for Tom Gunn

The forum is buzzing with questions about tokenizing a C++ string. This is a short function that does it and returns a vector of the tokens. As an option, the delimiter string can represent either a multichar delimiter or a collection of single char delimiters: [code] // multichar delimiter == …

Member Avatar for daviddoria
1
734
Member Avatar for serkan sendur

[QUOTE]if i compare number of his posts or reputation points or solved threads, i think Ramy or Scott(sknake) must be granted these before than him.[/QUOTE] If the criteria for being featured are post count, solved thread count, and reputation points then there are a lot of people in line before …

Member Avatar for jephthah
1
366
Member Avatar for alvalany
Member Avatar for kikat

Does your AvlNode class have a public default constructor, public destructor, and public assignment operator? Those are the requirements for storage in a container class.

Member Avatar for mrnutty
0
117
Member Avatar for job2617

[QUOTE] *Implementation of the Traveling Salesman Algorithm on Networking Systems. *Graph Traversal System Using Best Path Method . *Analysis on the Different Advanced Algorithms *Implementation of the Closest Pair Algorithm on Networking Systems *Comparative Study on the Efficiency of Sorting Algorithms[/QUOTE] These have been done to death. If you are …

Member Avatar for Nick Evan
0
980
Member Avatar for Dave Sinkula

[QUOTE]Newbies not using code tags are a huge issue for us, and we finally made some successful progress[/QUOTE] It must have been a sad state of affairs before that progress, because almost none of the new members use code tags in the C and C++ forums now.

Member Avatar for ablitz
4
349
Member Avatar for CrazyProgrammer

The algorithm is the same as with a binary tree. The only difference is you loop through the vector to find a matching key and then loop through the links and recursively traverse each one in turn.

Member Avatar for john.double
0
224
Member Avatar for siggivara

Typically the two options for a case like this are a count argument and a sentinel argument: [code] #include <stdio.h> #include <stdarg.h> /* gets a count of arguments */ void TestCount(int x, int n, ...) { va_list args; va_start(args, n); printf("%d: ", x); while (--n >= 0) printf("%-3d", va_arg(args, int)); …

Member Avatar for siggivara
0
188
Member Avatar for stevenpetersen

What do you mean by a points system? The whole idea is pretty vague.

Member Avatar for stevenpetersen
0
538
Member Avatar for candoc

You do need to do an fseek to that location, but not because C uses separate read and write pointers. The standard says that when switching between read and write mode on a stream, there needs to be a flush or seek between them. So you would read to the …

Member Avatar for Tom Gunn
0
117
Member Avatar for BitFarmer

[QUOTE]..or may be I am missing some option, in witch case, it should be a lot more visible than it is... I couldn't find it ;-) [/QUOTE] I can go to the Delphi forum, then under the Related Forum Features box on the right there is a direct link to …

Member Avatar for BitFarmer
-1
181
Member Avatar for Iam3R

[QUOTE]can somebody explain the behaviour of the statement printf("%d");[/QUOTE] Undefined. In practice it will probably print whatever is next in the stack and potentially corrupt the rest of your program by moving the stack pointer in an unexpected way.

Member Avatar for Tom Gunn
0
114
Member Avatar for dmm
Member Avatar for William Hemsworth
0
79
Member Avatar for simonsayz27

[ICODE]input == depth[/ICODE] will happen for every node at that depth. You only want to print the total after the function returns instead of inside the recursive function. A reference parameter would be better suited to that: [code] #include <iostream> struct treeNode { int data; treeNode* left; treeNode* right; treeNode(int …

Member Avatar for codewalkz
0
356
Member Avatar for Iam3R

[QUOTE]its already available for free on internet.[/QUOTE] Not legally, AFAIK. Any that you find are pirated and in breach of copyright. You can contact Addison-Wesley and ask them to be sure, but I think you will get the same answer.

Member Avatar for Tom Gunn
-4
136
Member Avatar for rino699

C++ has two kinds of strings. The strings inherited from C are char arrays with a terminating '\0' character. All of the rules for arrays apply, which means you can only return a pointer to the array somehow. But if the array is local to the function returning it, you …

Member Avatar for Tom Gunn
0
130
Member Avatar for discovery-power

[QUOTE]getch();[/QUOTE] This may or may not work. getch() is not a standard function and not all compilers implement it as an extension. If the only goal is to keep the window open, any blocking read will do: [code] #include <iostream> int main() { std::cout << "Hello world!\n"; // blocking read …

Member Avatar for discovery-power
0
165
Member Avatar for gcardonav

The simplest way to adjust the range of rand() is with the modulus operator: [code] #include <iostream> #include <cstdlib> int main() { for (int x = 0; x < 20; ++x) { std::cout << (std::rand() % 900 + 100) << '\n'; } } [/code] I am sure someone will chime …

Member Avatar for mrnutty
0
162
Member Avatar for miskeen

[QUOTE]Can I enable/disable an #ifdef based on a specific condition?[/QUOTE] Yes, but only if the condition is available at compile time. In your case the value of i is a run time quantity, so you cannot use it with the preprocessor. I think what you really want is an [ICODE]if[/ICODE] …

Member Avatar for miskeen
0
107
Member Avatar for nightninja12

[QUOTE]would the restore code go in the trees constructor or do i need a seperate function to initialize all the nodes?[/QUOTE] I would put it in a separate constructor, as well as a public method. The actual implementation could be in a private method that is shared between the two. …

Member Avatar for Lerner
0
161
Member Avatar for Star Frost

[QUOTE]I just cant seem to fathom the last part of each line is being completely ignored...[/QUOTE] I know the answer to this problem because it is a problem I create myself on a regular basis. :) On the last token, [ICODE]finish [/ICODE]will be [ICODE]string::npos[/ICODE]. After the last token, [ICODE]start [/ICODE]should …

Member Avatar for Star Frost
0
187
Member Avatar for snapppy

[QUOTE]i have not yet learned the code to do it and dont want to wait.[/QUOTE] You can learn on your own how to do it and not have to wait for your class to catch up. Then again, patience is an important trait for a programmer to have. Rushing through …

Member Avatar for Grn Xtrm
0
207
Member Avatar for riahc3

[QUOTE][CODE]#include <assert.h> #include <complex.h> #include <ctype.h> #include <errno.h> #include <fenv.h> #include <float.h> #include <inttypes.h> #include <iso646.h> #include <limits.h> #include <locale.h> #include <math.h> #include <setjmp.h> #include <signal.h> #include <stdarg.h> #include <stdbool.h> #include <stddef.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <wchar.h> #include <wctype.h>[/CODE][/QUOTE] It is always good …

Member Avatar for Tom Gunn
0
925
Member Avatar for cloisterham

The second menu is legitimate. When you typed something for scanf() to read, you also pressed [Enter], right? That [Enter] is a character too, and it is stored in the stream as '\n'. The first menu is the one you want, but because there is another character ready to be …

Member Avatar for Tom Gunn
0
552
Member Avatar for Gribouillis

[QUOTE]where is this function and how is it called ?[/QUOTE] It is done by the C runtime. The same code that calls main() collects arguments from the command shell and parses them into an array of char pointers.

Member Avatar for Gribouillis
0
219
Member Avatar for discovery-power

There are left over characters in the stream that cin.get() is reading immediately. It is not blocking, so the program ends immediately and I assume the window is closing so you cannot see the output. Try this: [code] #include <iostream> using namespace std; int main() { int length; // this …

Member Avatar for discovery-power
0
96
Member Avatar for neithan

I/O is kind of complicated in C. Can you list out your questions so that it is easier to answer them? I will be happy to give you all of the details you want, but right now it feels like I would end up writing a small book.

Member Avatar for Narue
0
191
Member Avatar for AdRock

Your search always starts from position 0, that is why tokens are being duplicated. You need to skip over the extracted tokens as you go. Something like this: [code] #include <iostream> #include <string> #include <vector> int main() { using namespace std; string const punct = "+-*/<=!>{()};,"; string str = "dressed(with)"; …

Member Avatar for Tom Gunn
0
272
Member Avatar for Iam3R

Do not forget to enter curses mode before using getch() and leave curses mode when you are done: [code] #include <ncurses.h> int main() { initscr(); printw("Enter a character: "); printw("You entered '%c'\n", getch()); refresh(); endwin(); return 0; } [/code]

Member Avatar for Tom Gunn
0
996
Member Avatar for arsh_arsh

To add to dkalita's reply, the array decaying into a pointer rule only applies to the first dimension. The pointer version of your 2D array function parameter is [ICODE]int (*)[MAX_COL][/ICODE]. You can change your function in either of these two ways: [code] void fnGetMatrix(int aiMat[][MAX_COL,int *iNoOfRows,int *iNoOfCol) [/code] [code] void …

Member Avatar for arsh_arsh
0
86
Member Avatar for sbmcdeshan

[QUOTE]So at what point I have to delete this pointer?[/QUOTE] As long as you have a copy of the pointer that was returned by [ICODE]new[/ICODE], you can delete it. You said that the pointer is stored in another object, so that object's destructor would probably handle the deletion. Though that …

Member Avatar for sbmcdeshan
0
150
Member Avatar for ankur_

Do a Google search. You can download the runtime as an redistributable package from M$.

Member Avatar for Ancient Dragon
0
207

The End.