Design a counter system to count number of people

Assignment Help Programming Languages
Reference no: EM132931391

Question 1: Write code to build explicitly all combinations of k 1s in n boxes
k=4, n=12

Recursion: Invoke fun(0.-1)

Define fun(bit_num, prev_bit_pos):
1) If bit_num-k,
(a) Print current combination;
(b) return (exit);

2) Otherwise
for(i-prev_bit_pos+1, i<=n-k+bit_num, i++){
(a) Place 1 at position i;
(b) invoke fun(bit_num+1,1);
(c) clear bit at position i;}

Iteration:
1) Consider all integer numbers from 0 to 2"n-1
2) Convert each int number to binary form
3) Compute the popcount (no. of 1s)
4) If popcount-k. this is one of the desired combination

Complexity: O(2^n)

Complexity: O(n! /( k!(n - k)!)))

Question 2:

Q1: a) Write an assembly language program to send continuously E3H to port 2. Timer 1 mode 1 is used to generate the time delay where the starting count start from AFH.

b) Write a program for the 8051 to transfer letter 'T&A' serially at 9600 baud continuously.

Q2:
a) Design a counter system to count number of people walking through a secured door. The electronic sensor system connected to the door gives a pulse output for each person who walks through door connected to T1 of 8051. Display the number of persons cross through the door using LED's connected at Port 2. Use counter 1 operated in mode 2.

c) Write a subroutine which checks the content of 20H. If it is a positive number, the subroutine find its two's complement and store it in same location and returns.

Question 3:

Need making a program (in C, or Java, or C++, or C#) that creates three new threads (besides the already existing main thread) and synchronizes them in such a way that each thread displays it's thread id in turn for 5 iterations. The output of the program should look like this:

Thread 1 - iteration no. 1

Thread 2 - iteration no. 1

Thread 3 - iteration no. 1

Thread 1 - iteration no. 2

Thread 2 - iteration no. 2

Thread 3 - iteration no. 2

Thread 1 - iteration no. 3

Thread 2 - iteration no. 3

Thread 3 - iteration no. 3

Thread 1 - iteration no. 4

Thread 2 - iteration no. 4

Thread 3 - iteration no. 4

Thread 1 - iteration no. 5

Thread 2 - iteration no. 5

Thread 3 - iteration no. 5

Question 4:

"Polybius was an ancient Greek writer who first proposed a method of substituting different two-digit numbers for each letter. The alphabet is written inside a 5-by-5 2d array which a has numbered rows and columns:

1140_figure.jpg

Note both Y and Z are written in the last cell to divide the letters evenly. The context of the message should make clear which of the two letters is intended.

To encode, substitute for each letter the numbers marking the row and column in which the letter appears. Always put the row number first. For example, the number for J is 25. The word WATERMELON would be encoded as

53 11 45 15 43 33 15 32 35 34

To decode, simply locate each letter indicated by the number. The first number, 53, tells you to find the letter at the intersection of the fifth row and the third column."

Test a program that uses the Polybius Checkerboard to encode strings and decode arrays of numbers.

Question 5:

Your task is to write a program, words, that reports information about the number of words read from standard input. For example, if the file qbf .txt contains the text the quick brown fox jumps over the lazy dog then running the program with its input redirected to come from that file will report 9 words

$ words .g qbf .txt

Total: 9

Before you begin, you will need to check out the practical directory from the topic subversion repository. This can be achieved with the svn utility. Open a command prompt, change into your local CP2 practical directory, and enter the following command (replacing FAN with your FAN):

The check out process will create a words directory representing your working copy. You will need to write all of your code within this directory, so be sure to change into it before reading on.

Automatic marking
This practical is available for automatic marking via the FLO quiz Prac 4 hand-in. To check your solution, first commit your code to the topic repository by typing

svn commit -m "replace this sentence with a suitable commit message"

and then enter the revision number into the answer box for the relevant question (level). There are no penalties for incorrect solutions, so if you fail one or more of the test cases, check the report output, modify your solution, and try again. Remember to finish and submit the quiz when you are ready to hand in. You may complete the quiz as many times as you like; your final mark for the practical will be the highest quiz mark achieved.

Background
The following skeleton code for the program is provided in words .cpp, which will be located inside your working copy directory following the check out process described above.
int main (int argc, chars* argv)
{
enum { total, unique } mode = total;
for (int c; (c = getopt(argc, argv, 'Yu")) != -1;)
9d itch(c) { case 't':
mode = total;
break; case 'u':
mode = unique;
break;
}
}
argc -= optind;
argv -= optind;
string word; int count = 9;

Reference no: EM132931391

Questions Cloud

Analyzing a complete skeleton : Imagine that you are a forensic detective and you have been tasked with analyzing a complete skeleton. How might you go about determining if the skeleton is mal
What process transports stuff like proteins and vesicles : What process transports stuff like proteins and vesicles from the axon terminals to the cell body of the neuron?
Simple randomized control trial designs test one treatment : Simple randomized control trial designs test one treatment; factorial designs test two or more designs including the interaction effects.
What is chronic wasting disease : What is chronic wasting disease? Describe some detail about prions and how they work. give the most up to date information about the state of chronic wasting di
Design a counter system to count number of people : Design a counter system to count number of people walking through a secured door. The electronic sensor system connected to the door gives a pulse output
How is genetic diversity maintained : How is genetic diversity maintained in a flowering plant versus a fern?
Angiosperms and gymnosperms on plant phylogenetic : 1. According to the phylogenetic tree, is phylum Echinodermata more closely related to phylum Chordata or phylum Arthropoda? Explain your answer.
Different chemical gas components of the air we breath : What are the different chemical gas components of the air we breath?
Sketch a line on the graph : Rodents that live alongside a river tend to be three colors - dark brown (BB), beige (B'B'), or light brown in the middle (BB'). The environment around the rive

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a haskell program to calculates a balanced partition

Write a program in Haskell which calculates a balanced partition of N items where each item has a value between 0 and K such that the difference b/w the sum of the values of first partition,

  Create an application to run in the amazon ec2 service

In this project you will create an application to run in the Amazon EC2 service and you will also create a client that can run on local machine and access your application.

  Explain the process to develop a web page locally

Explain the process to develop a Web page locally

  Write functions

These 14 questions covers java class, Array, link list , generic class.

  Programming assignment

If the user wants to read the input from a file, then the output will also go into a different file . If the user wants to read the input interactively, then the output will go to the screen .

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Create a application using the mvc architecture

create a application using the MVC architecture. No scripting elements are allowed in JSP pages.

  Develops bespoke solutions for the rubber industry

Develops bespoke solutions for the rubber industry

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Design a program that assigns seats on an airplane

Write a program that allows an instructor to keep a grade book and also design and implement a program that assigns seats on an airplane.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd