A.m.h
line 5
what ????
klimi
what ????
you haven't told your problem, don't expect magic happening and just showing you where your "problem" is and how to fix it
A.m.h
When I enter the wrong data, it enters the infinite loop with the condition I said
Chat Boss
Night Rider sent a code, it has been re-uploaded as a file
mito
Night Rider sent a code, it has been re-uploaded as a file
Night Rider, you were thrashed in another C/C++ group by the admin for sending unformatted code. Now you're coming here and doing the same thing. I'll leave the screenshot in the OT group.
hrb
hey what is the time complexity of this loop? i=2 while(i<n) { i = i * i * i; } i think it’s definitely logarithmic and what i came with is (log i^2(n)) but i felt like it doesn’t make sense
hrb
O(cube root of n)
can you explain it please ?
Pavel
hey what is the time complexity of this loop? i=2 while(i<n) { i = i * i * i; } i think it’s definitely logarithmic and what i came with is (log i^2(n)) but i felt like it doesn’t make sense
So the progression is 2, 8, 512, 134 millions It is looking logarithmic, but I'm not sure what would be the proper math formula for it
Sherlock
I need one permission from admin here. I don't know who is currently handling the group.
Anonymous
hey what is the time complexity of this loop? i=2 while(i<n) { i = i * i * i; } i think it’s definitely logarithmic and what i came with is (log i^2(n)) but i felt like it doesn’t make sense
The complexity of this algorithm is log to the base 3 of log n. The loop variable goes like this 2, 2^3, (2^3)^3 i.e. 2^(3^2) and so on. The last term will be 2^(3^log3(log n)) and this must be less than n. So there are log3(log n) iterations in all or simply log(log n) iteration as the bases don't matter really.
p
how do I know the size of the first dimension of this array? int R[][2]
R.size()=first dimension R[0].size()= second dimension
Anonymous
Hi, I need help for solved this exercise. I can't understand what the program is asking me. I would appreciate it if you could explain it to me with code illustrations : This is the exercise Write a program that reads two numbers a and b (positive less than 10000) and: -Create a vector where each position is a digit of the number. The first position is the least significant digit; -Create a vector that is the sum of a and b, but do it using only the vectors previously built. Hint: add the corresponding positions. If the sum exceeds 10, subtract 10 from result and add 1 to the next position.
27Onion
say, if you got a = 69381 b = 45133 then you need to create two vectors like these: std::vector a_digits {1, 8, 3, 9, 6}; // Represents 69381 std::vector b_digits {3, 3, 1, 5, 4}; // Represents 45133 and you need to add them and gives out a vector with the content {4, 1, 5, 4, 1, 1}
27Onion
which represents the number 114514
Xerox53
Hi
klimi
Hi
don't say just "Hi" and please read the group rules
Anonymous
Im an engineering student we studied C language but not all of it the last thing we studied was memory allocation which i couldnt find in W3schools so Whats the best resources of learning and Coding C language
Anonymous
Daniyal Nadeem
I have exam of DSA in cpp what’s imp in theory for exams?
Ahmad
Hey.can anyone suggest me best c++course
Garry
im using debugger in vs code for c++ when i step into a class method it takes me to something like allocator.h this happened with a normal function also once but it got solved,i did that steps which i did then but it didn't get solved
Tommaso
Hi everyone, usually after using fork() to duplicate the process you manage what the duplicate process has to do with the if(pid==0) condition, but is there a way to handle it outside the condition? That is, to specify that a certain process must do a certain function? Thank you all
Xerox53
Hey.can anyone suggest me best c++course
Love Babbar C++ and DSA on YT
Talentless guy
hey , guys i am with difcult to learn programming , so do you have any idea to can i learn better?
Tommaso
Why do you need another way when pid == 0 works?
maybe I'm wrong, but I should create more processes and do an infinite loop with while (true) in which these processes access resources, then a for that generates x processes by fork, which then alternate until a special function detect deadlock or starvation
Tommaso
you know the problem of philosophers at dinner? I would like to create for example 5 philosophers as processes, which take chopsticks and eat endlessly, until I go into deadlock or starvation
Anonymous
you know the problem of philosophers at dinner? I would like to create for example 5 philosophers as processes, which take chopsticks and eat endlessly, until I go into deadlock or starvation
So you need to create four processes from your main process (which you can do in a loop) and all processes including the parent process will execute the same code (i.e. picking up a fork on the right followed by one on the left and then eat and then sleep (think) or you could even change it to a random order)... The only difference is that the parent process will do so after finishing the for loop while the child processes will do it immediately. What is the problem?
Tommaso
the problem is that I would like to iterate the 4 processes indefinitely, and I didn't understand how I can do it, if I put the while (true) before the for I create many processes, if I put it in the if(pid==0) I iterate the loop on a single process, instead I would like x processes to make that loop alternating, thanks for your patience
jungletek
While maze generation algorithms are easy to find, and I've done a bit of research on my particular issue already, information about how to generate mazes where the paths are different sizes than the walls are significantly less common and/or google sucks at returning relevant results. I'm making a game, and I have simple maze generation working, etc. The issue I'm struggling with is in either trying to develop an algorithm that generates paths that are cellSize*3, while walls are still cellSize, or figuring out a way to have my generated maze with cellSize paths be rendered in such a way that the paths are wider, accommodating a player that is 3*3 square. Pseudocode is fine, I'll figure out how to implement it from there. Thanks in advance.
jungletek
Fair enough. Most maze generation algorithms work with a grid of cells, right? The result is that you have walls of the maze, and the paths through them being the same size (cellSize).
jungletek
the walls are 1 cell thick, and the paths through are 1 cell
jungletek
now how do you write the algorithm to produce mazes with 1cell thick walls, but 3cell thick paths through them?
Anonymous
the walls are 1 cell thick, and the paths through are 1 cell
Well you could instead of using walls make everything cells where some cells can be walked through and some cells being blocked. That is equivalent to making walls as thick as a cell
jungletek
i already have that part, it's easy and comes as a byproduct of a cell-based generation algorithm
Anonymous
now how do you write the algorithm to produce mazes with 1cell thick walls, but 3cell thick paths through them?
Make paths three cells long i.e. if a cell (1,1) is not a wall then cell (1,0) and cell (1,2) are not walls either
Anonymous
So basically you have to expand the input map into a graph of your own. It will be different from the input but it will account for the fact that paths are 3 times as thicker as walls
jungletek
yes, i follow the logic, i guess i'm just going to have to give it a hard think and wrap my head around what modifications do and do not need to be made to the logic
jungletek
ok i think i understand the broader premise: i need to walk and cull the cells as normal, but at a larger scale resolution than 1 cell at a time, but rather 3 (actually 3x3 blocks)
abdisa
Hello, mates i have this question i have a class called Account and its has its own deposit method and i have a child class called Cheking_account which also has its own deposite method i created a unique_ptr to the checking account but when i called the deposit method the parent class deposit method is called btw Cheking_account inherites publicly from account And when we use smart pointers is the binding dynamic or static
Anonymous
Hello, mates i have this question i have a class called Account and its has its own deposit method and i have a child class called Cheking_account which also has its own deposite method i created a unique_ptr to the checking account but when i called the deposit method the parent class deposit method is called btw Cheking_account inherites publicly from account And when we use smart pointers is the binding dynamic or static
And is the unique_ptr of type of unique_ptr<Account> or unique_ptr<CheckingAccount>? If it is the latter then irrespective of whether the deposit method is virtual, the method in CheckingAccount will be called. If it is the former, then then the method in Account class will be called if it is not virtual or if the method's signature in derived class does not match that of the parent class. The method in the derived class will be called if it is virtual. Also make sure that the derived class method overrides the base class method using the override contextual keyword
abdisa
Is the deposit method in account class virtual?
No but i was wondering about that also the deposits method in the checking account has a different function signature(parameter called an interest rate)
Anonymous
No but i was wondering about that also the deposits method in the checking account has a different function signature(parameter called an interest rate)
Then read the last line of my previous post. Your method in CheckingAccont class then doesn't override the deposit method in Account class. For overriding to happen, both methods must have the same signature barring covariant return types
Anonymous
Oh men! I'm keep forgetting about that thanks mate but if i use virtual in any of method i also have to use virtual destructors as well i hop
Yes. Given that you are using smart pointers, you would want the destructor to be virtual so that when the smart pointer gets destroyed, the correct destructor gets called.
Anonymous
I have exam of DSA in cpp what’s imp in theory for exams?
Arrays, Lists (Singly Linked and Doubly Linked), Graph representations like Adjacent Matrix, Edge graphs and so on, Graph Algorithms, String Algorithms like Burrows Wheeler, Rabin Karp, Morris and so on, Dynamic Programming, Greedy Algorithms, Streaming Algorithms et al. That should be the syllabus. I have checked the question paper for Algorithms in my university which account for most of these questions. Your university would do the same if it intended to check a student's understanding of the concepts Please stick to C/C++ questions in future unless you want to get banned
--//Zak
Given an Nx N grid G and each cell of the grid contains an integer. In one step you can travel from any cell G, to Gid if abs(ji-j2)+abs(i1-12) ≤ p at a cost of floor(G). Here p is the number of unique prime factors of the integer at Gij. Find the minimum cost to move from the top-left corner cell to the bottom-right corner cell, no matter how many steps you take. Notes abs(x) means taking the absolute value of a number x or Ix. ⚫ floor(x) represents the largest integer y such that y<x. . V represents the square root of x. • Use 1-based indexing Write a code in c++
Emanuele
guys, is it possible to do a binary search with a double linked list?
Anonymous
Anonymous
guys, is it possible to do a binary search with a double linked list?
If you want to do efficient searching on a sorted linked list, converting your linked list to a binary search tree would be the best option
Emanuele
i need to use dijkstra
Emanuele
lists are better
Pavel
i need to use dijkstra
If you want to iterate over your list you can iterate over elements of std::map as well. But if you iterate more often than search/add/remove, then std::vector may be more efficient
Hima
guys, is it possible to do a binary search with a double linked list?
I think you can do this , but the runtime wouldn't be logN .
Chat Boss
Ꭰɾ 𝑆𝑂𝐵𝐾𝐴 𝐾𝐸𝑈𝐷𝐸𝑈 ᴊᴏꜱᴜé sent a code, it has been re-uploaded as a file