0% found this document useful (0 votes)
33 views

Assignment

The document outlines 12 algorithm design problems covering topics like sorting arrays and numbers, searching 2D arrays, finding patterns in strings, verifying binary search trees, and generating permutations with parentheses. It includes examples for each problem and asks for solutions analyzing time and space complexity, such as finding the kth largest number in an array in O(n) time or reversing a sentence in-place without extra space. Solutions would need to address a variety of algorithm challenges, from sorting and searching to string and tree pattern matching.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Assignment

The document outlines 12 algorithm design problems covering topics like sorting arrays and numbers, searching 2D arrays, finding patterns in strings, verifying binary search trees, and generating permutations with parentheses. It includes examples for each problem and asks for solutions analyzing time and space complexity, such as finding the kth largest number in an array in O(n) time or reversing a sentence in-place without extra space. Solutions would need to address a variety of algorithm challenges, from sorting and searching to string and tree pattern matching.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Design Analysis of Algorithms Assignment

1. Push all the zeros of a given array to the end of the array. In place only. Ex 1,2,0,4,0,0,8 become 1,2,4,8,0,0,0. 2. Given a 2D array, all rows and all columns sorted. Find an integer x from the 2D array. 3. Find the no which is most repeated in an array and its frequency in O(n) 4. Given N pair of parenthesis. Write an algorithm which would print out all possible permutations possible with those
parenthesis given that parenthesis are in correct order (i.e. every open parenthesis is matched with closed parenthesis) For .e.g. N =3 should give:
()()() (()()) ()(()) (())() ((()))

5. Given a tree, write algorithm to verify whether it is a BST or not? 6. Write a function f(n) which computes the number of scoring sequences that add up to score n. 7. Given an array, write a function to return the kth largest number in the array. Should do in O (n) time complexity. 8. How many comparisons are required to sort an array of length 5 if a straight selection sort is used and the array is
already sorted in the opposite order?

9. Reverse sentence: Example:


"Hello life " to "life Hello" Test cases

10. Write a function to make the largest number from the digits of a given number.
Example: Number: 32441 Output: 44321 function prototype: C/C++: int biggestNumber(int number) Java: int biggestNumber(int number) Note: Use minimum, constant space

11. Given an array A which has only 0's and 1's in sorted order; find the occurrence of first '1' in A.
Example: A [] = 00001111, returns 5.

12. Write a function which takes a string S and a pattern P and an integer i, and returns the ith occurrence of P in S.
Example: S = "abcabcefgabc", P = "abc", i =3, Returns 10 Source: http://www.careercup.com/page?pid=algorithm-interview-questions&n=2

Ramakant Soni, BKBIET

You might also like