0% found this document useful (0 votes)
30 views1 page

Data Structures and Algorithms

This document contains 5 tutorial questions about data structures and algorithms: 1) It asks to analyze the time complexity of 3 functions: one is O(n^3), one is O(n^2), and one is O(n). 2) It asks for an O(n) algorithm to remove duplicate characters from an array. 3) It asks for an efficient algorithm to check if two unordered arrays contain the same set of numbers. 4) It asks for an algorithm to check if a pair of elements from two sets add up to a given number k. 5) It asks for an efficient algorithm to find the first repeating letter in a string.

Uploaded by

Raji Pillai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views1 page

Data Structures and Algorithms

This document contains 5 tutorial questions about data structures and algorithms: 1) It asks to analyze the time complexity of 3 functions: one is O(n^3), one is O(n^2), and one is O(n). 2) It asks for an O(n) algorithm to remove duplicate characters from an array. 3) It asks for an efficient algorithm to check if two unordered arrays contain the same set of numbers. 4) It asks for an algorithm to check if a pair of elements from two sets add up to a given number k. 5) It asks for an efficient algorithm to find the first repeating letter in a string.

Uploaded by

Raji Pillai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS 010 403: DATA STRUCTURES AND ALGORITHMS

Tutorial Questions

Module 1
TOPICS: Complexity calculation, Hashing
1. What is the complexity of the programs given below:
(i) void function(int n) {
int i, j, k, count =0;
for( i = n/2; i<=n; i++)
for( j = 1; j+n/2<=n; j++)
for( k= 1; k<=n; k=k*2)
count ++;
(ii) void function(int n) {
int i, j;
if(n==1) return;
for( i = 1; i<=n; i++){
for( j= 1; j<=n; j++){
printf(*)
break;
}
}
(iii) void function(int n) {
int i, count = 0;
for( i = 1; i * i <=n; i++){
count ++;
}
2. Given an array of characters, give an algorithm of average complexity (n), for
removing the duplicates.
3. Given two arrays of unordered numbers, propose an efficient algorithm to check
whether both arrays have the same set of numbers.
4. Given two sets A and B, and a number k, give an algorithm for finding whether there
exists a pair of elements, one from A and one from B, that add upto k.
5. Given a string, give an efficient algorithm for finding the first repeating letter in a
string.

You might also like