If-then-else statements, Data Structure & Algorithms

In this example, suppose the statements are simple unless illustrious otherwise. if-then-else statements

if (cond) {

sequence of statements 1

}

else {

sequence of statements 2

}

In this, if-else statement, either sequence 1 will execute, or sequence 2 will execute based on the Boolean condition. In this case the worst-case time is the slower of the two possibilities. For instance, if sequence 1 is O(N2) and sequence 2 is O(1), then the worst-case time for the whole if-then-else statement would be O(N2).

Posted Date: 4/4/2013 5:55:18 AM | Location : United States







Related Discussions:- If-then-else statements, Assignment Help, Ask Question on If-then-else statements, Get Answer, Expert's Help, If-then-else statements Discussions

Write discussion on If-then-else statements
Your posts are moderated
Related Questions
nested for loop for (i = 0; i for (j = 0; j sequence of statements } } Here, we observe that, the outer loop executes n times. Every time the outer loop execute


ST AC K is explained as follows : A stack is one of the most usually used data structure. A stack is also called a Last-In-First-Out (LIFO) system, is a linear list in

We have discussed that the above Dijkstra's single source shortest-path algorithm works for graphs along with non-negative edges (like road networks). Given two scenarios can emerg

Q. What is the smallest value of n such that an algorithm whose running time is 100n2 runs faster than an algorithm whose running time is 2n on the same machine.    A n

Linked list representations contain great advantages of flexibility on the contiguous representation of data structures. However, they contain few disadvantages also. Data structur

The searching technique that takes O (1) time to find a data is    Hashing is used to find a data

So far, we now have been concerned only with the representation of single stack. What happens while a data representation is required for several stacks? Let us consider an array X

As we have seen, as the traversal mechanisms were intrinsically recursive, the implementation was also easy through a recursive procedure. Though, in the case of a non-recursive me

This algorithm inputs number of hours of sunshine recorded every day for a week (7 days). Output is the highest value for hours of sunshine and average (mean) value for numbers of