Wednesday, January 6, 2021

DSA for interviews

When to use: 

for loop- use for loop when you know how many times that loop will iterate

while loop- if you dont know the number of times the loop will iterate, prefer while loop.

iterative approach: iterative approach involves the use of loops. They do not use stacks(LIFO), so they are faster than the recursive approach. It also takes less memory.

One negative point is that iterative appraoch makes the code long.

recursive approach: Recursive approach uses functions. 

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home