Question 1 (3 Points) : January 22, 2020

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

LAB-02

January 22, 2020

Question 1(3 Points)


Given two strings a and b consisting of lowercase characters. The task is to check whether two given strings
are anagram of each other or not. If two string are anagram of each other then print ”YES” else print ”No”.
An anagram of a string is another string that contains same characters, only the order of characters can be
different. For example, “act” and “tac” are anagram of each other.

Input Format:The first line consist of two strings in ’lowercase’ only, in a single line.

Input:
geeksforgeeks forgeeksgeeks
allergy allergic
Output:
YES
NO

Question 2(5 Points)


Given a square matrix mat of size N x N. The task is to find the determinant of this matrix.

Input Format: First line of input contains an integer N denoting the size of the matrix. The next line
contains the elements of the matrix in row-wise form..

Input:
4
1 0 2 -1 3 0 0 5 2 1 4 -3 1 0 5 0

Output:
30

Question 3(5 Points)


Recursive program to generate power set
Given a set represented as string, write a recursive code to print all subsets of it. The subsets can be printed
in any order.

Input Format: The first line contains an string ’S’ denoting the set

Input:
abc

1
Output:
””, ”a”, ”b”, ”c”, ”ab”, ”ac”, ”bc”, ”abc”

Question 4(7 Points)


Given an integer ‘K’ and a row-wise sorted 2-D Matrix i.e. the matrix has the following properties:
Integers in each row are sorted from left to right.
The first integer of each row is greater than the last integer of the previous row.
The task is to apply binary search to find the integer ‘K’ is present in the matrix or not. If present then
print ‘Found’ else print ‘Not found’.

Input Format: The first line contains the integers N, M denoting the size of matrix followed by the
N lines which contains the element of the matrix and the last line contains the element to be searched.

Input:
34
1357
10 11 16 20
23 30 34 50
3

Output:
Found

You might also like