hi,
i am looking for a function in STL that does this job:
say, i have a map with elements a,b,d,e, and their values are 10,20, 30,40 respectively.
i want a method, that gives me 20(or the...
Type: Posts; User: kolistivra
hi,
i am looking for a function in STL that does this job:
say, i have a map with elements a,b,d,e, and their values are 10,20, 30,40 respectively.
i want a method, that gives me 20(or the...
Hi experts,
The code below is from a programming contest, the answer must be given without using a compiler(this test is on paper).
The problem: How many '*' does that piece of code prints?...
the main problem of mine was that, i put the items in the set, and the way i put sorted the items according to their node number, instead of the cost. some little modifications corrected the code....
I had an error in my STL! The problem was my mistake! now the runtimes are:
STL: 0.047
Heap: 0.031
I inserted the the items in the Set in a wrong way, that's why the runtime difference was...
Yes, both give the same and the right result. The bubbling thing is doing heap's job, I guess.
After your post, I compiled with -O3 parameter, but the runtimes didn't change much.(~0.01 seconds...
Well, here we go:
the input generator:
#include <cstdio>
#include <cstdlib>
#include <ctime>
using namespace std;
Well, my new tests showed me an unbeliveable difference. in this test, i didn't count the IO(reading vertex and edge information from ~3mb file)
in the best performances:
STL Set version: 0.687...
Well, it did indeed increase the performance by about ~%7-8. thanks. do you have any other suggestions?
Thanks!
Hi,
I'm experimenting to code dijkstra with STL. The STL version of the algorithm runs slower than the hand-written heap, expectedly.
Even though STL one probably will never work as fast as...
Hi,
I'm trying to code Dijkstra by using STL, but I keep getting this error. I must be missing but I can't find it, here is the code:
#include <iostream>
#include <cstdio>
#include <set>...
@quzah: i wrote my code according to the suggestions of dwks,i think you didnt see it, and why im here is because im stuck at understanding and solving the question.
guys, i think my understanding...
10
/ \
5 15
/ \ / \
3 7 13 17
try your code on this. it will give 7, whereas it must give 8...
i have coded something like that:
int epl(node *tree) {
if (tree==NULL) return 1;
else return epl(tree->left) + epl(tree->right) ;
}
but this gives 7 for the tree below,whereas it must...
Hi,
I'm studying algorithms from the book "Algorithms in C" by Sedgewick and I have encountered with a question that I couldn't solve. The problem is to create a function to determine the external...
nope, i don't wanna get into any hairy stuff, im just looking for the fastest safe method possible, which can possibly be, in this context, looping through each element and memset, i agree with you...
yeah that is exactly what i'm looking for, another method, but as you say, is that faster? anyone knows about the performance of memset over going over all elements?
thanks
Hi,
int a[1000] = { 0 };
this initializes all elements of the array a to 0. let's say i have changed some elements, and now want to set all items to 0 again. should i go through all elements...
sorry that i didn't look at it, ty for answers..
hi, what is the difference between these?
int abc() {
...
}
int abc(void) {
...
}
Hi, I have encountered with a bizarre problem. Though i solved it in a different way, i can't understand why the problem occurs.
Here is the problematic code:
#include <stdio.h>
#include...
Ok, but isn't the issue a bit different for arrays? AFAIK, arrays are passed by reference, unlike other data types. So, shouldn't their actual values change? If you can clarify this point a little...
Thank you ZuK, it seems to be working fine now, with your suggestion as well as another bug i have found
Thank you again.
well, you are right itsme86, the correct answer is d(btw, i forgot to put space there, there is one)
what i couldn't get is that, you say the function has no effect on main, but
p = a;
q =...
Hi,
I've some problems to get over, first of all, i keep getting this error and couldn't get it solved. here is the code and the error i get:
the error: error C2664: 'strtok' : cannot convert...