Prep: Data Structures and Algorithms
Sérgio Charruadas edited this page Apr 12, 2023
·
1 revision
What is 1 of the more important things you should consider when deciding which data structure is best suited to solve a particular problem?
The most important thing to consider when deciding which data structure is best suited to solve a particular problem is identifying the specific needs of the problem and finding a data structure that meets those needs. An inappropriate choice of data structure might lead to clumsy, inefficient, and difficult implementation.
To avoid an infinite recursive call stack, you need at least one branch (i.e. of an if/else statement) that does not make a recursive call, this ensures that the function will eventually terminate. Branches without recursive calls are called base cases
However, it is difficult to guarantee that recursion will never overflow the stack unless there are bounds on the input and memory size.