assign1 - bargain CD's. These are to be placed in a bargain...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
ECOR 1606 B & C Assignment 1 Put your answers in a plain text file “a1.txt” and submit as Assignment #1. Question 1 (2 marks) A westbound train has come to an industrial siding. The siding may or may not have cars in it. If there are cars in the siding, each car will have a label on it saying whether or not it is to be attached to the train before the train continues westwards. Prepare a set of instructions for the train crew. East West Switch A A1 A2 A3 Main Line Siding Question 2 (2 marks) Write an algorithm that computes 2 N using only basic arithmetic operations (i.e. addition, subtraction, multiplication, and division). Make sure that your algorithm works for any integral N (i.e. N is an integer, but can be negative, zero, or positive). Remember that 2 0 =1, and that for negative N, 2 N = 1/2 ( N) . Question 3 (Bonus Question, worth 1 bonus mark) An employee in a CD store must process a box of newly arrived CD's. Some of the CD's in the box are
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: bargain CD's. These are to be placed in a bargain bin. The other CD's are to be placed in a rack having a number of horizontally arranged slots. Each slot holds one CD. The CD's that are to be placed in the rack are all numbered, and at the end of the process they must all be in numerical order, with the lowest numbered CD in the leftmost rack slot and so on. Note that you may not assume that the CD numbers are sequential. For example, we could have four CDs numbered 100, 45, 100004, and 7. The rack is initially empty. As the box is unpacked only the CD at the top of it can been seen and removed. Produce a set of instructions for the employee. You may assume whatever additional elements (e.g. cardboard boxes, pieces of paper, etc.) that you find necessary. Your instructions may involve only simple steps (e.g. move one CD from somewhere to somewhere else), if then else constructs, and while loops....
View Full Document

This note was uploaded on 02/28/2011 for the course MATH 101 taught by Professor Duke during the Spring '11 term at University of Ottawa.

Ask a homework question - tutors are online