Skip to main content

PROBLEM SHEET 4

This problem sheet was created by Sir Narasimhan T, Assistant Professor, IT Department LBS College of Engineering, Kasaragod.

The softcopy in .pdf is available here. There is  a bit more in the file.

1)Write a program to reverse the contents of an 1D array without using a second array.

2)Assume that an integer array contains duplicate entries. Find the mode of this array. Mode is that element that occurs the most number of times. A sample input and output is shown below:
Enter array size
7
Enter 7 elements
2  1  -1  2  -1  4  -1
The mode is  -1

3)Rotate an array r times. Print the array after each rotation. A sample input and output is shown below.
Enter the array size
5
Enter the elements
10 7 8 25 16
How many times you want to rotate?
3
Array after rotation 1
16 10 7 8 25
Array after rotation 2
25 16 10 7 8
Array after rotation 3
8 25 16 10 7

4)An election is contested by 5 candidates whose symbols are @, #, $, % and &. The voting is done by marking the candidate symbol on the ballot paper. Get the number of voters from the user, conduct the election and announce the result. If a ballot is marked with a symbol other than those given above, it is considered as spoilt ballot. Spoilt ballots should not be considered during the counting process.

5)You are given the task of evaluating a test of 10 questions each of multiple-choice type. There are 4 possible choices A, B, C and D of which only one is correct. The answers are stored in a string ANSWER such that ith character in the string is the answer of (i+1)th question, 0 ≤ i ≤ 9. Say, if the first 5 questions have answers A and all others have B, then ANSWER is AAAAABBBBB. The student takes the test and submits his answer as a 10 character string TEST. If he doesn’t know the answer, he gives ’X’ for the corresponding question. For example, if the student gives ’A’ for 2nd and 7th questions, 4th question, a ’C’, doesn’t know the answer for 10th question and gives all other questions, a ’D’, his answer string TEST will be DADCDDADDX. Get the number of students from the user and get the answer string of each student and display the marks scored by each student. Assume that each correct answer carries 1 mark and wrong answer has a penalty of 0.25 mark.(negative mark)

6)Insert an element at a given position in the array. Sample input and output is given below:
Enter array size
7
Enter array elements
5  4  8  100  1024  4015  7
Enter the position and element to insert
3  45
The array after insertion of 45 is
5  4  8  45  100  1024  4015  7

7)Delete an element from a given position in the array. Sample input and output is given below:
Enter array size
6
Enter array elements
7 2 108 10 24 15
Enter the position to delete
4
The element deleted is 24 and the array after deletion is
7 2 108 10 15

8)Assume an array has duplicate entries. Remove the duplicate entries from this array. After the removal of all duplicate entries, the remaining elements should be in continuous positions.
Sample input and output is shown below:
Enter array size
9
Enter array elements
1 45 2 1 7 45 28 1 7
The array after removing duplicates is
1 45 2 7 28

Comments

Popular posts from this blog

SNIFF GSM USING HACKRFX

​TOOLS  USED: •  ha ckrf_kali • brategnuradio-companion • gr-gsmgqrx • wireshark INSTALL REQUIREMENTS: First thing, you want to make sure you have all the required software installed, you can install most of them and their dependencies using your distribution package manager. Let’s start with the libraries and tools for the hackrf itself, on a Debian/Ubuntu distro you’ll install them like so: sudo  apt-get install  hackrf   libhackrf -dev libhackrf0 Once these libraries are installed, you can plug your hackrf into one of your USB ports and execute the  hackrf_info  command, at this point you should see something like the following: # hackrf_info Found  HackRF  board. Board ID Number: 2 ( HackRF  One) Firmware Version: 2014.08.1 Part ID Number: 0x00574746 0x00574746 Serial Number: 0x00000000 0x00000000 0x14d463dc 0x2f4339e1 You will now install  gnuradio  which is the software we’ll use to decode the RF signals,...

MORE ABOUT RANSOMWARES. PART 1

 Not long ago, a man committed suicide after an automatically generated notice from a computer virus threatened him with jail unless he paid a ransom thousands of dollars. The year was 2014. As incredible as the story seems, it marked the first known time a computer virus actually killed somebody. The next generations stole cash from users around the globe, and Cryptolocker raised the stakes – holding data of hundreds of thousands of users hostage. Despite successive short-lived take downs, the malware has made a comeback as CTB (Curve-Tor-Bitcoin) Locker. This challenging breed of malware is continuously improving, reaching new levels of complexity as smartphones and tablets are increasingly used to store crucial personal and enterprise-level documents. Bitdefender, the anti-malware solutions provider, zooms in on the subject to show how this type of virus works and to tell users how to prevent being locked out and extorted. What is ransomware? Ransomware is a type of malware th...

SHE, HE TOLD ABOUT

Her handwriting was so beautiful. Each letter had it's own boldness, elegance and I loved to look at them. A pen and a white space, even in a notice, was enough for her to begin. She would write and then look at it, enjoys it's beauty, goes into a serious thought and ends with a small smile. Every of those sequential actions I remember. It is so normal, universal and a must go reality that time moves foreward. Ages, days, hours, everything passes. My happiness on seeing those fonts kept on changing its demensions. My skin began to paint itself lines and so do she. Still, she wrote. But now there is a difference. As timestamps move, the interpretations made by my brain on those texts perplexed from simple happiness to pride, then to a feeling of belongingness, to love, to possessiveness, to responsibility to trust, to many other emotions for which I am weak in English to find words to substitute for and finally to a fear; a fear of death. Wrong. Perfectly wrong. Its not fear. ...