Computer Science EngineeringVery hard
What is the Theta bound of: for(i=1;i<=n;i++) for(j=1;j<=n;j*=2) count++;
- A. Theta(n log n)
- B. Theta(n^2)
- C. Theta(n)
- D. Theta(log n)
Correct answer: A. Theta(n log n)
The inner loop runs about log2 n times for each of the n iterations of the outer loop.
Practise more Algorithms, Data Structures & Programming (ISRO CS) questionsAlgorithms, Data Structures & Programming (ISRO CS): notes and key points
More Algorithms, Data Structures & Programming (ISRO CS) questions
- An adjacency matrix representation of a graph with V vertices needs space
- Which hashing technique guarantees O(1) worst-case search time for a static set of keys?
- A singly linked list holds 1->2->3->4->5. After: p=head; while(p->next && p->next->next) p=p->next->next; what is p->data?
- The number of leaf nodes in a perfect binary tree of height 5 (root at height 0) is
- A simple graph has degree sequence 4, 3, 3, 2, 2. How many edges does it have?
- A graph is bipartite if and only if