0% found this document useful (0 votes)
11 views2 pages

PF 2B Mock Exam

Uploaded by

QUARANTINE TV
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)
11 views2 pages

PF 2B Mock Exam

Uploaded by

QUARANTINE TV
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/ 2

National University of Computer & Emerging Sciences, Karachi

Spring-2020 Computer Science Department


Mock Exam

Course Code: CS118 Course Name: Programming Fundamentals


Instructor Name: Ms. Farah Sadia

Time: 35 minutes. Max Marks: 20

PDF Formation time: 15 minutes

String
Question # 01: Max. Time: 20, Marks: 10,

Mr. Faisal wants a search feature for his language training website. One can submit a word as a
query and the site would return the meaning of that word from a language dictionary. A user
however, may sometimes have spell errors in his input. Mr. Faisal wants to take care of this and
wants to give him suggestions like "Did you mean this another word?". Mr. Faisal needs your
help. You need to write a program that would compare the proximity of two strings according
to a given set of rules designed by Mr. Faisal and decide whether one can be suggested for
another.

Input Description:
First line of input will contain an integer T = number of test cases. Next T lines will each contain
two strings consisting only of lower case English letters separated by space. Strings are
compared by these rules designed by Mr. X :
1. All the vowels plus the letter 'y' - set of characters: { 'a', 'e' , 'i', 'o', 'u', 'y' } are removed
from both the strings if they are present at any index other than 0. First letter is not
removed even if it's a vowel or 'y'.
2. Two strings are similar and can be suggested for each other if the first characters after
modification by rule 1 are the same and remaining characters after modification are not
different at more than 2 positions. If resulting strings after applying rule 1 are of
unequal length, all the extra indices in the larger string should be counted as having
different characters. e.g: if we get "bcd" and "bkd" after applying rule 1, they differ at
one position. "pqrs" and "pq" differ at 2 positions, (extra positions in "pqrs")
Output Description:
For each test case, print "YES", if the strings can be suggested for each other using the given
comparison logic, else print "NO".

Dynamic Memory Allocation


Note: Must attempt it with DMA. Otherwise not will be considered.

Question # 02: Max. Time: 15, Marks: 10,

Given a list of integers, find out the number that has the highest frequency. If there are one or
more such numbers, output the smaller one.

Input Description:
First line of input will contain an integer T = number of test cases. Each test case will contain
two lines. First line will contain an integer N = number of elements in the sequence and 1 <= N
<= 1000. Next line will contain N space separated integers of sequence A. For each Ai in
sequence A, 1<= Ai <= 10001.

Output Description:
For each test case, print on a single line, the number with highest frequency in the sequence.

You might also like