Professional Documents
Culture Documents
Problem Set 2
Problem Set 2
Problem Set 2
CS101
May 2016
Question1:
a. Give the Big O of the following function.
Greedy
Brute
Binary Trees
Random
Divide and Conquer
Question4:
Give difference between recursive and iterative functions.
Computer Science & Engineering Department, UET Lahore
Question5:
Give iterative and recursive implementation of the following.
a. Factorial
b. Summation of series up to n. (1 + 2 + 3 + . + n)
Question6:
Define following.
a. Worst case of algorithm
b. Best case of algorithm
c. Average case of algorithm.
Question7:
How algorithms will help you in your respective engineering practices?
Question8:
Given a bracket sequence, S containing {,[,(,},],) etc. all known brackets.
Devise an algorithm to check if it is a valid sequence i.e. all opening
brackets must have a closing match.
Lets say,
If input => S = {{, (,),}} => output = valid.
If input => S = {{, {,[,]} => output = invalid.
If input => S = {} => output = valid.
If input => S = {{, {,},}} => output = valid.
.
Etc.