Chandu
Try this i will work
Chandu
*it
Anonymous
Worked bro thanks alot
Chandu
👍
__.whizz.__
Hi
__.whizz.__
I don't know c program
__.whizz.__
Anybody want to teach me
Anshul
Anonymous
Anyone?
Just think about how the tree is built.
If it's a binary tree every node has up to two children nodes. This mean that, assuming it is balanced, at each level you have 2M nodes, where M is the number of nodes of the previous level.
Therefore if you have a total of N nodes, you can go as deep as log(N)
Anonymous
AJAY
Kisi ke pass DSA ke handwritten notes hai to please send me
Anshul
Anshul
For a binary tree calculating height takes o(n) time right? Then why for height balanced tree it is o(logn)
Anonymous
Just Google some visual representation and you'll understand what I'm saying
Anshul
Anshul
So the height can be calculated in o(logn) time or does it mean the height is log n
Anshul
But calculating the height will still take O(number of nodes) time right?
Anshul
Because to calculate height, I make a recursive function which at every node ask the height of its left and right sub trees and returns it's height as max of both heights + 1
Anshul
So to traverse each node I'm making n number of calls. n being the number of nodes
Anonymous
It takes O(log(N))
Anonymous
The number of times you function gets called is equal to the number of levels of the tree, right?
Every time, starting from the root node, you check if it has a left or right children. If so, you call the same function on one of the two, right? Therefore you are calling that function for every tree level
Anshul
Anonymous
Anshul
Thanks brother
Anonymous
Anshul
👍
mystery
#include <iostream>
using namespace std;
int main() {
long num;
cin>>num;
cout<<endl; // Reading input from STDIN
unsigned long long a,b,sum=0;
long i;
while(i<num)
{
cin>>a>>b;
cout<<endl;
long long j;
while(j<=a)
{
if(j%b==0)
{
if((j%b)%b==0)
{
sum+=(j/b)/b;
}
else{
sum+=j/b;
}
}
else
{
sum+=j;
}
}
cout<<sum<<endl;
}
}
mystery
Anshul
Anshul
If j and i are 0 at start so the complexity will be O(a*num). What are the constraints
Anonymous
Anonymous
I tried many times i can't figure it out
I'd suggest you:
1 - Provide an explanation about what your code should do
2 - State the expected output and the output or error you got
3 - Send a minimal working example of your faulty code in a well-formatted fashion
Anonymous
@OxFFFFFFFF What about the following message in the rules?
1 - Provide an explanation about what your code should do
2 - State the expected output and the output or error you got
3 - Send a minimal working example of your faulty code in a well-formatted fashion
Ибраги́м
Ибраги́м
ZukiZest
for (j = x; j <= 4 * x * y; j += y / x)
Anonymous
Chandu
Milwaukee
Hello can anyone assist
Describe how parameters are passed between a function call and a function in programming. For each
way of passing parameter write a program segment to show how
it is implemented.
Anonymous
Anonymous
klimi
バレンタインがいない柴(食用不可)
Anonymous
Hm?
Does it break those two rules?
* Not checking your problem in google (or any other search engine) first will get you a warn.
* Asking to solve an assignment/test/whatever without trying it first yourself will get you a warn or will get you BANNED. We won’t write a code for you, but we can push you forward and suggest something.
+
Hello guys
for my needs I subclassed QProgressBar and created my own
the way Im using it is:
create an empty QFrame where I want to put my progress bar in it
after that add my progress bar to it in my code with setParent, its ok, but problem is in this way the progress bar widget isn't center, so how can I center it? (without using layout of cource)
Daniel
hello, whats the difference between
int const value =5;
const int value1 = 5;
Anshul
Anonymous
Anshul
ANONYMOUS
i read from txt pairs of numbers
how can i check it only 2 numbers in each line and not 3 I want show the line is the problem for example:
ANONYMOUS
the pairs file:
ANONYMOUS
3
25 35
14 42
30 60 70
ANONYMOUS
my code: scanf("%d", &numOfPairs);
arrNum = (int *)malloc(sizeof(int) * numOfPairs * numbersInPair);
for (int i = 0; i < numOfPairs * numbersInPair; i += 2)
{
int num1, num2;
if (scanf("%d %d \n", &num1, &num2) == 2)
{
arrNum[i] = num1;
arrNum[i + 1] = num2;
}
else
{
printf("illegal input at line %d \n", i);
}
}
ANONYMOUS
console: illegal input at line 4
Артём
Anonymous
/get
Steven
Ehsan
Suyash
Help me to write Java code
Que.) Reverse a String and print it on console
"Java Skills"
Chandu
Chandu
/report
バレンタインがいない柴(食用不可)
Anonymous
Heyyy
ANONYMOUS
ANONYMOUS
int i, c;
FILE *fp;
char str[100];
fp = fopen("./pairs.txt", "r");
if (dup2(fileno(fp), STDIN_FILENO < 0))
{
printf("Error opening file");
return -1;
}
if (feof(fp))
printf("Error reading file");
scanf("%d", &numOfPairs);
arrNum = (int *)malloc(sizeof(int) * numOfPairs * numbersInPair);
for (int i = 0; i < numOfPairs * numbersInPair; i += 2)
{
int num1, num2;
scanf("%d %d", &num1, &num2);
arrNum[i] = num1;
arrNum[i + 1] = num2;
}
Sandeep
If I have hash that stores the frequency of the key...then how do I create a vector which is sorted based on the frequency
Артём
Артём
ANONYMOUS
ANONYMOUS
{
int index, i, numOfPairs;
int c;
FILE *file;
file = fopen("./pairs.txt", "r");
if ((c = getc(file)) == EOF)
{
perror("Error opening file"); //or return 1;
fclose(file);
}
while ((c = getc(file)) != EOF)
putchar(c);
{
if (pid == ROOT)
fscanf(file, "%d", &numOfPairs);
allNumbers = (int *)malloc(sizeof(int) * numOfPairs * numbersInPair); //need multiply in 2 numbers for each pair
while (!feof(file) && numOfPairs > 0)
{
int x, y, arrIndex = 0;
numOfPairs--;
fscanf(file, "%d %d", &x, &y);
allNumbers[arrIndex] = x;
printf("The X : %d\n", x);
allNumbers[arrIndex + 1] = y;
printf("THE Y : %d\n", y);
arrIndex + 2;
}
fclose(file);
}
ANONYMOUS
it get array garbage
Anshul
i wrote a code for this, "Construct Binary Tree from Preorder and Inorder Traversal". for sample test cases it runs fine but when i submit the code it gives a run time error and i can't understand the reason why